diff --git a/.gitignore b/.gitignore index f33e16fbb..eb42f09ac 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4compiler/ *.out *.app +.idea +*.iml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..c660db4c1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "org.alloytools.pardinus"] + path = org.alloytools.pardinus + url = https://github.com/haslab/Pardinus diff --git a/.travis.yml b/.travis.yml index 9d539bc94..5bfcad44c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,12 @@ -dist: trusty -sudo: false +dist: focal language: java -jdk: -- oraclejdk8 -install: "./gradlew --version" -script: ./gradlew --no-daemon -DGRADLE_OPTS="-Xms128m" --stacktrace build -i -after_success: -- git status -- echo $REPOSITORY_USERNAME -- echo $TRAVIS_PULL_REQUEST -- echo $TRAVIS_BRANCH -- if [ master == $TRAVIS_BRANCH -a $TRAVIS_PULL_REQUEST == false -a ${REPOSITORY_USERNAME:=X} - != X ]; then ./gradlew -DGRADLE_OPTS="-Xms128m" release -i; fi +before_install: + - curl -L "http://nusmv.fbk.eu/distrib/NuSMV-2.6.0-zchaff-linux64.tar.gz" | tar --extract --gzip --strip-components=2 -C $HOME/bin "NuSMV-2.6.0-Linux/bin/NuSMV" || true + - curl -N -L "http://es-static.fbk.eu/tools/nuxmv/downloads/nuXmv-2.0.0-linux64.tar.gz" | tar --extract --gzip --strip-components=2 -C $HOME/bin "nuXmv-2.0.0-Linux/bin/nuXmv" || true +install: + - "gradle --version" +script: travis_wait gradle --no-daemon -DGRADLE_OPTS="-Xms128m" --stacktrace build -i cache: directories: - "$HOME/.gradle" -env: - secure: "iMLby/ptj+UObydTJmFj2VO3QoYOiLmNC6kl7HOeSek7Jeo1LNV/+PXZ01o72t2QszFVux2gDcUBlaZKFXsvN585rT0JGRf7R9EA5qiRzetPmWJaA4vdY+GSZR4O0DiOuBcp+KGS5rBHmi3NoKlLAeO/CrHLFyAv2qjofsECUwmsRsS47aCepC7qllla+8PiQbyse6wytJKIqvk4n7BDXXOfQLM6Y5LZ/5uFs6PKyiLlXBmlG5LzdMtxlEED1nOEmLKak7ZjP2VwpJ3KSFGyu7/l9lf+IFnnXAIZaGvARbTDUhF3cyoZgP2Ab5yWJEB1uYzkoNwczmW5ARfalKkjBAV8DuZJFSe39K7XcWVvWRMGTpUSUKA20BpD+wW3q1x8s8Vw+CLuRzCO6QD3uG+JZX2URIBt4F50SpS07HHAd0c6hzv9M4cjd5l9wBYH2nFX1uUuza6znuk3DJ69bM9INMQ+8A5fkSUaXEw/7ym3a+GQINrFtYftcDm915wAznS5Sa86tK2icDtV4vCdTikXLtu6xmYJ4raliGN0E3yL9agW0J1dMjzK+D6l6zXo/qVT+qjwN8+KSFaaYpGYGotqYT4ZnzR9gE85LZWAYLKgsyOOvMopl9MxRVDSKPomUW48aLpG4G80r2NDG3paxA8xS7esDJTBPNCYKuh7Gn3Cp8s=" - + - "$HOME/bin" diff --git a/README.md b/README.md index 146032ec8..043d8bea9 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ [![Build Status](https://travis-ci.org/AlloyTools/org.alloytools.alloy.svg?branch=master)](https://travis-ci.org/AlloyTools/org.alloytools.alloy) # Alloy -Alloy 4 is a self-contained executable, which includes the Kodkod -model finder and a variety of SAT solvers, as well as the standard -Alloy library and a collection of tutorial examples. The same jar file -can be incorporated into other applications to use Alloy as an API, -and includes the source code. See the release notes for details of new +Alloy 6 is a self-contained executable, which includes an extended version of +the Kodkod model finder and a variety of SAT solvers, as well as the standard +Alloy library and a collection of tutorial examples. The same jar file can be +incorporated into other applications to use Alloy as an API, and includes the +source code. See the release notes for details of new features. More documentation can be found at: http://alloytools.org/documentation.html. @@ -28,12 +28,12 @@ Checkout the project and type `./gradlew build`. You find the executable JAR in java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed model - $ git clone https://github.com/AlloyTools/org.alloytools.alloy.git + $ git clone --recursive https://github.com/AlloyTools/org.alloytools.alloy.git $ cd org.alloytools.alloy $ ./gradlew build $ java -jar org.alloytools.alloy.dist/target/org.alloytools.alloy.dist.jar # opens GUI - + Note: if you are behind a proxy, the call to `gradlew` is likely to fail, unless you pass it further options about the http and https proxies (and possibly your login and password on this proxy). There are several ways to pass these options, a simple one is to type (replace the `XXXXX`'s by the adequate settings): $ ./gradlew -Dhttps.proxyHost=XXXXX -Dhttp.proxyHost=XXXXX -Dhttp.proxyPort=XXXXX \ @@ -53,8 +53,8 @@ The workspace is divided into a number of projects: * [org.alloytools.alloy.application](org.alloytools.alloy.application) – Main application code includes the parser, ast, visualiser, and application code * [org.alloytools.alloy.dist](org.alloytools.alloy.dist) – Project to create the distribution executable JAR * [org.alloytools.alloy.extra](org.alloytools.alloy.extra) – Models and examples -* [org.alloytools.kodkod.core](org.alloytools.kodkod.core) – Kodkod without native code -* [org.alloytools.kodkod.nativesat](org.alloytools.kodkod.nativesat) – The native code libraries for kodkod +* [org.alloytools.pardinus](org.alloytools.pardinus) – A Kodkod extension without native code +* [org.alloytools.kodkod.nativesat](org.alloytools.kodkod.nativesat) – The native code libraries for Kodkod ### Relevant Project files @@ -97,7 +97,9 @@ In the root of this workspace type `./gradlew`. This is a script that will downl ### Continuous Integration -The workspace is setup to build after every commit using Travis. It releases snapshots to `https://oss.sonatype.org/content/repositories/snapshots/org/alloytools/` for every CI build on Travis. +The workspace is setup to build after every commit using Travis. + +It releases snapshots to `https://oss.sonatype.org/content/repositories/snapshots/org/alloytools/` for every CI build on Travis. ### Building the DMG file for OSX systems diff --git a/cnf/.classpath b/cnf/.classpath index fb5011632..ca962805d 100644 --- a/cnf/.classpath +++ b/cnf/.classpath @@ -3,4 +3,4 @@ - + \ No newline at end of file diff --git a/cnf/build.bnd b/cnf/build.bnd index 6c71c8f5e..8a3b7e44e 100644 --- a/cnf/build.bnd +++ b/cnf/build.bnd @@ -9,8 +9,8 @@ testbin: target/test-classes target-dir: target javac.source: 1.8 -javac.target: ${javac.source} -javac.compliance: ${javac.source} +javac.target: 1.8 +javac.compliance: 1.8 javac.debug: on Git-Descriptor: ${system-allow-fail;git describe --dirty --always} @@ -21,7 +21,7 @@ Bundle-Vendor: AlloyTools at Github Bundle-DocURL: http://alloytools.org Bundle-License: MIT -base.version: 5.1.0 +base.version: 6.0.0 Bundle-Version: ${base.version}.${tstamp} # Remove -SNAPSHOT for release version diff --git a/cnf/central.xml b/cnf/central.xml index 6de780cf2..e60bb8c11 100644 --- a/cnf/central.xml +++ b/cnf/central.xml @@ -8,6 +8,10 @@ pom + + 1.1.7 + + org.eclipse.jdt @@ -24,6 +28,18 @@ org.sat4j.core 2.3.1 + + org.sat4j + org.sat4j.maxsat + 2.3.1 + compile + + + org.sat4j + org.sat4j.pb + 2.3.1 + compile + de.jflex jflex @@ -34,6 +50,16 @@ java-cup 11b-20160615 + + org.slf4j + slf4j-api + 1.7.28 + + + org.slf4j + slf4j-simple + 1.7.5 + diff --git a/cnf/jars/java-cup-11a.jar b/cnf/jars/java-cup-11a.jar index 73ffa0b33..46dd51639 100644 Binary files a/cnf/jars/java-cup-11a.jar and b/cnf/jars/java-cup-11a.jar differ diff --git a/cnf/jars/java-cup-runtime-0.11-a-czt01-cdh.jar b/cnf/jars/java-cup-runtime-0.11-a-czt01-cdh.jar new file mode 100644 index 000000000..f0ed64cf5 Binary files /dev/null and b/cnf/jars/java-cup-runtime-0.11-a-czt01-cdh.jar differ diff --git a/org.alloytools.alloy.application/.classpath b/org.alloytools.alloy.application/.classpath index 55864cdf7..bcafe71e5 100644 --- a/org.alloytools.alloy.application/.classpath +++ b/org.alloytools.alloy.application/.classpath @@ -1,9 +1,12 @@ - - - - + + + + + + + diff --git a/org.alloytools.alloy.application/.settings/org.eclipse.jdt.core.prefs b/org.alloytools.alloy.application/.settings/org.eclipse.jdt.core.prefs index 581b9f158..2f809de6d 100644 --- a/org.alloytools.alloy.application/.settings/org.eclipse.jdt.core.prefs +++ b/org.alloytools.alloy.application/.settings/org.eclipse.jdt.core.prefs @@ -133,12 +133,16 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=4 org.eclipse.jdt.core.formatter.align_type_members_on_columns=true +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=2 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=51 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=50 @@ -148,6 +152,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_e org.eclipse.jdt.core.formatter.alignment_for_assignment=2 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=2 org.eclipse.jdt.core.formatter.alignment_for_compact_if=2 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=2 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=2 @@ -191,6 +196,8 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true @@ -242,13 +249,13 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert @@ -415,6 +422,9 @@ org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false diff --git a/org.alloytools.alloy.application/.settings/org.eclipse.jdt.ui.prefs b/org.alloytools.alloy.application/.settings/org.eclipse.jdt.ui.prefs index dcee2a4d2..5ba47fdd1 100644 --- a/org.alloytools.alloy.application/.settings/org.eclipse.jdt.ui.prefs +++ b/org.alloytools.alloy.application/.settings/org.eclipse.jdt.ui.prefs @@ -31,7 +31,9 @@ cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=tru cleanup.qualify_static_member_accesses_with_declaring_class=true cleanup.qualify_static_method_accesses_with_declaring_class=false cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true +cleanup.remove_redundant_modifiers=false +cleanup.remove_redundant_semicolons=false +cleanup.remove_redundant_type_arguments=false cleanup.remove_trailing_whitespaces=false cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false @@ -60,7 +62,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Alloy -formatter_settings_version=13 +formatter_settings_version=14 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true @@ -88,7 +90,7 @@ sp_cleanup.convert_functional_interfaces=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false +sp_cleanup.format_source_code_changes_only=true sp_cleanup.insert_inferred_type_arguments=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false @@ -105,6 +107,8 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class= sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false sp_cleanup.remove_redundant_type_arguments=false sp_cleanup.remove_trailing_whitespaces=true sp_cleanup.remove_trailing_whitespaces_all=true diff --git a/org.alloytools.alloy.application/bnd.bnd b/org.alloytools.alloy.application/bnd.bnd index 28ed13169..298a54ca5 100644 --- a/org.alloytools.alloy.application/bnd.bnd +++ b/org.alloytools.alloy.application/bnd.bnd @@ -3,8 +3,8 @@ -buildpath: \ lib/apple-osx-ui.jar;version=file,\ + org.alloytools.pardinus;version=latest,\ org.alloytools.alloy.core;version=latest,\ - org.alloytools.kodkod.core;version=latest -testpath: \ osgi.enroute.junit.wrapper, \ @@ -15,9 +15,8 @@ org.alloytools.kodkod.nativesat.x86-linux, \ org.alloytools.kodkod.nativesat.x86-mac, \ org.alloytools.kodkod.nativesat.x86-windows - + Private-Package: \ edu.mit.csail.sdg.alloy4graph,\ edu.mit.csail.sdg.alloy4viz,\ edu.mit.csail.sdg.alloy4whole,\ - diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/Graph.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/Graph.java index fb293d337..c3eed7800 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/Graph.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/Graph.java @@ -37,6 +37,9 @@ * Mutable; represents a graph. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] changed so that nodes are sorted lexicographically + * within each layer of the graph */ public final strictfp class Graph { @@ -313,7 +316,18 @@ private void layout_assignOrder() { grOUT.get(n.pos()).remove(x); for (GraphNode n : grOUT.get(x.pos())) grIN.get(n.pos()).remove(x); - for (GraphNode n : Util.fastJoin(grIN.get(x.pos()), grOUT.get(x.pos()))) { + // [electrum] hack to get nodes sorted lexicographically within each layer + // can't fast join since read-only + // Iterable aux = Util.fastJoin(grIN.get(x.pos()), ); + List aux = new ArrayList(grIN.get(x.pos())); + aux.addAll(grOUT.get(x.pos())); + aux.sort(new Comparator() { + + public int compare(GraphNode o1, GraphNode o2) { + return -o1.uuid.toString().compareTo(o2.uuid.toString()); + } + }); + for (GraphNode n : aux) { int ni = n.pos(), out = grOUT.get(ni).size(), in = grIN.get(ni).size(); int b = (out == 0) ? 0 : (in == 0 ? (2 * num) : (out - in + num)); if (grBIN[ni] != b) { diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/GraphViewer.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/GraphViewer.java index 8a75ecbaf..e6ef4cdf6 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/GraphViewer.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4graph/GraphViewer.java @@ -61,6 +61,9 @@ * This class displays the graph. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] added the ability to update the scale (needed to be + * preserved when navigating traces) */ public final strictfp class GraphViewer extends JPanel { @@ -695,6 +698,16 @@ public Dimension getPreferredSize() { return new Dimension((int) (graph.getTotalWidth() * scale), (int) (graph.getTotalHeight() * scale)); } + /** Returns the zoom level of this graph. */ + public double getScale() { + return scale; + } + + /** Updates the zoom level of this graph. */ + public void setScale(double scale) { + this.scale = scale; + } + /** * This method is called by Swing to draw this component. */ diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyRelation.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyRelation.java index 91118fb44..99b24c57c 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyRelation.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyRelation.java @@ -26,6 +26,8 @@ * Immutable; represents an Alloy relation of 2 or higher arity. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] changed to register whether a relation is mutable */ public final class AlloyRelation extends AlloyElement { @@ -34,13 +36,13 @@ public final class AlloyRelation extends AlloyElement { * This caches an instance of the "extends" AlloyRelation, so we don't have to * keep re-constructing it. */ - public static final AlloyRelation EXTENDS = new AlloyRelation("extends", false, false, Util.asList(AlloyType.UNIV, AlloyType.UNIV)); + public static final AlloyRelation EXTENDS = new AlloyRelation("extends", false, false, false, Util.asList(AlloyType.UNIV, AlloyType.UNIV)); /** * This caches an instance of the "in" AlloyRelation, so we don't have to keep * re-constructing it. */ - public static final AlloyRelation IN = new AlloyRelation("in", false, false, Util.asList(AlloyType.SET, AlloyType.UNIV)); + public static final AlloyRelation IN = new AlloyRelation("in", false, false, false, Util.asList(AlloyType.SET, AlloyType.UNIV)); /** The unmodifiable list of types. */ private final ConstList types; @@ -57,17 +59,24 @@ public final class AlloyRelation extends AlloyElement { */ public final boolean isMeta; + /** + * Records whether this relation is known to be "var"; NOTE: this value is NOT + * USED during equals() comparison. + */ + public final boolean isVar; + /** * Constructs a new AlloyRelation with that name and that list of types; * types.size() must be 2 or above. */ - public AlloyRelation(String name, boolean isPrivate, boolean isMeta, List types) { + public AlloyRelation(String name, boolean isPrivate, boolean isMeta, boolean isVar, List types) { super(name); if (types == null || types.size() < 2) throw new RuntimeException("An AlloyRelation object must have 2 or more types."); this.types = ConstList.make(types); this.isPrivate = isPrivate; this.isMeta = isMeta; + this.isVar = isVar; } /** diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloySet.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloySet.java index e066855c0..d82c5ebdb 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloySet.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloySet.java @@ -21,6 +21,8 @@ * Immutable; represents an Alloy set in an instance. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] changed to register whether a subset is mutable */ public final class AlloySet extends AlloyNodeElement { @@ -40,12 +42,19 @@ public final class AlloySet extends AlloyNodeElement { */ public final boolean isMeta; + /** + * Records whether this relation is known to be "variable"; NOTE: this value is + * NOT USED during equals() comparison. + */ + public final boolean isVar; + /** Constructs a new AlloySet object. */ - public AlloySet(String name, boolean isPrivate, boolean isMeta, AlloyType type) { + public AlloySet(String name, boolean isPrivate, boolean isMeta, boolean isVar, AlloyType type) { super(name); this.type = type; this.isPrivate = isPrivate; this.isMeta = isMeta; + this.isVar = isVar; } /** Returns the parent type of the AlloySet. */ diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyType.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyType.java index 68381c6df..e2915b958 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyType.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/AlloyType.java @@ -21,6 +21,8 @@ * Immutable; represents an Alloy toplevel signature or an Alloy subsignature. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] changed to register whether a sig is mutable */ public final class AlloyType extends AlloyNodeElement { @@ -29,34 +31,34 @@ public final class AlloyType extends AlloyNodeElement { * This caches an instance of the "univ" AlloyType, so we don't have to keep * re-constructing it. */ - public static final AlloyType UNIV = new AlloyType("univ", false, false, true, false, false, false); + public static final AlloyType UNIV = new AlloyType("univ", false, false, true, false, false, false, false); /** * This caches an instance of the "Int" AlloyType, so we don't have to keep * re-constructing it. */ - public static final AlloyType INT = new AlloyType("Int", false, false, true, false, false, false); + public static final AlloyType INT = new AlloyType("Int", false, false, true, false, false, false, false); /** * This caches an instance of the "seq/Int" AlloyType, so we don't have to keep * re-constructing it. */ - public static final AlloyType SEQINT = new AlloyType("seq/Int", false, false, true, false, false, false); + public static final AlloyType SEQINT = new AlloyType("seq/Int", false, false, true, false, false, false, false); /** * This caches an instance of the "String" AlloyType, so we don't have to keep * re-constructing it. */ - public static final AlloyType STRING = new AlloyType("String", false, false, true, false, false, false); + public static final AlloyType STRING = new AlloyType("String", false, false, true, false, false, false, false); /** * This caches an instance of the "set" AlloyType, so we don't have to keep * re-constructing it. */ - public static final AlloyType SET = new AlloyType("set", false, false, false, false, false, false); + public static final AlloyType SET = new AlloyType("set", false, false, false, false, false, false, false); /** Constructs an AlloyType object with that name. */ - public AlloyType(String name, boolean isOne, boolean isAbstract, boolean isBuiltin, boolean isPrivate, boolean isMeta, boolean isEnum) { + public AlloyType(String name, boolean isOne, boolean isAbstract, boolean isBuiltin, boolean isPrivate, boolean isMeta, boolean isEnum, boolean isVar) { super(name); this.isOne = isOne; this.isAbstract = isAbstract; @@ -64,6 +66,7 @@ public AlloyType(String name, boolean isOne, boolean isAbstract, boolean isBuilt this.isPrivate = isPrivate; this.isMeta = isMeta; this.isEnum = isEnum; + this.isVar = isVar; } /** @@ -102,6 +105,12 @@ public AlloyType(String name, boolean isOne, boolean isAbstract, boolean isBuilt */ public final boolean isEnum; + /** + * Records whether this sig is known to be "var"; NOTE: this value is NOT USED + * during equals() comparison. + */ + public final boolean isVar; + /** * When comparing two AlloyType objects, we compare their names.
* We guarantee x.equals(y) iff x.compareTo(y)==0 diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticInstanceReader.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticInstanceReader.java index 0927fa059..713516543 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticInstanceReader.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticInstanceReader.java @@ -46,6 +46,10 @@ * This utility class parses an XML file into an AlloyInstance object. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] creates an AlloyInstance for a particular state after + * parsing the XML of a full instance trace (expressions evaluated in + * that state); whether elements are mutable is also registered */ public final class StaticInstanceReader { @@ -107,11 +111,11 @@ public final class StaticInstanceReader { /** * Create a new AlloyType whose label is unambiguous with any existing one. */ - private AlloyType makeType(String label, boolean isOne, boolean isAbstract, boolean isBuiltin, boolean isPrivate, boolean isMeta, boolean isEnum) { + private AlloyType makeType(String label, boolean isOne, boolean isAbstract, boolean isBuiltin, boolean isPrivate, boolean isMeta, boolean isEnum, boolean isVar) { if (label.startsWith("this/")) label = label.substring(5); while (true) { - AlloyType ans = new AlloyType(label, isOne, isAbstract, isBuiltin, isPrivate, isMeta, isEnum); + AlloyType ans = new AlloyType(label, isOne, isAbstract, isBuiltin, isPrivate, isMeta, isEnum, isVar); if (!sig2type.values().contains(ans)) return ans; label = label + "'"; @@ -121,11 +125,11 @@ private AlloyType makeType(String label, boolean isOne, boolean isAbstract, bool /** * Create a new AlloySet whose label is unambiguous with any existing one. */ - private AlloySet makeSet(String label, boolean isPrivate, boolean isMeta, AlloyType type) { + private AlloySet makeSet(String label, boolean isPrivate, boolean isMeta, boolean isVar, AlloyType type) { while (label.equals(Sig.UNIV.label) || label.equals(Sig.SIGINT.label) || label.equals(Sig.SEQIDX.label) || label.equals(Sig.STRING.label)) label = label + "'"; while (true) { - AlloySet ans = new AlloySet(label, isPrivate, isMeta, type); + AlloySet ans = new AlloySet(label, isPrivate, isMeta, isVar, type); if (!sets.contains(ans)) return ans; label = label + "'"; @@ -135,11 +139,11 @@ private AlloySet makeSet(String label, boolean isPrivate, boolean isMeta, AlloyT /** * Create a new AlloyRelation whose label is unambiguous with any existing one. */ - private AlloyRelation makeRel(String label, boolean isPrivate, boolean isMeta, List types) { + private AlloyRelation makeRel(String label, boolean isPrivate, boolean isMeta, boolean isVar, List types) { while (label.equals(Sig.UNIV.label) || label.equals(Sig.SIGINT.label) || label.equals(Sig.SEQIDX.label) || label.equals(Sig.STRING.label)) label = label + "'"; while (true) { - AlloyRelation ans = new AlloyRelation(label, isPrivate, isMeta, types); + AlloyRelation ans = new AlloyRelation(label, isPrivate, isMeta, isVar, types); if (!rels.containsKey(ans)) return ans; label = label + "'"; @@ -155,7 +159,7 @@ private AlloyType sig(PrimSig s) throws Err { throw new ErrorFatal("Unexpected sig \"none\" encountered."); AlloyType ans = sig2type.get(s); if (ans == null) { - ans = makeType(s.label, s.isOne != null, s.isAbstract != null, false, s.isPrivate != null, s.isMeta != null, s.isEnum != null); + ans = makeType(s.label, s.isOne != null, s.isAbstract != null, false, s.isPrivate != null, s.isMeta != null, s.isEnum != null, s.isVariable != null); sig2type.put(s, ans); if (s.parent != Sig.UNIV) ts.put(ans, sig(s.parent)); @@ -182,7 +186,7 @@ else if (s == Sig.SEQIDX) else if (s == Sig.STRING) type = AlloyType.STRING; else - type = makeType(s.label, s.isOne != null, s.isAbstract != null, false, s.isPrivate != null, s.isMeta != null, s.isEnum != null); + type = makeType(s.label, s.isOne != null, s.isAbstract != null, false, s.isPrivate != null, s.isMeta != null, s.isEnum != null, s.isVariable != null); sig2type.put(s, type); AlloyAtom atom = new AlloyAtom(type, (type == AlloyType.SEQINT ? Integer.MIN_VALUE : Integer.MAX_VALUE), s.label); atom2sets.put(atom, new LinkedHashSet()); @@ -206,7 +210,7 @@ private void sigMETA(SubsetSig s) throws Err { AlloyType type = sig2type.get(s); if (type != null) return; - type = makeType(s.label, s.isOne != null, s.isAbstract != null, false, s.isPrivate != null, s.isMeta != null, s.isEnum != null); + type = makeType(s.label, s.isOne != null, s.isAbstract != null, false, s.isPrivate != null, s.isMeta != null, s.isEnum != null, s.isVariable != null); atom = new AlloyAtom(type, Integer.MAX_VALUE, s.label); atom2sets.put(atom, new LinkedHashSet()); sig2atom.put(s, atom); @@ -222,13 +226,14 @@ private void sigMETA(SubsetSig s) throws Err { } /** Constructs the atoms corresponding to the given sig. */ - private void atoms(A4Solution sol, PrimSig s) throws Err { + private void atoms(A4Solution sol, PrimSig s, int state) throws Err { Expr sum = Sig.NONE; for (PrimSig c : s.children()) { sum = sum.plus(c); - atoms(sol, c); + atoms(sol, c, state); } - A4TupleSet ts = (A4TupleSet) (sol.eval(s.minus(sum))); // This ensures + A4TupleSet ts = (A4TupleSet) (sol.eval(s.minus(sum), state)); + // This ensures // that atoms // will be // associated @@ -242,7 +247,8 @@ private void atoms(A4Solution sol, PrimSig s) throws Err { } catch (NumberFormatException ex) { i = Integer.MAX_VALUE; } - AlloyAtom at = new AlloyAtom(sig(s), ts.size() == 1 ? Integer.MAX_VALUE : i, atom); + // [electrum] do not hide ids for variable singletons, their id may change between states + AlloyAtom at = new AlloyAtom(sig(s), ts.size() == 1 && s.isVariable == null ? Integer.MAX_VALUE : i, atom); atom2sets.put(at, new LinkedHashSet()); string2atom.put(atom, at); } @@ -251,13 +257,13 @@ private void atoms(A4Solution sol, PrimSig s) throws Err { /** * Construct an AlloySet or AlloyRelation corresponding to the given expression. */ - private void setOrRel(A4Solution sol, String label, Expr expr, boolean isPrivate, boolean isMeta) throws Err { + private void setOrRel(A4Solution sol, String label, Expr expr, boolean isPrivate, boolean isMeta, boolean isVar, int state) throws Err { for (List ps : expr.type().fold()) { if (ps.size() == 1) { PrimSig t = ps.get(0); - AlloySet set = makeSet(label, isPrivate, isMeta, sig(t)); + AlloySet set = makeSet(label, isPrivate, isMeta, isVar, sig(t)); sets.add(set); - for (A4Tuple tp : (A4TupleSet) (sol.eval(expr.intersect(t)))) { + for (A4Tuple tp : (A4TupleSet) (sol.eval(expr.intersect(t), state))) { atom2sets.get(string2atom.get(tp.atom(0))).add(set); } } else { @@ -270,9 +276,9 @@ private void setOrRel(A4Solution sol, String label, Expr expr, boolean isPrivate else mask = mask.product(ps.get(i)); } - AlloyRelation rel = makeRel(label, isPrivate, isMeta, types); + AlloyRelation rel = makeRel(label, isPrivate, isMeta, isVar, types); Set ts = new LinkedHashSet(); - for (A4Tuple tp : (A4TupleSet) (sol.eval(expr.intersect(mask)))) { + for (A4Tuple tp : (A4TupleSet) (sol.eval(expr.intersect(mask), state))) { AlloyAtom[] atoms = new AlloyAtom[tp.arity()]; for (int i = 0; i < tp.arity(); i++) { atoms[i] = string2atom.get(tp.atom(i)); @@ -287,7 +293,7 @@ private void setOrRel(A4Solution sol, String label, Expr expr, boolean isPrivate } /** Parse the file into an AlloyInstance if possible. */ - private StaticInstanceReader(XMLNode root) throws Err { + private StaticInstanceReader(XMLNode root, int state) throws Err { XMLNode inst = null; for (XMLNode sub : root) if (sub.is("instance")) { @@ -317,15 +323,15 @@ private StaticInstanceReader(XMLNode root) throws Err { sig((PrimSig) s); for (Sig s : toplevels) if (!s.builtin || s == Sig.STRING) - atoms(sol, (PrimSig) s); + atoms(sol, (PrimSig) s, state); for (Sig s : sol.getAllReachableSigs()) if (s instanceof SubsetSig) - setOrRel(sol, s.label, s, s.isPrivate != null, s.isMeta != null); + setOrRel(sol, s.label, s, s.isPrivate != null, s.isMeta != null, s.isVariable != null, state); for (Sig s : sol.getAllReachableSigs()) for (Field f : s.getFields()) - setOrRel(sol, f.label, f, f.isPrivate != null, f.isMeta != null); + setOrRel(sol, f.label, f, f.isPrivate != null, f.isMeta != null, f.isVariable != null, state); for (ExprVar s : sol.getAllSkolems()) - setOrRel(sol, s.label, s, false, false); + setOrRel(sol, s.label, s, false, false, false, state); } if (isMeta) { sigMETA(Sig.UNIV); @@ -341,7 +347,7 @@ private StaticInstanceReader(XMLNode root) throws Err { types.add(sig(ps.get(i))); tuple[i] = sig2atom.get(ps.get(i)); } - AlloyRelation rel = makeRel(f.label, f.isPrivate != null, false, types); + AlloyRelation rel = makeRel(f.label, f.isPrivate != null, false, f.isVariable != null, types); rels.put(rel, Util.asSet(new AlloyTuple(tuple))); } } @@ -411,9 +417,9 @@ private StaticInstanceReader(XMLNode root) throws Err { } /** Parse the file into an AlloyInstance if possible. */ - public static AlloyInstance parseInstance(File file) throws Err { + public static AlloyInstance parseInstance(File file, int state) throws Err { try { - return (new StaticInstanceReader(new XMLNode(file))).ans; + return (new StaticInstanceReader(new XMLNode(file), state)).ans; } catch (IOException ex) { throw new ErrorFatal("Error reading the XML file: " + ex, ex); } @@ -423,9 +429,9 @@ public static AlloyInstance parseInstance(File file) throws Err { * Parse the file into an AlloyInstance if possible, then close the Reader * afterwards. */ - public static AlloyInstance parseInstance(Reader reader) throws Err { + public static AlloyInstance parseInstance(Reader reader, int state) throws Err { try { - return (new StaticInstanceReader(new XMLNode(reader))).ans; + return (new StaticInstanceReader(new XMLNode(reader), state)).ans; } catch (IOException ex) { throw new ErrorFatal("Error reading the XML file: " + ex, ex); } diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticProjector.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticProjector.java index e708034fb..d48949376 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticProjector.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/StaticProjector.java @@ -28,6 +28,8 @@ * This utility class performs projection of AlloyModel and AlloyInstance. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] propagate whether elements are mutable after projection */ public final class StaticProjector { @@ -98,13 +100,13 @@ private static AlloyModel project(AlloyModel unprojectedModel, Collection 1) { - relations.add(new AlloyRelation(rel.getName(), rel.isPrivate, rel.isMeta, relTypes)); + relations.add(new AlloyRelation(rel.getName(), rel.isPrivate, rel.isMeta, rel.isVar, relTypes)); if (data != null) data.put(rel, indices); } // If it contains only one type, it becomes a new set. else if (relTypes.size() == 1) { - sets.add(new AlloySet(rel.getName(), rel.isPrivate, rel.isMeta, relTypes.get(0))); + sets.add(new AlloySet(rel.getName(), rel.isPrivate, rel.isMeta, rel.isVar, relTypes.get(0))); if (data != null) data.put(rel, indices); } @@ -168,7 +170,7 @@ public static AlloyInstance project(AlloyInstance oldInstance, AlloyProjection p List newTuple = oldTuple.project(list); List newObj = r.project(list); if (newObj.size() > 1 && newTuple.size() > 1) { - AlloyRelation r2 = new AlloyRelation(r.getName(), r.isPrivate, r.isMeta, newObj); + AlloyRelation r2 = new AlloyRelation(r.getName(), r.isPrivate, r.isMeta, r.isVar, newObj); Set answer = rel2tuples.get(r2); if (answer == null) rel2tuples.put(r2, answer = new LinkedHashSet()); @@ -178,7 +180,7 @@ public static AlloyInstance project(AlloyInstance oldInstance, AlloyProjection p Set answer = atom2sets.get(a); if (answer == null) atom2sets.put(a, answer = new LinkedHashSet()); - answer.add(new AlloySet(r.getName(), r.isPrivate, r.isMeta, newObj.get(0))); + answer.add(new AlloySet(r.getName(), r.isPrivate, r.isMeta, r.isVar, newObj.get(0))); } } } diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGUI.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGUI.java index 742dcd14b..958bf56cd 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGUI.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGUI.java @@ -18,27 +18,42 @@ import static edu.mit.csail.sdg.alloy4.OurUtil.menu; import static edu.mit.csail.sdg.alloy4.OurUtil.menuItem; +import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Path2D; import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.StringJoiner; import java.util.prefs.Preferences; import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComponent; @@ -69,11 +84,29 @@ import edu.mit.csail.sdg.alloy4.Util; import edu.mit.csail.sdg.alloy4.Version; import edu.mit.csail.sdg.alloy4graph.GraphViewer; +import edu.mit.csail.sdg.ast.Expr; +import edu.mit.csail.sdg.ast.ExprConstant; +import edu.mit.csail.sdg.ast.ExprVar; +import edu.mit.csail.sdg.ast.Sig; +import edu.mit.csail.sdg.translator.A4Solution; +import edu.mit.csail.sdg.translator.A4Tuple; +import edu.mit.csail.sdg.translator.A4TupleSet; /** * GUI main window for the visualizer. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] support for visualization of traces; multiple states + * presented side-by-side (each with own viz state); (navigable) + * overview of the trace shape; evaluator also acts on focused state; + * if the Alloy model is static, should revert to classic viz; all + * theme management applies to all graphs; support for exporting an + * instance as an Alloy formula; added support for new operations over + * traces, next config, next path, next init, fork at given state + * (toolbar/menu buttons); communication with the enumerator which now + * expects an additional parameter with selected operation to be + * passed too the A4Solution */ public final class VizGUI implements ComponentListener { @@ -111,7 +144,10 @@ public final class VizGUI implements ComponentListener { private final JButton projectionButton, openSettingsButton, closeSettingsButton, magicLayout, loadSettingsButton, saveSettingsButton, saveAsSettingsButton, resetSettingsButton, updateSettingsButton, openEvaluatorButton, closeEvaluatorButton, enumerateButton, vizButton, treeButton, - txtButton, tableButton/* , dotButton, xmlButton */; + txtButton, tableButton, leftNavButton, rightNavButton, cnfgButton, forkButton, initButton, pathButton/* + * , dotButton, + * xmlButton + */; /** * This list must contain all the display mode buttons (that is, vizButton, @@ -128,6 +164,21 @@ public final class VizGUI implements ComponentListener { /** The "show next" menu item. */ private final JMenuItem enumerateMenu; + /** The "fresh config" menu item. */ + private final JMenuItem cnfgMenu; + + /** The "fresh path" menu item. */ + private final JMenuItem pathMenu; + + /** The "fork next" menu item. */ + private final JMenuItem forkMenu; + + /** The "fork init" menu item. */ + private final JMenuItem initMenu; + + /** The trace navigation menu items. */ + private final JMenuItem rightNavMenu, leftNavMenu; + /** Current font size. */ private int fontSize = 12; @@ -138,18 +189,24 @@ public final class VizGUI implements ComponentListener { private int settingsOpen = 0; /** - * The current instance and visualization settings; null if none is loaded. + * Whether the previous iteration operation was a next init/fork (which disables + * next path until a next config). */ - private VizState myState = null; + private boolean seg_iteration = false; + + /** + * The current states and visualization settings; null if none is loaded. + */ + private List myStates = new ArrayList(); /** * Returns the current visualization settings (and you can call - * getOriginalInstance() on it to get the current instance). If you make changes - * to the state, you should call doApply() on the VizGUI object to refresh the - * screen. + * getOriginalInstance() on it to get the current state of the instance). If you + * make changes to the state, you should call doApply() on the VizGUI object to + * refresh the screen. */ - public VizState getVizState() { - return myState; + public List getVizState() { + return myStates; } /** @@ -163,10 +220,17 @@ public VizState getVizState() { private OurConsole myEvaluatorPanel = null; /** - * The graphical panel to the right; null if it is not yet loaded. + * The graphical panel at the lower-side of the the right panel; null if it is + * not yet loaded. */ private VizGraphPanel myGraphPanel = null; + /** + * The panel to the right, containing the graph and the temporal navigation + * panel; null if it is not yet loaded. + */ + private JPanel mySplitTemporal = null; + /** * The splitpane between the customization panel and the graph panel. */ @@ -207,6 +271,11 @@ public JFrame getFrame() { */ private final Computer enumerator; + /** + * Number of trace states to depict in graph mode. + */ + private final int statepanes; + // ==============================================================================================// /** @@ -488,7 +557,7 @@ public void run() { * will initially hide the window. */ public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu) { - this(standalone, xmlFileName, windowmenu, null, null); + this(standalone, xmlFileName, windowmenu, null, null, 1); } /** @@ -504,12 +573,13 @@ public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu) { * @param enumerator - if it's not null, it provides solution enumeration * ability * @param evaluator - if it's not null, it provides solution evaluation ability + * @param panes - the number of states that will be shown *

* Note: if standalone==false and xmlFileName.length()==0, then we * will initially hide the window. */ - public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu, Computer enumerator, Computer evaluator) { - this(standalone, xmlFileName, windowmenu, enumerator, evaluator, true); + public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu, Computer enumerator, Computer evaluator, int panes) { + this(standalone, xmlFileName, windowmenu, enumerator, evaluator, true, panes); } /** @@ -527,12 +597,13 @@ public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu, Computer * @param evaluator - if it's not null, it provides solution evaluation ability * @param makeWindow - if false, then we will only construct the JSplitPane, * without making the window + * @param panes - the number of states that will be shown side-by-side *

* Note: if standalone==false and xmlFileName.length()==0 and * makeWindow==true, then we will initially hide the window. */ - public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu, Computer enumerator, Computer evaluator, boolean makeWindow) { - + public VizGUI(boolean standalone, String xmlFileName, JMenu windowmenu, Computer enumerator, Computer evaluator, boolean makeWindow, int panes) { + this.statepanes = panes == 0 ? 1 : panes; this.enumerator = enumerator; this.standalone = standalone; this.evaluator = evaluator; @@ -570,6 +641,7 @@ else if (height < 100) JMenu exportMenu = menu(null, "&Export To", null); menuItem(exportMenu, "Dot...", 'D', 'D', doExportDot()); menuItem(exportMenu, "XML...", 'X', 'X', doExportXml()); + menuItem(exportMenu, "Predicate...", 'P', 'P', doExportPred()); fileMenu.add(exportMenu); menuItem(fileMenu, "Close", 'W', 'W', doClose()); if (standalone) @@ -577,7 +649,15 @@ else if (height < 100) else menuItem(fileMenu, "Close All", 'A', doCloseAll()); JMenu instanceMenu = menu(mb, "&Instance", null); - enumerateMenu = menuItem(instanceMenu, "Show Next Solution", 'N', 'N', doNext()); + enumerateMenu = menuItem(instanceMenu, "Show New Solution", 'N', 'N', doNext()); + // [electrum] new iteration operation buttons + cnfgMenu = menuItem(instanceMenu, "Show New Configuration", 'C', 'C', doConfig()); + pathMenu = menuItem(instanceMenu, "Show New Path", 'P', 'P', doPath()); + initMenu = menuItem(instanceMenu, "Show New Initial State", 'I', 'I', doInit()); + forkMenu = menuItem(instanceMenu, "Show New Fork", 'F', 'F', doFork()); + // [electrum] trace navigation buttons + leftNavMenu = menuItem(instanceMenu, "Show Previous State", KeyEvent.VK_LEFT, KeyEvent.VK_LEFT, doNavLeft()); + rightNavMenu = menuItem(instanceMenu, "Show Next State", KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT, doNavRight()); thememenu = menu(mb, "&Theme", doRefreshTheme()); if (standalone || windowmenu == null) windowmenu = menu(mb, "&Window", doRefreshWindow()); @@ -628,7 +708,15 @@ public void actionPerformed(ActionEvent e) { toolbar.add(magicLayout = OurUtil.button("Magic Layout", "Automatic theme customization (will reset current theme)", "images/24_settings_apply2.gif", doMagicLayout())); toolbar.add(openEvaluatorButton = OurUtil.button("Evaluator", "Open the evaluator", "images/24_settings.gif", doOpenEvalPanel())); toolbar.add(closeEvaluatorButton = OurUtil.button("Close Evaluator", "Close the evaluator", "images/24_settings_close2.gif", doCloseEvalPanel())); - toolbar.add(enumerateButton = OurUtil.button("Next", "Show the next solution", "images/24_history.gif", doNext())); + toolbar.add(enumerateButton = OurUtil.button("New", "Show a new solution", "images/24_history.gif", doNext())); + // [electrum] new iteration operation buttons + toolbar.add(cnfgButton = OurUtil.button("New Config", "Show a new configuration", "images/24_history.gif", doConfig())); + toolbar.add(pathButton = OurUtil.button("New Path", "Show a new path", "images/24_history.gif", doPath())); + toolbar.add(initButton = OurUtil.button("New Init", "Show a new initial state", "images/24_history.gif", doInit())); + toolbar.add(forkButton = OurUtil.button("New Fork", "Show a new fork", "images/24_history.gif", doFork())); + // [electrum] trace navigation buttons + toolbar.add(leftNavButton = OurUtil.button(new String(Character.toChars(0x2190)), "Show the previous state", "images/24_history.gif", doNavLeft())); + toolbar.add(rightNavButton = OurUtil.button(new String(Character.toChars(0x2192)), "Show the next state", "images/24_history.gif", doNavRight())); toolbar.add(projectionButton); toolbar.add(loadSettingsButton = OurUtil.button("Load", "Load the theme customization from a theme file", "images/24_open.gif", doLoadTheme())); toolbar.add(saveSettingsButton = OurUtil.button("Save", "Save the current theme customization", "images/24_save.gif", doSaveTheme())); @@ -713,17 +801,18 @@ public void componentHidden(ComponentEvent e) { } /** - * Helper method that repopulates the Porjection popup menu. + * Helper method that repopulates the Projection popup menu. */ private void repopulateProjectionPopup() { int num = 0; String label = "Projection: none"; - if (myState == null) { + if (myStates.isEmpty()) { projectionButton.setEnabled(false); return; } projectionButton.setEnabled(true); projectionPopup.removeAll(); + VizState myState = myStates.get(statepanes - 1); final Set projected = myState.getProjectedTypes(); for (final AlloyType t : myState.getOriginalModel().getTypes()) if (myState.canProject(t)) { @@ -733,10 +822,12 @@ private void repopulateProjectionPopup() { @Override public void actionPerformed(ActionEvent e) { - if (on) - myState.deproject(t); - else - myState.project(t); + // [electrum] apply projection to all states + for (VizState myState : myStates) + if (on) + myState.deproject(t); + else + myState.project(t); updateDisplay(); } }); @@ -755,7 +846,7 @@ public void actionPerformed(ActionEvent e) { * latest settings. */ private void updateDisplay() { - if (myState == null) + if (myStates.isEmpty()) return; // First, update the toolbar currentMode.set(); @@ -776,7 +867,11 @@ private void updateDisplay() { default : vizButton.setEnabled(false); } - final boolean isMeta = myState.getOriginalInstance().isMetamodel; + // [electrum] this info is the same in all states + final AlloyInstance oInst = myStates.get(statepanes - 1).getOriginalInstance(); + final boolean isMeta = oInst.isMetamodel; + final boolean isTrace = oInst.originalA4.getMaxTrace() >= 0; + final boolean hasConfigs = oInst.originalA4.hasConfigs(); vizButton.setVisible(frame != null); treeButton.setVisible(frame != null); txtButton.setVisible(frame != null); @@ -794,15 +889,40 @@ private void updateDisplay() { openEvaluatorButton.setVisible(!isMeta && settingsOpen == 0 && evaluator != null); closeEvaluatorButton.setVisible(!isMeta && settingsOpen == 2 && evaluator != null); enumerateMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null); - enumerateButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null); + // [electrum] hide buttons if static; disable previous at first state + enumerateMenu.setVisible(!isTrace); + enumerateButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && !isTrace); + initMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null); + initMenu.setVisible(isTrace); + initButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); + // [electrum] after fork cannot iterate path (would not guarantee non-isomorphic solutions) + pathMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null && !seg_iteration); + pathMenu.setVisible(isTrace); + pathButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); + pathButton.setEnabled(!seg_iteration); + // [electrum] if no static relations, do not allow next config (would always return the same solution) + cnfgMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null && hasConfigs); + cnfgMenu.setVisible(isTrace); + cnfgButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); + cnfgButton.setEnabled(hasConfigs); + forkMenu.setEnabled(!isMeta && settingsOpen == 0 && enumerator != null); + forkMenu.setVisible(isTrace); + forkButton.setVisible(!isMeta && settingsOpen == 0 && enumerator != null && isTrace); + leftNavButton.setVisible(!isMeta && isTrace); + leftNavButton.setEnabled(current > 0); + leftNavMenu.setEnabled(!isMeta && current > 0); + leftNavButton.setText(new String(current > 0 ? Character.toChars(0x2190) : Character.toChars(0x21e4))); + rightNavButton.setVisible(!isMeta && isTrace); + rightNavMenu.setEnabled(!isMeta); toolbar.setVisible(true); // Now, generate the graph or tree or textarea that we want to display // on the right if (frame != null) frame.setTitle(makeVizTitle()); + // [electrum] all visualizations focus on current state switch (currentMode) { case Tree : { - final VizTree t = new VizTree(myState.getOriginalInstance().originalA4, makeVizTitle(), fontSize); + final VizTree t = new VizTree(myStates.get(statepanes - 1).getOriginalInstance().originalA4, makeVizTitle(), fontSize, current); final JScrollPane scroll = OurUtil.scrollpane(t, Color.BLACK, Color.WHITE, new OurBorder(true, false, true, false)); scroll.addFocusListener(new FocusListener() { @@ -819,12 +939,12 @@ public final void focusLost(FocusEvent e) { break; } case TEXT : { - String textualOutput = myState.getOriginalInstance().originalA4.toString(); + String textualOutput = myStates.get(statepanes - 1).getOriginalInstance().originalA4.toString(current); content = getTextComponent(textualOutput); break; } case TABLE : { - String textualOutput = myState.getOriginalInstance().originalA4.format(); + String textualOutput = myStates.get(statepanes - 1).getOriginalInstance().originalA4.format(current); content = getTextComponent(textualOutput); break; } @@ -833,15 +953,60 @@ public final void focusLost(FocusEvent e) { // break; // } default : { - if (myGraphPanel == null) { - myGraphPanel = new VizGraphPanel(frame, myState, false); + List numPanes = isTrace && !isMeta ? myStates : myStates.subList(statepanes - 1, statepanes); + if (myGraphPanel == null || numPanes.size() != myGraphPanel.numPanels()) { + if (isTrace && !isMeta) // [electrum] test whether trace + myGraphPanel = new VizGraphPanel(frame, myStates, false); + else + myGraphPanel = new VizGraphPanel(frame, myStates.subList(statepanes - 1, statepanes), false); } else { + if (isTrace && !isMeta) { + for (int i = 0; i < statepanes; i++) { + File f = new File(getXMLfilename()); + try { + if (!f.exists()) + throw new IOException("File " + getXMLfilename() + " does not exist."); + + if (current + i < 0) { + getVizState().set(i, null); + } else { + AlloyInstance myInstance = StaticInstanceReader.parseInstance(f, current + i); + if (getVizState().get(i) != null) + getVizState().get(i).loadInstance(myInstance); + else { + getVizState().set(i, new VizState(getVizState().get(statepanes - 1))); // [electrum] get the previous state (including theme) + getVizState().get(i).loadInstance(myInstance); + } + } + } catch (Throwable e) { + OurDialog.alert(frame, "Cannot read or parse Alloy instance: " + xmlFileName + "\n\nError: " + e.getMessage()); + doCloseAll(); + return; + } + } + } myGraphPanel.seeDot(frame, false); myGraphPanel.remakeAll(frame); } - } content = myGraphPanel; + } + } + + // [electrum] update the trace overview + if (isTrace && !isMeta) { + JComponent aux = content; + + JPanel tmpNavScrollPanel = new JPanel(); + tmpNavScrollPanel.setLayout(new BoxLayout(tmpNavScrollPanel, BoxLayout.PAGE_AXIS)); + tmpNavScrollPanel.add(traceGraph()); + final Box instanceTopBox = Box.createVerticalBox(); + instanceTopBox.add(tmpNavScrollPanel); + content = new JPanel(new BorderLayout()); + content.add(instanceTopBox, BorderLayout.NORTH); + content.add(aux, BorderLayout.CENTER); + content.setVisible(true); } + // Now that we've re-constructed "content", let's set its font size if (currentMode != VisualizerMode.Tree) { content.setFont(OurUtil.getVizFont().deriveFont((float) fontSize)); @@ -863,15 +1028,17 @@ public final void focusLost(FocusEvent e) { JComponent left = null; if (settingsOpen == 1) { if (myCustomPanel == null) - myCustomPanel = new VizCustomizationPanel(splitpane, myState); + myCustomPanel = new VizCustomizationPanel(splitpane, myStates.get(statepanes - 1)); else myCustomPanel.remakeAll(); left = myCustomPanel; } else if (settingsOpen > 1) { if (myEvaluatorPanel == null) - myEvaluatorPanel = new OurConsole(evaluator, true, "The ", true, "Alloy Evaluator ", false, "allows you to type\nin Alloy expressions and see their values.\nFor example, ", true, "univ", false, " shows the list of all atoms.\n(You can press UP and DOWN to recall old inputs).\n"); + myEvaluatorPanel = new OurConsole(evaluator, true, "The ", true, "Alloy Evaluator ", false, "allows you to type\nin Alloy expressions and see their values\nat the currently focused state (left-hand side).\nFor example, ", true, "univ", false, " shows the list of all\natoms on the left-hand state.\n(You can press UP and DOWN to recall old inputs).\n"); try { evaluator.compute(new File(xmlFileName)); + // [electrum] evaluator acts on current state + myEvaluatorPanel.setCurrentState(current); } catch (Exception ex) { } // exception should not happen left = myEvaluatorPanel; @@ -920,8 +1087,9 @@ private JButton makeSolutionButton(String label, String toolTip, String image, A * being displayed. */ private String makeVizTitle() { - String filename = (myState != null ? myState.getOriginalInstance().filename : ""); - String commandname = (myState != null ? myState.getOriginalInstance().commandname : ""); + // [electrum] this info is the same in all states + String filename = (!myStates.isEmpty() ? myStates.get(statepanes - 1).getOriginalInstance().filename : ""); + String commandname = (!myStates.isEmpty() ? myStates.get(statepanes - 1).getOriginalInstance().commandname : ""); int i = filename.lastIndexOf('/'); if (i >= 0) filename = filename.substring(i + 1); @@ -1002,29 +1170,46 @@ public GraphViewer getViewer() { /** Load the XML instance. */ public void loadXML(final String fileName, boolean forcefully) { + loadXML(fileName, forcefully, current); + } + + /** Load the XML instance. */ + public void loadXML(final String fileName, boolean forcefully, int state) { + current = state; final String xmlFileName = Util.canon(fileName); File f = new File(xmlFileName); + if (!forcefully) + seg_iteration = false; if (forcefully || !xmlFileName.equals(this.xmlFileName)) { - AlloyInstance myInstance; - try { - if (!f.exists()) - throw new IOException("File " + xmlFileName + " does not exist."); - myInstance = StaticInstanceReader.parseInstance(f); - } catch (Throwable e) { - xmlLoaded.remove(fileName); - xmlLoaded.remove(xmlFileName); - OurDialog.alert(frame, "Cannot read or parse Alloy instance: " + xmlFileName + "\n\nError: " + e.getMessage()); - if (xmlLoaded.size() > 0) { - loadXML(xmlLoaded.get(xmlLoaded.size() - 1), false); + // [electrum] update all viz states + for (int i = 0; i < statepanes; i++) { + try { + if (!f.exists()) + throw new IOException("File " + xmlFileName + " does not exist."); + if (i >= myStates.size()) { + AlloyInstance myInstance = StaticInstanceReader.parseInstance(f, state + i); + myStates.add(new VizState(myInstance)); + } else { + VizState vstate = myStates.get(i); + AlloyInstance myInstance = StaticInstanceReader.parseInstance(f, state + i); + if (vstate == null) + vstate = new VizState(myInstance); + else + vstate.loadInstance(myInstance); + myStates.set(i, vstate); + } + } catch (Throwable e) { + xmlLoaded.remove(fileName); + xmlLoaded.remove(xmlFileName); + OurDialog.alert(frame, "Cannot read or parse Alloy instance: " + xmlFileName + "\n\nError: " + e.getMessage()); + if (xmlLoaded.size() > 0) { + loadXML(xmlLoaded.get(xmlLoaded.size() - 1), false, state + i); + return; + } + doCloseAll(); return; } - doCloseAll(); - return; } - if (myState == null) - myState = new VizState(myInstance); - else - myState.loadInstance(myInstance); repopulateProjectionPopup(); xml2title.put(xmlFileName, makeVizTitle()); this.xmlFileName = xmlFileName; @@ -1047,11 +1232,12 @@ public void loadXML(final String fileName, boolean forcefully) { /** This method loads a specific theme file. */ public boolean loadThemeFile(String filename) { - if (myState == null) + if (myStates.isEmpty()) return false; // Can only load if there is a VizState loaded filename = Util.canon(filename); try { - myState.loadPaletteXML(filename); + for (VizState myState : myStates) // [electrum] applly theme to all states + myState.loadPaletteXML(filename); } catch (IOException ex) { OurDialog.alert(frame, "Error: " + ex.getMessage()); return false; @@ -1072,7 +1258,7 @@ public boolean loadThemeFile(String filename) { * user); returns true if it succeeded. */ public boolean saveThemeFile(String filename) { - if (myState == null) + if (myStates.isEmpty()) return false; // Can only save if there is a VizState loaded if (filename == null) { File file = OurDialog.askFile(frame, false, null, ".thm", ".thm theme files"); @@ -1086,7 +1272,7 @@ public boolean saveThemeFile(String filename) { } filename = Util.canon(filename); try { - myState.savePaletteXML(filename); + myStates.get(statepanes - 1).savePaletteXML(filename); // [electrum] same theme in all states filename = Util.canon(filename); // Since the canon name may have // changed addThemeHistory(filename); @@ -1122,7 +1308,7 @@ private Runner doLoad() { if (file == null) return null; Util.setCurrentDirectory(file.getParentFile()); - loadXML(file.getPath(), true); + loadXML(file.getPath(), true, 0); return null; } @@ -1201,14 +1387,17 @@ private Runner doLoadTheme() { String defaultTheme = System.getProperty("alloy.theme0"); if (defaultTheme == null) defaultTheme = ""; - if (myState == null) + if (myStates.isEmpty()) return null; // Can only load if there is a VizState loaded - if (myState.changedSinceLastSave()) { - char opt = OurDialog.askSaveDiscardCancel(frame, "The current theme"); - if (opt == 'c') - return null; - if (opt == 's' && !saveThemeFile(thmFileName.length() == 0 ? null : thmFileName)) - return null; + // [electrum] apply theme to all states + for (VizState myState : myStates) { + if (myState.changedSinceLastSave()) { + char opt = OurDialog.askSaveDiscardCancel(frame, "The current theme"); + if (opt == 'c') + return null; + if (opt == 's' && !saveThemeFile(thmFileName.length() == 0 ? null : thmFileName)) + return null; + } } File file = OurDialog.askFile(frame, true, null, ".thm", ".thm theme files"); if (file != null) { @@ -1228,14 +1417,17 @@ private Runner doLoadSampleTheme() { String defaultTheme = System.getProperty("alloy.theme0"); if (defaultTheme == null) defaultTheme = ""; - if (myState == null) + if (myStates.isEmpty()) return null; // Can only load if there is a VizState loaded - if (myState.changedSinceLastSave()) { - char opt = OurDialog.askSaveDiscardCancel(frame, "The current theme"); - if (opt == 'c') - return null; - if (opt == 's' && !saveThemeFile(thmFileName.length() == 0 ? null : thmFileName)) - return null; + // [electrum] apply theme to all states + for (VizState myState : myStates) { + if (myState.changedSinceLastSave()) { + char opt = OurDialog.askSaveDiscardCancel(frame, "The current theme"); + if (opt == 'c') + return null; + if (opt == 's' && !saveThemeFile(thmFileName.length() == 0 ? null : thmFileName)) + return null; + } } File file = OurDialog.askFile(frame, true, defaultTheme, ".thm", ".thm theme files"); if (file != null) @@ -1305,15 +1497,135 @@ private Runner doExportXml() { return null; } + /** + * Export the current instance as an Alloy formula that exactly represents it. + */ + // [electrum] ad hoc implementation since Alloy lacks a proper pretty printer + // also, conjunctions would be printed as lists, which can't be parsed back + private Runner doExportPred() { + if (wrap) + return wrapMe(); + if (myStates.isEmpty()) + return null; + + Map reifs = new HashMap(); + A4Solution inst = myStates.get(myStates.size() - 1).getOriginalInstance().originalA4; + + // calculate the values of the static relations + StringJoiner config = new StringJoiner(" and "); + for (Sig s : inst.getAllReachableSigs()) { + if (s.isPrivate != null || s.isVariable != null || s.equals(Sig.UNIV) || s.equals(Sig.NONE)) + continue; + A4TupleSet ts = inst.eval(s); + Expr tupleset = null; + for (A4Tuple t : ts) { + Expr tuple = null; + for (int ai = 0; ai < t.arity(); ai++) { + Expr atom; + if (t.atom(ai).matches("-?\\d+")) { + atom = ExprConstant.makeNUMBER(Integer.valueOf(t.atom(ai))); + } else { + atom = reifs.computeIfAbsent("_" + t.atom(ai).replace("$", "").replace("/", "_"), k -> ExprVar.make(null, k)); + } + tuple = tuple == null ? atom : tuple.product(tuple); + } + tupleset = tupleset == null ? tuple : tupleset.plus(tuple); + } + if (tupleset == null) { + tupleset = ExprConstant.EMPTYNESS; + for (int ai = 0; ai < ts.arity() - 1; ai++) + tupleset = tupleset.product(ExprConstant.EMPTYNESS); + } + config.add(s.equal(tupleset).toString()); + } + + // calculate the values of the variable relations + List states = new ArrayList(); + for (int i = 0; i < inst.getTraceLength(); i++) { + StringJoiner state = new StringJoiner(" and "); + for (Sig s : inst.getAllReachableSigs()) { + if (s.isPrivate != null || (s.isVariable == null && !s.equals(Sig.UNIV))) + continue; + A4TupleSet ts = inst.eval(s, i); + Expr tupleset = null; + for (A4Tuple t : ts) { + Expr tuple = null; + for (int ai = 0; ai < t.arity(); ai++) { + Expr atom; + if (t.atom(ai).matches("-?\\d+")) { + atom = ExprConstant.makeNUMBER(Integer.valueOf(t.atom(ai))); + } else { + atom = reifs.computeIfAbsent("_" + t.atom(ai).replace("$", "").replace("/", "_"), k -> ExprVar.make(null, k)); + } + tuple = tuple == null ? atom : tuple.product(tuple); + } + tupleset = tupleset == null ? tuple : tupleset.plus(tuple); + } + if (tupleset == null) { + tupleset = ExprConstant.EMPTYNESS; + for (int ai = 0; ai < ts.arity() - 1; ai++) + tupleset = tupleset.product(ExprConstant.EMPTYNESS); + } + state.add(s.equal(tupleset).toString()); + } + states.add(state.toString()); + } + StringBuilder sb = new StringBuilder(); + if (!reifs.isEmpty()) { + // quantify over all atoms of all univs (univ changes over time) + sb.append("some disj "); + StringJoiner sj = new StringJoiner(","); + for (ExprVar v : reifs.values()) + sj.add(v.toString()); + sb.append(sj.toString()); + sb.append(" : "); + Expr unvs = Sig.UNIV; + for (int i = 0; i < inst.getTraceLength() - 1; i++) + unvs = Sig.UNIV.plus(unvs.prime()); + sb.append(unvs.toString()); + } + sb.append(" {\n "); + // print config + sb.append(config.toString()); + sb.append("\n\n "); + // print prefix + StringJoiner statesj = new StringJoiner(";\n "); + for (String s : states) + statesj.add(s); + sb.append(statesj.toString()); + sb.append("\n\n "); + // print looping suffix + if (inst.getMaxTrace() >= 0) { + for (int i = 0; i < inst.getLoopState(); i++) + sb.append("after "); + sb.append(" {\n"); + for (int i = inst.getLoopState(); i < inst.getTraceLength(); i++) { + StringBuilder sa = new StringBuilder(""); + for (int j = inst.getLoopState(); j < inst.getTraceLength(); j++) + sa.append("after "); + sa.append("("); + sa.append(states.get(i)); + sa.append(")"); + sb.append(" (" + states.get(i) + ") implies " + sa.toString() + "\n"); + } + sb.append(" }\n"); + } + sb.append("}\n"); + + OurDialog.showtext("Text Viewer", sb.toString()); + return null; + } + /** This method resets the current theme. */ private Runner doResetTheme() { if (wrap) return wrapMe(); - if (myState == null) + if (myStates.isEmpty()) return null; if (!OurDialog.yesno(frame, "Are you sure you wish to clear all your customizations?", "Yes, clear them", "No, keep them")) return null; - myState.resetTheme(); + for (VizState myState : myStates) + myState.resetTheme(); repopulateProjectionPopup(); if (myCustomPanel != null) myCustomPanel.remakeAll(); @@ -1330,15 +1642,17 @@ private Runner doResetTheme() { private Runner doMagicLayout() { if (wrap) return wrapMe(); - if (myState == null) + if (myStates.isEmpty()) return null; if (!OurDialog.yesno(frame, "This will clear your original customizations. Are you sure?", "Yes, clear them", "No, keep them")) return null; - myState.resetTheme(); - try { - MagicLayout.magic(myState); - MagicColor.magic(myState); - } catch (Throwable ex) { + for (VizState myState : myStates) { + myState.resetTheme(); + try { + MagicLayout.magic(myState); + MagicColor.magic(myState); + } catch (Throwable ex) { + } } repopulateProjectionPopup(); if (myCustomPanel != null) @@ -1397,6 +1711,36 @@ private Runner doZoom() { return wrapMe(); } + /** + * Navigates the trace being visualized to the left, unless already in the first + * state. + */ + private Runner doNavLeft() { + if (wrap) + return wrapMe(); + if (current > 0) { + current--; + updateDisplay(); + } + return null; + } + + /** + * Navigates the trace being visualized to the right, unrolling the loop if + * needed. + */ + private Runner doNavRight() { + if (wrap) + return wrapMe(); + int lst = getVizState().get(statepanes - 1).getOriginalInstance().originalA4.getTraceLength(); + int lop = getVizState().get(statepanes - 1).getOriginalInstance().originalA4.getLoopState(); + int lmx = current + 1 + statepanes > lst ? current + 1 + statepanes : lst; + int lox = lmx - (lst - lop); + current = normalize(current + 1, lmx, lox); + updateDisplay(); + return null; + } + /** * This method attempts to derive the next satisfying instance. */ @@ -1411,7 +1755,113 @@ private Runner doNext() { OurDialog.alert(frame, "Cannot display the next solution since the analysis engine is not loaded with the visualizer."); } else { try { - enumerator.compute(xmlFileName); + enumerator.compute(new String[] { + xmlFileName, -3 + "" + }); + } catch (Throwable ex) { + OurDialog.alert(frame, ex.getMessage()); + } + } + return null; + } + + /** + * This method attempts to derive the next satisfying instance with a distinct + * configuration. + */ + private Runner doConfig() { + if (wrap) + return wrapMe(); + if (settingsOpen != 0) + return null; + if (xmlFileName.length() == 0) { + OurDialog.alert(frame, "Cannot display the next solution since no instance is currently loaded."); + } else if (enumerator == null) { + OurDialog.alert(frame, "Cannot display the next solution since the analysis engine is not loaded with the visualizer."); + } else { + try { + seg_iteration = false; + enumerator.compute(new String[] { + xmlFileName, -1 + "" + }); + } catch (Throwable ex) { + OurDialog.alert(frame, ex.getMessage()); + } + } + return null; + } + + /** + * This method attempts to derive the next satisfying instance with a distinct + * path (but same configuration). + */ + private Runner doPath() { + if (wrap) + return wrapMe(); + if (settingsOpen != 0) + return null; + if (xmlFileName.length() == 0) { + OurDialog.alert(frame, "Cannot display the next solution since no instance is currently loaded."); + } else if (enumerator == null) { + OurDialog.alert(frame, "Cannot display the next solution since the analysis engine is not loaded with the visualizer."); + } else { + try { + seg_iteration = false; + enumerator.compute(new String[] { + xmlFileName, -2 + "" + }); + } catch (Throwable ex) { + OurDialog.alert(frame, ex.getMessage()); + } + } + return null; + } + + /** + * This method attempts to derive the next satisfying instance with a distinct + * focused state (but same configuration and prefix). + */ + private Runner doFork() { + if (wrap) + return wrapMe(); + if (settingsOpen != 0) + return null; + if (xmlFileName.length() == 0) { + OurDialog.alert(frame, "Cannot display the next solution since no instance is currently loaded."); + } else if (enumerator == null) { + OurDialog.alert(frame, "Cannot display the next solution since the analysis engine is not loaded with the visualizer."); + } else { + try { + seg_iteration = true; + enumerator.compute(new String[] { + xmlFileName, current + 1 + "" + }); + } catch (Throwable ex) { + OurDialog.alert(frame, ex.getMessage()); + } + } + return null; + } + + /** + * This method attempts to derive the next satisfying instance with a distinct + * initial state (but same configuration). + */ + private Runner doInit() { + if (wrap) + return wrapMe(); + if (settingsOpen != 0) + return null; + if (xmlFileName.length() == 0) { + OurDialog.alert(frame, "Cannot display the next solution since no instance is currently loaded."); + } else if (enumerator == null) { + OurDialog.alert(frame, "Cannot display the next solution since the analysis engine is not loaded with the visualizer."); + } else { + try { + seg_iteration = true; + enumerator.compute(new String[] { + xmlFileName, 0 + "" + }); } catch (Throwable ex) { OurDialog.alert(frame, ex.getMessage()); } @@ -1423,6 +1873,14 @@ private Runner doNext() { * This method updates the graph with the current theme customization. */ private Runner doApply() { + if (!myStates.isEmpty()) { + // [electrum] apply theme to all states + for (int i = 0; i < myStates.size() - 1; i++) { + VizState ss = myStates.get(statepanes - 1); + myStates.set(i, new VizState(ss)); + myStates.get(i).loadInstance(ss.getOriginalInstance()); + } + } if (!wrap) updateDisplay(); return wrapMe(); @@ -1536,4 +1994,131 @@ public Runner doShowTable() { // return wrapMe(); // } + /** + * The currently focused state (the one printed in the left-most graph panel). + */ + private int current = 0; + + /* + * Draws a graph depicting the shape of the trace being visualized. States are + * clickable for navigation. + */ + private JPanel traceGraph() { + + List states = new ArrayList(); + + JPanel trace = new JPanel() { + + int heighti = 50; + + @Override + public void paintComponent(Graphics g) { + states.clear(); + + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + int radius = 12; + int dist = 45; + int offsety = 2 + heighti / 2; + // center and apply offset according to current state + int offsetx = this.getWidth() / 2 + ((dist - 2 * radius) / 2) - (dist * (current + 1)); + int lst = getVizState().get(statepanes - 1).getOriginalInstance().originalA4.getTraceLength(); + int lop = getVizState().get(statepanes - 1).getOriginalInstance().originalA4.getLoopState(); + int lmx = current + statepanes > lst ? current + statepanes : lst; + int lox = lmx - (lst - lop); + Ellipse2D loop = null, last = null; + for (int i = 0; i < lmx; i++) { + g2.setStroke(new BasicStroke(2)); + Ellipse2D circl = new Ellipse2D.Double(i * dist + offsetx, offsety - radius, 2.0 * radius, 2.0 * radius); + if (i == lmx - 1) + last = circl; + if (i == lox) + loop = circl; + Color tmp = g2.getColor(); + int max = normalize(current + statepanes - 1, lmx, lox); + int min = normalize(current, lmx, lox); + if ((min <= max && i >= min && i <= max) || (min > max && (i >= min || (i <= max && i >= lox)))) { + g2.setColor(new Color(255, 255, 255)); + } else { + g2.setColor(new Color(120, 120, 120)); + } + g2.fill(circl); + g2.setColor(tmp); + g2.draw(circl); + FontMetrics mets = g2.getFontMetrics(); + String lbl = normalize(i, lst, lop) + ""; + g2.drawString(lbl, i * dist + radius + offsetx - (mets.stringWidth(lbl) / 2), offsety + (mets.getAscent() / 2)); + states.add(circl); + g2.setStroke(new BasicStroke(1)); + g2.setColor(new Color(0, 0, 0)); + } + + Polygon arrowHead = new Polygon(); + arrowHead.addPoint(0, 4); + arrowHead.addPoint(-4, -4); + arrowHead.addPoint(4, -4); + + for (int i = 0; i < lmx - 1; i++) { + Path2D path = new Path2D.Double(); + path.moveTo(states.get(i).getMaxX(), states.get(i).getCenterY()); + path.lineTo(states.get(i + 1).getMinX(), states.get(i + 1).getCenterY()); + g2.draw(path); + AffineTransform tx = new AffineTransform(); + tx.setToIdentity(); + double angle = Math.atan2(0, 1); + tx.translate(states.get(i + 1).getMinX(), states.get(i + 1).getCenterY()); + tx.rotate((angle - Math.PI / 2d)); + g2.fill(tx.createTransformedShape(arrowHead)); + } + + Path2D path = new Path2D.Double(); + path.moveTo(states.get(states.size() - 1).getCenterX(), states.get(states.size() - 1).getMinY()); + path.curveTo(last.getCenterX() - 25, 0, loop.getCenterX() + 25, 0, loop.getCenterX(), loop.getMinY()); + g2.draw(path); + + AffineTransform tx = new AffineTransform(); + tx.setToIdentity(); + double angle = Math.atan2(loop.getMinY(), -dist / 2); + tx.translate(loop.getCenterX(), loop.getMinY()); + tx.rotate(angle - Math.PI / 2d); + g2.fill(tx.createTransformedShape(arrowHead)); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(Integer.MAX_VALUE, heighti); + } + + }; + trace.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + for (int i = 0; i < states.size(); i++) + if (e.getButton() == 1 && states.get(i).contains(e.getX(), e.getY())) { + current = i; + updateDisplay(); + break; + } + } + + }); + return trace; + } + + /** + * Given an arbitrary positive index, calculates the corresponding state the in + * trace prefix after loop unrollings. + * + * @param idx current index + * @param length trace prefix length + * @param loop backloop state + * @return the corresponding state in the prefix + */ + private int normalize(int idx, int length, int loop) { + int lln = length - loop; + return idx > loop ? (((idx - loop) % lln) + loop) : idx; + } + } diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGraphPanel.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGraphPanel.java index f65ae01f5..ded2b1f11 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGraphPanel.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizGraphPanel.java @@ -59,33 +59,38 @@ * GUI panel that houses the actual graph, as well as any projection comboboxes. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] apply default style for mutable elements; a graph panel + * now holds a list of graphs (and associated components), each with + * its own viz state; assumes that cannot project over mutable + * variables; */ public final class VizGraphPanel extends JPanel { /** This ensures the class can be serialized reliably. */ - private static final long serialVersionUID = 0; + private static final long serialVersionUID = 0; - /** This is the current customization settings. */ - private final VizState vizState; + /** This is the current customization settings of each graph panel. */ + private final List vizState; /** * Whether the user wants to see the DOT source code or not. */ - private boolean seeDot = false; + private boolean seeDot = false; /** - * The current GraphViewer (or null if we are not looking at a GraphViewer) + * The current GraphViewer (or null if we are not looking at a GraphViewer). */ - private GraphViewer viewer = null; + private List viewer = null; /** - * The scrollpane containing the upperhalf of the panel (showing the graph) + * The scrollpanes containing the upperhalf of the panel (showing the graphs). */ - private final JScrollPane diagramScrollPanel; + private final List diagramScrollPanels = new ArrayList(); - /** The upperhalf of the panel (showing the graph). */ - private final JPanel graphPanel; + /** The upperhalf of the panel (showing the graphs). */ + private final List graphPanels = new ArrayList(); /** * The lowerhalf of the panel (showing the comboboxes for choosing the projected @@ -101,12 +106,12 @@ public final class VizGraphPanel extends JPanel { /** * The current projection choice; null if no projection is in effect. */ - private AlloyProjection currentProjection = null; + private AlloyProjection currentProjection = null; /** * This is the list of TypePanel(s) we've already constructed. */ - private final Map type2panel = new TreeMap(); + private final Map type2panel = new TreeMap(); /** * Inner class that displays a combo box of possible projection atom choices. @@ -142,7 +147,7 @@ private boolean upToDate(AlloyType type, List atoms) { if (!this.atoms.equals(atoms)) return false; for (int i = 0; i < this.atoms.size(); i++) { - String n = this.atoms.get(i).getVizName(vizState, true); + String n = this.atoms.get(i).getVizName(vizState.get(0), true); if (!atomnames[i].equals(n)) return false; } @@ -167,7 +172,7 @@ private TypePanel(JFrame parent, AlloyType type, List atoms, AlloyAto setBorder(null); this.atomnames = new String[this.atoms.size()]; for (int i = 0; i < this.atoms.size(); i++) { - atomnames[i] = this.atoms.get(i).getVizName(vizState, true); + atomnames[i] = this.atoms.get(i).getVizName(vizState.get(0), true); if (this.atoms.get(i).equals(initialValue)) initialIndex = i; } @@ -248,14 +253,14 @@ public AlloyType getAlloyType() { } /** - * Create a splitpane showing the graph on top, as well as projection comboboxes - * on the bottom. + * Create a splitpane showing the graphs on top, as well as projection + * comboboxes on the bottom. * * @param vizState - the current visualization settings * @param seeDot - true if we want to see the DOT source code, false if we want * it rendered as a graph */ - public VizGraphPanel(JFrame parent, VizState vizState, boolean seeDot) { + public VizGraphPanel(JFrame parent, List vizState, boolean seeDot) { Border b = new EmptyBorder(0, 0, 0, 0); OurUtil.make(this, Color.BLACK, Color.WHITE, b); this.seeDot = seeDot; @@ -264,24 +269,53 @@ public VizGraphPanel(JFrame parent, VizState vizState, boolean seeDot) { setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); navPanel = new JPanel(); JScrollPane navscroll = OurUtil.scrollpane(navPanel); - graphPanel = OurUtil.make(new JPanel(), Color.BLACK, Color.WHITE, b); + + // [electrum] container for all (diagram scroll) graph panels + JPanel diagramsScrollPanels = new JPanel(); + diagramsScrollPanels.setLayout(new BoxLayout(diagramsScrollPanels, BoxLayout.LINE_AXIS)); + for (int i = 0; i < vizState.size(); i++) { + JScrollPane diagramScrollPanel = createGraphPanel(i); + diagramScrollPanels.add(diagramScrollPanel); + diagramsScrollPanels.add(diagramScrollPanel); + diagramScrollPanel.setPreferredSize(new Dimension(0, 0)); + } + + split = OurUtil.splitpane(JSplitPane.VERTICAL_SPLIT, diagramsScrollPanels, navscroll, 0); + split.setResizeWeight(1.0); + split.setDividerSize(0); + add(split); + remakeAll(parent); + } + + /** + * Creates a particular diagram scroll panel. + * + * @param i the i-th panel in the visualizer + * @return the i-th diagram graph panel + */ + // [electrum] refactored from VizGraphPanel constructor so that multiple can be created + private JScrollPane createGraphPanel(int i) { + Border b = new EmptyBorder(0, 0, 0, 0); + + JPanel graphPanel = OurUtil.make(new JPanel(), Color.BLACK, Color.WHITE, b); + graphPanels.add(graphPanel); graphPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent ev) { - // We let Ctrl+LeftClick bring up the popup menu, just like - // RightClick, + // We let Ctrl+LeftClick bring up the popup menu, just like RightClick, // since many Mac mouses do not have a right button. - if (viewer == null) + if (viewer.size() <= i) return; else if (ev.getButton() == MouseEvent.BUTTON3) { - } else if (ev.getButton() == MouseEvent.BUTTON1 && ev.isControlDown()) { - } else + } else if (ev.getButton() == MouseEvent.BUTTON1 && ev.isControlDown()) {} else return; - viewer.alloyPopup(graphPanel, ev.getX(), ev.getY()); + if (graphPanel.contains(ev.getX(), ev.getY())) // [electrum] distinguish clicked panel + viewer.get(i).alloyPopup(graphPanel, ev.getX(), ev.getY()); } }); - diagramScrollPanel = OurUtil.scrollpane(graphPanel, new OurBorder(true, true, true, false)); + + JScrollPane diagramScrollPanel = OurUtil.scrollpane(graphPanel, new OurBorder(true, true, true, false)); diagramScrollPanel.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { @Override @@ -300,19 +334,16 @@ public void adjustmentValueChanged(AdjustmentEvent e) { diagramScrollPanel.validate(); } }); - split = OurUtil.splitpane(JSplitPane.VERTICAL_SPLIT, diagramScrollPanel, navscroll, 0); - split.setResizeWeight(1.0); - split.setDividerSize(0); - add(split); - remakeAll(parent); + return diagramScrollPanel; } /** Regenerate the comboboxes and the graph. */ public void remakeAll(JFrame parent) { Map map = new LinkedHashMap(); navPanel.removeAll(); - for (AlloyType type : vizState.getProjectedTypes()) { - List atoms = vizState.getOriginalInstance().type2atoms(type); + // [electrum] this info is the same in all viz states + for (AlloyType type : vizState.get(vizState.size() - 1).getProjectedTypes()) { + List atoms = vizState.get(vizState.size() - 1).getOriginalInstance().type2atoms(type); TypePanel tp = type2panel.get(type); if (tp != null && tp.getAlloyAtom() != null && !atoms.contains(tp.getAlloyAtom())) tp = null; @@ -326,22 +357,30 @@ public void remakeAll(JFrame parent) { map.put(tp.getAlloyType(), tp.getAlloyAtom()); } currentProjection = new AlloyProjection(map); - JPanel graph = vizState.getGraph(parent, currentProjection); - if (seeDot && (graph instanceof GraphViewer)) { - viewer = null; - JTextArea txt = OurUtil.textarea(graph.toString(), 10, 10, false, true, getFont()); - diagramScrollPanel.setViewportView(txt); - } else { - if (graph instanceof GraphViewer) - viewer = (GraphViewer) graph; - else + List prevsv = viewer; + // [electrum] update all graph panels + viewer = new ArrayList<>(vizState.size()); + for (int i = 0; i < vizState.size(); i++) { + JPanel graph = vizState.get(i).getGraph(parent, currentProjection); + if (seeDot && (graph instanceof GraphViewer)) { viewer = null; - graphPanel.removeAll(); - graphPanel.add(graph); - diagramScrollPanel.setViewportView(graphPanel); - diagramScrollPanel.invalidate(); - diagramScrollPanel.repaint(); - diagramScrollPanel.validate(); + JTextArea txt = OurUtil.textarea(graph.toString(), 10, 10, false, true, getFont()); + diagramScrollPanels.get(i).setViewportView(txt); + } else { + if (graph instanceof GraphViewer) { + viewer.add((GraphViewer) graph); + if (prevsv != null && i <= prevsv.size()) + viewer.get(i).setScale(prevsv.get(i).getScale()); + } else + viewer = null; + graphPanels.get(i).removeAll(); + graphPanels.get(i).add(graph); + graphPanels.get(i).setBackground(Color.WHITE); + diagramScrollPanels.get(i).setViewportView(graphPanels.get(i)); + diagramScrollPanels.get(i).invalidate(); + diagramScrollPanels.get(i).repaint(); + diagramScrollPanels.get(i).validate(); + } } } @@ -349,8 +388,9 @@ public void remakeAll(JFrame parent) { @Override public void setFont(Font font) { super.setFont(font); - if (diagramScrollPanel != null) - diagramScrollPanel.getViewport().getView().setFont(font); + if (diagramScrollPanels != null) // [electrum] called before initialization + for (JScrollPane diagramScrollPanel : diagramScrollPanels) + diagramScrollPanel.getViewport().getView().setFont(font); } /** Changes whether we are seeing the DOT source or not. */ @@ -362,7 +402,8 @@ public void seeDot(JFrame parent, boolean yesOrNo) { } public String toDot(JFrame parent) { - return vizState.getGraph(parent, currentProjection).toString(); + // [electrum] only converts the first shown state + return vizState.get(0).getGraph(parent, currentProjection).toString(); } /** @@ -370,7 +411,7 @@ public String toDot(JFrame parent) { * the graph hasn't loaded yet) */ public GraphViewer alloyGetViewer() { - return viewer; + return viewer.get(0); } /** @@ -388,4 +429,13 @@ public void resetProjectionAtomCombos() { e.getValue().atomCombo.setSelectedIndex(0); } } + + /** + * The number of graph panels in the viz. + * + * @return the number of graph panels + */ + public int numPanels() { + return vizState.size(); + } } diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizState.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizState.java index 74c1273e0..61f98855f 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizState.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizState.java @@ -41,6 +41,8 @@ * customization. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] apply a default style to mutable elements (dashed) */ public final class VizState { @@ -85,6 +87,7 @@ public VizState(VizState old) { edgeStyle.putAll(old.edgeStyle); edgeVisible.putAll(old.edgeVisible); changedSinceLastSave = false; + applyDefaultVar(); } /** Clears the current theme. */ @@ -155,11 +158,29 @@ public void resetTheme() { edgeColor.put(in, DotColor.BLACK); weight.put(in, 100); layoutBack.put(in, true); + applyDefaultVar(); // [electrum] dashed style for variable elements // Done cache.clear(); changedSinceLastSave = false; } + /** + * Paints variable items as dashed if no other style has been set by the user. + * Must be run every time since new elements may have been introduced. + */ + void applyDefaultVar() { + // if parent also var or has style, inherit, otherwise paint dashed + for (AlloyType r : currentModel.getTypes()) + if (nodeStyle.get(r) == null && r.isVar && !(currentModel.getSuperType(r).isVar || nodeStyle.get(currentModel.getSuperType(r)) != null)) + nodeStyle.put(r, DotStyle.DASHED); + for (AlloyRelation r : currentModel.getRelations()) + if (edgeStyle.get(r) == null && r.isVar) + edgeStyle.put(r, DotStyle.DASHED); + for (AlloySet r : currentModel.getSets()) + if (nodeStyle.get(r) == null && r.isVar && !(r.getType().isVar || nodeStyle.get(r.getType()) != null)) + nodeStyle.put(r, DotStyle.DASHED); + } + /** * Load a new instance into this VizState object (the input argument is treated * as a new unprojected instance); if world!=null, it is the root of the AST @@ -323,7 +344,7 @@ public ConstSet getProjectedTypes() { * Returns true iff the type is not univ, and it is a toplevel type. */ public boolean canProject(final AlloyType type) { - return isTopLevel(type); + return isTopLevel(type) && !type.isVar; // [electrum] can't project over mutable variable } /** @@ -524,8 +545,7 @@ public final class MInt { private final LinkedHashMap map = new LinkedHashMap(); - private MInt() { - } + private MInt() {} private void clear() { map.clear(); @@ -556,8 +576,7 @@ public final class MString { private final LinkedHashMap map = new LinkedHashMap(); - private MString() { - } + private MString() {} private void clear() { map.clear(); diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizTree.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizTree.java index beeda5351..90bf17159 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizTree.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4viz/VizTree.java @@ -39,6 +39,8 @@ * GUI tree that displays an instance as a tree. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] adapted to focus on particular state */ public final class VizTree extends OurTree { @@ -91,14 +93,14 @@ public Object do_root() { if (parent instanceof A4Solution) { return toplevel; } else if (parent instanceof Sig || parent instanceof ExprVar) { - A4TupleSet ts = (A4TupleSet) (instance.eval((Expr) parent)); + A4TupleSet ts = (A4TupleSet) (instance.eval((Expr) parent, state)); for (A4Tuple t : ts) ans.add(t.atom(0)); } else if (parent instanceof String) { String atom = (String) parent; for (Sig s : instance.getAllReachableSigs()) for (Field f : s.getFields()) - for (A4Tuple t : instance.eval(f)) { + for (A4Tuple t : instance.eval(f, state)) { if (t.atom(0).equals(atom)) { ans.add(new Pair(atom, f)); break; @@ -106,7 +108,7 @@ public Object do_root() { } for (ExprVar f : instance.getAllSkolems()) if (f.type().arity() > 1) - for (A4Tuple t : (A4TupleSet) (instance.eval(f))) { + for (A4Tuple t : (A4TupleSet) (instance.eval(f, state))) { if (t.atom(0).equals(atom)) { ans.add(new Pair(atom, f)); break; @@ -116,7 +118,7 @@ public Object do_root() { Pair< ? , ? > p = (Pair< ? , ? >) parent; ExprHasName rel = (ExprHasName) (p.b); String atom = (String) (p.a); - for (A4Tuple tuple : (A4TupleSet) (instance.eval(rel))) + for (A4Tuple tuple : (A4TupleSet) (instance.eval(rel, state))) if (tuple.atom(0).equals(atom)) { if (tuple.arity() == 2) ans.add(tuple.atom(1)); @@ -171,12 +173,16 @@ public int compare(Object a, Object b) { /** The list of toplevel nodes to show. */ private final List toplevel; + /** The state in which the tree if focused. */ + private final int state; + /** Constructs a tree to display the given instance. */ - public VizTree(A4Solution instance, String title, int fontSize) { + public VizTree(A4Solution instance, String title, int fontSize, int state) { super(fontSize); this.instance = instance; this.title = title; this.onWindows = Util.onWindows(); + this.state = state; ArrayList toplevel = new ArrayList(); for (Sig s : instance.getAllReachableSigs()) if (s != Sig.UNIV && s != Sig.SEQIDX && s != Sig.NONE) diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/PreferencesDialog.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/PreferencesDialog.java index 6fbe2ff48..f4b0118a1 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/PreferencesDialog.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/PreferencesDialog.java @@ -4,6 +4,7 @@ import static edu.mit.csail.sdg.alloy4.A4Preferences.AutoVisualize; import static edu.mit.csail.sdg.alloy4.A4Preferences.CoreGranularity; import static edu.mit.csail.sdg.alloy4.A4Preferences.CoreMinimization; +import static edu.mit.csail.sdg.alloy4.A4Preferences.DecomposePref; import static edu.mit.csail.sdg.alloy4.A4Preferences.FontName; import static edu.mit.csail.sdg.alloy4.A4Preferences.FontSize; import static edu.mit.csail.sdg.alloy4.A4Preferences.ImplicitThis; @@ -32,10 +33,15 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import javax.swing.AbstractAction; import javax.swing.AbstractListModel; @@ -74,6 +80,10 @@ import edu.mit.csail.sdg.alloy4.Subprocess; import edu.mit.csail.sdg.translator.A4Options.SatSolver; +/** + * @modified [electrum] only log when debugging; load electrod binary + * executables; added decompose strategy option + */ @SuppressWarnings({ "serial" } ) @@ -85,6 +95,8 @@ public class PreferencesDialog extends JFrame { // private JPanel solverPane; // private JPanel miscPane; + final static boolean isDebug = "yes".equals(System.getProperty("debug")); + private static class MyIntSpinnerModel extends AbstractSpinnerModel { private final IntPref pref; @@ -278,6 +290,15 @@ protected Iterable testSolvers() { satChoices.remove(SatSolver.GlucoseJNI); if (!loadLibrary("cryptominisat")) satChoices.remove(SatSolver.CryptoMiniSatJNI); + // [electrum] load unbounded model checking backend + if (!staticLibrary("electrod")) { + satChoices.remove(SatSolver.ElectrodX); + satChoices.remove(SatSolver.ElectrodS); + } + if (!staticLibrary("NuSMV")) + satChoices.remove(SatSolver.ElectrodS); + if (!staticLibrary("nuXmv")) + satChoices.remove(SatSolver.ElectrodX); SatSolver now = Solver.get(); if (!satChoices.contains(now)) { now = SatSolver.LingelingJNI; @@ -312,13 +333,41 @@ private static boolean isSat(String output) { return output.substring(i).startsWith("s SATISFIABLE"); } + private static boolean staticLibrary(String name) { + // check if in java library path + final String[] dirs = System.getProperty("java.library.path").split(System.getProperty("path.separator")); + for (int i = dirs.length - 1; i >= 0; i--) { + final File file = new File(dirs[i] + File.separator + name); + if (file.canExecute()) { + if (isDebug) + System.out.println("Loaded: " + name + " at " + file); + return true; + } + } + // check if in system path + for (String str : (System.getenv("PATH")).split(Pattern.quote(File.pathSeparator))) { + Path pth = Paths.get(str); + if (Files.exists(pth.resolve(name))) { + if (isDebug) + System.out.println("Loaded: " + name + " at " + pth); + return true; + } + } + + if (isDebug) + System.out.println("Failed to load: " + name); + return false; + } + + private static boolean loadLibrary(String library) { boolean loaded = _loadLibrary(library); String libName = System.mapLibraryName(library); - if (loaded) - System.out.println("Loaded: " + libName); - else - System.out.println("Failed to load: " + libName); + if (isDebug) + if (loaded) + System.out.println("Loaded: " + libName); + else + System.out.println("Failed to load: " + libName); return loaded; } @@ -384,8 +433,8 @@ protected Component initEditorPane() { } protected Component initSolverPane() { - JPanel p = OurUtil.makeGrid(2, gbc().make(), mkCombo(Solver), mkSlider(SkolemDepth), mkCombo(Unrolls), mkCombo(CoreGranularity), mkSlider(CoreMinimization)); - int r = 5; + JPanel p = OurUtil.makeGrid(2, gbc().make(), mkCombo(Solver), mkSlider(SkolemDepth), mkCombo(Unrolls), mkCombo(CoreGranularity), mkSlider(CoreMinimization), mkSlider(DecomposePref)); + int r = 6; addToGrid(p, mkCheckBox(NoOverflow), gbc().pos(0, r++).gridwidth(2)); addToGrid(p, mkCheckBox(ImplicitThis), gbc().pos(0, r++).gridwidth(2)); addToGrid(p, mkCheckBox(InferPartialInstance), gbc().pos(0, r++).gridwidth(2)); diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleCLI.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleCLI.java index 4ccbeba9b..b7e0b4392 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleCLI.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleCLI.java @@ -49,8 +49,9 @@ * This class is used by the Alloy developers to drive the regression test * suite. For a more detailed guide on how to use Alloy API, please see * "ExampleUsingTheCompiler.java" + * + * @modified [electrum] updated reporting */ - public final class SimpleCLI { private static final class SimpleReporter extends A4Reporter { @@ -114,12 +115,12 @@ public void bound(String msg) { } @Override - public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) { - sb.append(" Solver=" + solver + " Bitwidth=" + bitwidth + " MaxSeq=" + maxseq + " Symmetry=" + (symmetry > 0 ? ("" + symmetry) : "OFF") + "\n"); + public void translate(String solver, int bitwidth, int maxseq, int mintrace, int maxtrace, int skolemDepth, int symmetry, String strat) { + debug("Solver=" + solver + " Steps=" + mintrace + ".." + maxtrace + " Bitwidth=" + bitwidth + " MaxSeq=" + maxseq + " Symmetry=" + (symmetry > 0 ? ("" + symmetry) : "OFF") + " Mode=" + strat + "\n"); } @Override - public void solve(int primaryVars, int totalVars, int clauses) { + public void solve(int step, int primaryVars, int totalVars, int clauses) { if (db) db(" " + totalVars + " vars. " + primaryVars + " primary vars. " + clauses + " clauses.\n"); sb.append(" " + totalVars + " vars. " + primaryVars + " primary vars. " + clauses + " clauses. 12345ms.\n"); @@ -184,7 +185,7 @@ private static void validate(A4Solution sol) throws Exception { sw.flush(); String txt = sw.toString(); A4SolutionReader.read(new ArrayList(), new XMLNode(new StringReader(txt))).toString(); - StaticInstanceReader.parseInstance(new StringReader(txt)); + StaticInstanceReader.parseInstance(new StringReader(txt), 0); } public static void main(String[] args) throws Exception { @@ -258,7 +259,7 @@ public static void main(String[] args) throws Exception { metasb.flush(); String metaxml = metasb.toString(); A4SolutionReader.read(new ArrayList(), new XMLNode(new StringReader(metaxml))); - StaticInstanceReader.parseInstance(new StringReader(metaxml)); + StaticInstanceReader.parseInstance(new StringReader(metaxml), 0); // Okay, now solve the commands A4Options options = new A4Options(); options.originalFilename = filename; diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleGUI.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleGUI.java index 0d13d5528..b35e7a0a1 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleGUI.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleGUI.java @@ -23,6 +23,7 @@ import static edu.mit.csail.sdg.alloy4.A4Preferences.AutoVisualize; import static edu.mit.csail.sdg.alloy4.A4Preferences.CoreGranularity; import static edu.mit.csail.sdg.alloy4.A4Preferences.CoreMinimization; +import static edu.mit.csail.sdg.alloy4.A4Preferences.DecomposePref; import static edu.mit.csail.sdg.alloy4.A4Preferences.FontName; import static edu.mit.csail.sdg.alloy4.A4Preferences.FontSize; import static edu.mit.csail.sdg.alloy4.A4Preferences.ImplicitThis; @@ -52,6 +53,7 @@ import static java.awt.event.KeyEvent.VK_PAGE_DOWN; import static java.awt.event.KeyEvent.VK_PAGE_UP; import static java.awt.event.KeyEvent.VK_SHIFT; +import static java.awt.event.KeyEvent.VK_U; import java.awt.BorderLayout; import java.awt.Color; @@ -186,6 +188,14 @@ * (1) the run() method in SatRunner is launched from a fresh thread
* (2) the run() method in the instance watcher (in constructor) is launched * from a fresh thread + * + * @modified [electrum] added electrum example models; added accelerator for + * execute all on mac; updated about message; evaluator now takes a + * second argument denoting the focused state; visualize traces with 2 + * states, 1 otherwise; enumerator now takes as additional argument + * the operation to apply; also distinguishes between global and local + * iterations, the former resets the visualizer; added electrod + * binaries; added the option to select the decompose strategy */ public final class SimpleGUI implements ComponentListener, Listener { @@ -280,8 +290,8 @@ public final class SimpleGUI implements ComponentListener, Listener { private static final Color background = new Color(0.9f, 0.9f, 0.9f); /** - * If subrunning==true: 0 means SAT solving; 1 means metamodel; 2 means - * enumeration. + * If subrunning==true: 0 means SAT solving; 1 means metamodel; 2 means global + * enumeration; 3 means local enumeration. */ private int subrunningTask = 0; @@ -456,10 +466,11 @@ else if (os.startsWith("windows-")) // The error will be caught later by the "berkmin" or "spear" test } // Copy the platform-dependent binaries - Util.copy(frame, true, false, platformBinary, arch + "/libminisat.so", arch + "/libminisatx1.so", arch + "/libminisat.jnilib", arch + "/libminisat.dylib", arch + "/libminisatprover.so", arch + "/libminisatproverx1.so", arch + "/libminisatprover.jnilib", arch + "/libminisatprover.dylib", arch + "/libzchaff.so", arch + "/libzchaffmincost.so", arch + "/libzchaffx1.so", arch + "/libzchaff.jnilib", arch + "/liblingeling.so", arch + "/liblingeling.dylib", arch + "/liblingeling.jnilib", arch + "/plingeling", arch + "/libglucose.so", arch + "/libglucose.dylib", arch + "/libglucose.jnilib", arch + "/libcryptominisat.so", arch + "/libcryptominisat.la", arch + "/libcryptominisat.dylib", arch + "/libcryptominisat.jnilib", arch + "/berkmin", arch + "/spear", arch + "/cryptominisat"); - Util.copy(frame, false, false, platformBinary, arch + "/minisat.dll", arch + "/cygminisat.dll", arch + "/libminisat.dll.a", arch + "/minisatprover.dll", arch + "/cygminisatprover.dll", arch + "/libminisatprover.dll.a", arch + "/glucose.dll", arch + "/cygglucose.dll", arch + "/libglucose.dll.a", arch + "/zchaff.dll", arch + "/berkmin.exe", arch + "/spear.exe"); + Util.copy(frame, true, false, platformBinary, arch + "/libminisat.so", arch + "/libminisatx1.so", arch + "/libminisat.jnilib", arch + "/libminisat.dylib", arch + "/libminisatprover.so", arch + "/libminisatproverx1.so", arch + "/libminisatprover.jnilib", arch + "/libminisatprover.dylib", arch + "/libzchaff.so", arch + "/libzchaffmincost.so", arch + "/libzchaffx1.so", arch + "/libzchaff.jnilib", arch + "/liblingeling.so", arch + "/liblingeling.dylib", arch + "/liblingeling.jnilib", arch + "/plingeling", arch + "/libglucose.so", arch + "/libglucose.dylib", arch + "/libglucose.jnilib", arch + "/libcryptominisat.so", arch + "/libcryptominisat.la", arch + "/libcryptominisat.dylib", arch + "/libcryptominisat.jnilib", arch + "/berkmin", arch + "/spear", arch + "/cryptominisat", arch + "/electrod"); + Util.copy(frame, false, false, platformBinary, arch + "/minisat.dll", arch + "/cygminisat.dll", arch + "/libminisat.dll.a", arch + "/minisatprover.dll", arch + "/cygminisatprover.dll", arch + "/libminisatprover.dll.a", arch + "/glucose.dll", arch + "/cygglucose.dll", arch + "/libglucose.dll.a", arch + "/zchaff.dll", arch + "/berkmin.exe", arch + "/spear.exe", arch + "/electrod.exe"); // Copy the model files - Util.copy(frame, false, true, alloyHome(frame), "models/book/appendixA/addressBook1.als", "models/book/appendixA/addressBook2.als", "models/book/appendixA/barbers.als", "models/book/appendixA/closure.als", "models/book/appendixA/distribution.als", "models/book/appendixA/phones.als", "models/book/appendixA/prison.als", "models/book/appendixA/properties.als", "models/book/appendixA/ring.als", "models/book/appendixA/spanning.als", "models/book/appendixA/tree.als", "models/book/appendixA/tube.als", "models/book/appendixA/undirected.als", "models/book/appendixE/hotel.thm", "models/book/appendixE/p300-hotel.als", "models/book/appendixE/p303-hotel.als", "models/book/appendixE/p306-hotel.als", "models/book/chapter2/addressBook1a.als", "models/book/chapter2/addressBook1b.als", "models/book/chapter2/addressBook1c.als", "models/book/chapter2/addressBook1d.als", "models/book/chapter2/addressBook1e.als", "models/book/chapter2/addressBook1f.als", "models/book/chapter2/addressBook1g.als", "models/book/chapter2/addressBook1h.als", "models/book/chapter2/addressBook2a.als", "models/book/chapter2/addressBook2b.als", "models/book/chapter2/addressBook2c.als", "models/book/chapter2/addressBook2d.als", "models/book/chapter2/addressBook2e.als", "models/book/chapter2/addressBook3a.als", "models/book/chapter2/addressBook3b.als", "models/book/chapter2/addressBook3c.als", "models/book/chapter2/addressBook3d.als", "models/book/chapter2/theme.thm", "models/book/chapter4/filesystem.als", "models/book/chapter4/grandpa1.als", "models/book/chapter4/grandpa2.als", "models/book/chapter4/grandpa3.als", "models/book/chapter4/lights.als", "models/book/chapter5/addressBook.als", "models/book/chapter5/lists.als", "models/book/chapter5/sets1.als", "models/book/chapter5/sets2.als", "models/book/chapter6/hotel.thm", "models/book/chapter6/hotel1.als", "models/book/chapter6/hotel2.als", "models/book/chapter6/hotel3.als", "models/book/chapter6/hotel4.als", "models/book/chapter6/mediaAssets.als", "models/book/chapter6/memory/abstractMemory.als", "models/book/chapter6/memory/cacheMemory.als", "models/book/chapter6/memory/checkCache.als", "models/book/chapter6/memory/checkFixedSize.als", "models/book/chapter6/memory/fixedSizeMemory.als", "models/book/chapter6/memory/fixedSizeMemory_H.als", "models/book/chapter6/ringElection.thm", "models/book/chapter6/ringElection1.als", "models/book/chapter6/ringElection2.als", "models/examples/algorithms/dijkstra.als", "models/examples/algorithms/dijkstra.thm", "models/examples/algorithms/messaging.als", "models/examples/algorithms/messaging.thm", "models/examples/algorithms/opt_spantree.als", "models/examples/algorithms/opt_spantree.thm", "models/examples/algorithms/peterson.als", "models/examples/algorithms/ringlead.als", "models/examples/algorithms/ringlead.thm", "models/examples/algorithms/s_ringlead.als", "models/examples/algorithms/stable_mutex_ring.als", "models/examples/algorithms/stable_mutex_ring.thm", "models/examples/algorithms/stable_orient_ring.als", "models/examples/algorithms/stable_orient_ring.thm", "models/examples/algorithms/stable_ringlead.als", "models/examples/algorithms/stable_ringlead.thm", "models/examples/case_studies/INSLabel.als", "models/examples/case_studies/chord.als", "models/examples/case_studies/chord2.als", "models/examples/case_studies/chordbugmodel.als", "models/examples/case_studies/com.als", "models/examples/case_studies/firewire.als", "models/examples/case_studies/firewire.thm", "models/examples/case_studies/ins.als", "models/examples/case_studies/iolus.als", "models/examples/case_studies/sync.als", "models/examples/case_studies/syncimpl.als", "models/examples/puzzles/farmer.als", "models/examples/puzzles/farmer.thm", "models/examples/puzzles/handshake.als", "models/examples/puzzles/handshake.thm", "models/examples/puzzles/hanoi.als", "models/examples/puzzles/hanoi.thm", "models/examples/systems/file_system.als", "models/examples/systems/file_system.thm", "models/examples/systems/javatypes_soundness.als", "models/examples/systems/lists.als", "models/examples/systems/lists.thm", "models/examples/systems/marksweepgc.als", "models/examples/systems/views.als", "models/examples/toys/birthday.als", "models/examples/toys/birthday.thm", "models/examples/toys/ceilingsAndFloors.als", "models/examples/toys/ceilingsAndFloors.thm", "models/examples/toys/genealogy.als", "models/examples/toys/genealogy.thm", "models/examples/toys/grandpa.als", "models/examples/toys/grandpa.thm", "models/examples/toys/javatypes.als", "models/examples/toys/life.als", "models/examples/toys/life.thm", "models/examples/toys/numbering.als", "models/examples/toys/railway.als", "models/examples/toys/railway.thm", "models/examples/toys/trivial.als", "models/examples/tutorial/farmer.als", "models/util/boolean.als", "models/util/graph.als", "models/util/integer.als", "models/util/natural.als", "models/util/ordering.als", "models/util/relation.als", "models/util/seqrel.als", "models/util/sequence.als", "models/util/sequniv.als", "models/util/ternary.als", "models/util/time.als"); + Util.copy(frame, false, true, alloyHome(frame), "models/book/appendixA/addressBook1.als", "models/book/appendixA/addressBook2.als", "models/book/appendixA/barbers.als", "models/book/appendixA/closure.als", "models/book/appendixA/distribution.als", "models/book/appendixA/phones.als", "models/book/appendixA/prison.als", "models/book/appendixA/properties.als", "models/book/appendixA/ring.als", "models/book/appendixA/spanning.als", "models/book/appendixA/tree.als", "models/book/appendixA/tube.als", "models/book/appendixA/undirected.als", "models/book/appendixE/hotel.thm", "models/book/appendixE/p300-hotel.als", "models/book/appendixE/p303-hotel.als", "models/book/appendixE/p306-hotel.als", "models/book/chapter2/addressBook1a.als", "models/book/chapter2/addressBook1b.als", "models/book/chapter2/addressBook1c.als", "models/book/chapter2/addressBook1d.als", "models/book/chapter2/addressBook1e.als", "models/book/chapter2/addressBook1f.als", "models/book/chapter2/addressBook1g.als", "models/book/chapter2/addressBook1h.als", "models/book/chapter2/addressBook2a.als", "models/book/chapter2/addressBook2b.als", "models/book/chapter2/addressBook2c.als", "models/book/chapter2/addressBook2d.als", "models/book/chapter2/addressBook2e.als", "models/book/chapter2/addressBook3a.als", "models/book/chapter2/addressBook3b.als", "models/book/chapter2/addressBook3c.als", "models/book/chapter2/addressBook3d.als", "models/book/chapter2/theme.thm", "models/book/chapter4/filesystem.als", "models/book/chapter4/grandpa1.als", "models/book/chapter4/grandpa2.als", "models/book/chapter4/grandpa3.als", "models/book/chapter4/lights.als", "models/book/chapter5/addressBook.als", "models/book/chapter5/lists.als", "models/book/chapter5/sets1.als", "models/book/chapter5/sets2.als", "models/book/chapter6/hotel.thm", "models/book/chapter6/hotel1.als", "models/book/chapter6/hotel2.als", "models/book/chapter6/hotel3.als", "models/book/chapter6/hotel4.als", "models/book/chapter6/mediaAssets.als", "models/book/chapter6/memory/abstractMemory.als", "models/book/chapter6/memory/cacheMemory.als", "models/book/chapter6/memory/checkCache.als", "models/book/chapter6/memory/checkFixedSize.als", "models/book/chapter6/memory/fixedSizeMemory.als", "models/book/chapter6/memory/fixedSizeMemory_H.als", "models/book/chapter6/ringElection.thm", "models/book/chapter6/ringElection1.als", "models/book/chapter6/ringElection2.als", "models/examples/algorithms/dijkstra.als", "models/examples/algorithms/dijkstra.thm", "models/examples/algorithms/messaging.als", "models/examples/algorithms/messaging.thm", "models/examples/algorithms/opt_spantree.als", "models/examples/algorithms/opt_spantree.thm", "models/examples/algorithms/peterson.als", "models/examples/algorithms/ringlead.als", "models/examples/algorithms/ringlead.thm", "models/examples/algorithms/s_ringlead.als", "models/examples/algorithms/stable_mutex_ring.als", "models/examples/algorithms/stable_mutex_ring.thm", "models/examples/algorithms/stable_orient_ring.als", "models/examples/algorithms/stable_orient_ring.thm", "models/examples/algorithms/stable_ringlead.als", "models/examples/algorithms/stable_ringlead.thm", "models/examples/case_studies/INSLabel.als", "models/examples/case_studies/chord.als", "models/examples/case_studies/chord2.als", "models/examples/case_studies/chordbugmodel.als", "models/examples/case_studies/com.als", "models/examples/case_studies/firewire.als", "models/examples/case_studies/firewire.thm", "models/examples/case_studies/ins.als", "models/examples/case_studies/iolus.als", "models/examples/case_studies/sync.als", "models/examples/case_studies/syncimpl.als", "models/examples/puzzles/farmer.als", "models/examples/puzzles/farmer.thm", "models/examples/puzzles/handshake.als", "models/examples/puzzles/handshake.thm", "models/examples/puzzles/hanoi.als", "models/examples/puzzles/hanoi.thm", "models/examples/systems/file_system.als", "models/examples/systems/file_system.thm", "models/examples/systems/javatypes_soundness.als", "models/examples/systems/lists.als", "models/examples/systems/lists.thm", "models/examples/systems/marksweepgc.als", "models/examples/systems/views.als", "models/examples/toys/birthday.als", "models/examples/toys/birthday.thm", "models/examples/toys/ceilingsAndFloors.als", "models/examples/toys/ceilingsAndFloors.thm", "models/examples/toys/genealogy.als", "models/examples/toys/genealogy.thm", "models/examples/toys/grandpa.als", "models/examples/toys/grandpa.thm", "models/examples/toys/javatypes.als", "models/examples/toys/life.als", "models/examples/toys/life.thm", "models/examples/toys/numbering.als", "models/examples/toys/railway.als", "models/examples/toys/railway.thm", "models/examples/toys/trivial.als", "models/examples/tutorial/farmer.als", "models/util/boolean.als", "models/util/graph.als", "models/util/integer.als", "models/util/natural.als", "models/util/ordering.als", "models/util/relation.als", "models/util/seqrel.als", "models/util/sequence.als", "models/util/sequniv.als", "models/util/ternary.als", "models/util/time.als", + "models/examples/temporal/buffer.als", "models/examples/temporal/leader.als", "models/examples/temporal/leader_events.als", "models/examples/temporal/trash.als"); // Record the locations System.setProperty("alloy.theme0", alloyHome(frame) + fs + "models"); System.setProperty("alloy.home", alloyHome(frame)); @@ -519,7 +530,8 @@ private Runner wrapMe() { public void run() { try { method.setAccessible(true); - method.invoke(SimpleGUI.this, new Object[] {}); + method.invoke(SimpleGUI.this, new Object[] { +}); } catch (Throwable ex) { ex = new IllegalArgumentException("Failed call to " + name + "()", ex); Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), ex); @@ -1060,7 +1072,6 @@ private Runner doGotoNextFile() { private Runner doRefreshRun() { if (wrap) return wrapMe(); - KeyStroke ac = KeyStroke.getKeyStroke(VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); try { wrap = true; runmenu.removeAll(); @@ -1115,19 +1126,22 @@ private Runner doRefreshRun() { try { wrap = true; for (int i = 0; i < cp.size(); i++) { - JMenuItem y = new JMenuItem(cp.get(i).toString(), null); - y.addActionListener(doRun(i)); + JMenuItem menuItem = new JMenuItem(cp.get(i).toString(), null); + menuItem.addActionListener(doRun(i)); if (i == latestCommand) { - y.setMnemonic(VK_E); - y.setAccelerator(ac); + menuItem.setMnemonic(VK_E); + menuItem.setAccelerator(KeyStroke.getKeyStroke(VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); } - runmenu.add(y, i); + runmenu.add(menuItem, i); } - if (cp.size() >= 2) { - JMenuItem y = new JMenuItem("Execute All", null); - y.setMnemonic(VK_A); - y.addActionListener(doRun(-1)); - runmenu.add(y, 0); + if (cp.size() > 1) { + JMenuItem menuItem = new JMenuItem("Execute All", null); + // [electrum] cmd+u acc for mac + final int mnemonic = Util.onMac() ? VK_U : VK_A; + menuItem.setMnemonic(mnemonic); + menuItem.setAccelerator(KeyStroke.getKeyStroke(mnemonic, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); + menuItem.addActionListener(doRun(-1)); + runmenu.add(menuItem, 0); runmenu.add(new JSeparator(), 1); } } finally { @@ -1181,6 +1195,7 @@ private Runner doRun(Integer commandIndex) { opt.coreMinimization = CoreMinimization.get(); opt.inferPartialInstance = InferPartialInstance.get(); opt.coreGranularity = CoreGranularity.get(); + opt.decompose_mode = DecomposePref.get().ordinal(); opt.originalFilename = Util.canon(text.get().getFilename()); opt.solver = Solver.get(); task.bundleIndex = i; @@ -1236,7 +1251,10 @@ Runner doStop(Integer how) { if (latestAutoInstance.length() > 0) { String f = latestAutoInstance; latestAutoInstance = ""; + // [electrum] move to first state if global iteration if (subrunningTask == 2) + viz.loadXML(f, true, 0); + else if (subrunningTask == 3) viz.loadXML(f, true); else if (AutoVisualize.get() || subrunningTask == 1) doVisualize("XML: " + f); @@ -1436,6 +1454,7 @@ private Runner doRefreshOption() { if (Version.experimental) { addToMenu(optmenu, Unrolls); + addToMenu(optmenu, DecomposePref); addToMenu(optmenu, ImplicitThis, NoOverflow, InferPartialInstance); } @@ -1519,7 +1538,7 @@ public Runner doAbout() { ta.setBorder(null); ta.setFont(new JLabel().getFont()); // @formatter:off - ta.setText("

Alloy Analyzer " + Version.getShortversion() + "

" + ta.setText("

Alloy Analyzer "+ Version.getShortversion() +"

" + "
" + "" + "Project LeadDaniel Jackson" @@ -1531,12 +1550,13 @@ public Runner doAbout() { + "

Questions and comments about Alloy are welcome at the community forum:

" + "

Alloy Community Forum: https://groups.google.com/forum/#!forum/alloytools

" + "

Alloy experts also respond to https://stackoverflow.com questions tagged alloy.

" - + "

Major contributions to earlier versions of Alloy were made by: Felix Chang (v4);
" - + "Jonathan Edwards, Eunsuk Kang, Joe Near, Robert Seater, Derek Rayside, Greg Dennis,
" - + "Ilya Shlyakhter, Mana Taghdiri, Mandana Vaziri, Sarfraz Khurshid (v3); Manu Sridharan
" - + "(v2); Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip, Jongmin Baek, Ning Song,
" - + "Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel, Ian Schechter, Uriel
" - + "Schafer (v1).

" + + "

Major contributions to earlier versions of Alloy were made by: Julien Brunel, David
" + + "Chemouil, Alcino Cunha, Nuno Macedo, Denis Kuperberg, Eduardo Pessoa, Tiago Guimarães
" // [electrum] electrum contributors + + "(Electrum); Felix Chang (v4); Jonathan Edwards, Eunsuk Kang, Joe Near, Robert Seater,
" + + "Derek Rayside, Greg Dennis, Ilya Shlyakhter, Mana Taghdiri, Mandana Vaziri, Sarfraz
" + + "Khurshid (v3); Manu Sridharan (v2); Edmond Lau, Vincent Yeung, Sam Daitch, Andrew Yip,
" + + "Jongmin Baek, Ning Song, Arturo Arizpe, Li-kuo (Brian) Lin, Joseph Cohen, Jesse Pavel,
" + + "Ian Schechter, Uriel Schafer (v1).

" + "

The development of Alloy was funded by part by the National Science Foundation under
" + "Grant Nos. 0325283, 0541183, 0438897 and 0707612; by the Air Force Research Laboratory
" + "(AFRL/IF) and the Disruptive Technology Office (DTO) in the National Intelligence
" @@ -1739,7 +1759,7 @@ Runner doVisualize(String arg) { } } if (arg.startsWith("XML: ")) { // XML: filename - viz.loadXML(Util.canon(arg.substring(5)), false); + viz.loadXML(Util.canon(arg.substring(5)), false, 0); } return null; } @@ -1764,13 +1784,14 @@ private Runner doOpenFile(String arg) { @Override public String compute(Object input) { - final String arg = (String) input; + final String[] arg = (String[]) input; // [electrum] additional argument to set the iteration operation OurUtil.show(frame); if (WorkerEngine.isBusy()) throw new RuntimeException("Alloy4 is currently executing a SAT solver command. Please wait until that command has finished."); SimpleCallback1 cb = new SimpleCallback1(SimpleGUI.this, viz, log, VerbosityPref.get().ordinal(), latestAlloyVersionName, latestAlloyVersion); SimpleTask2 task = new SimpleTask2(); - task.filename = arg; + task.filename = arg[0]; + task.index = Integer.valueOf(arg[1]); try { if (AlloyCore.isDebug()) WorkerEngine.runLocally(task, cb); @@ -1783,14 +1804,14 @@ public String compute(Object input) { log.logDivider(); log.flush(); doStop(2); - return arg; + return arg[0]; } - subrunningTask = 2; + subrunningTask = task.index < 1 ? 2 : 3; // [electrum] whether global iteration runmenu.setEnabled(false); runbutton.setVisible(false); showbutton.setEnabled(false); stopbutton.setVisible(true); - return arg; + return arg[0]; } }; @@ -1840,10 +1861,11 @@ public final Object compute(final Object input) throws Exception { filename = ((File) input).getAbsolutePath(); return ""; } - if (!(input instanceof String)) + if (!(input instanceof String[])) return ""; - final String str = (String) input; - if (str.trim().length() == 0) + // [electrum] evaluator takes two arguments, the second is the focused state + final String[] strs = (String[]) input; + if (strs[0].trim().length() == 0) return ""; // Empty line Module root = null; A4Solution ans = null; @@ -1878,13 +1900,13 @@ public final Object compute(final Object input) throws Exception { throw new ErrorFatal("Failed to read or parse the XML file."); } try { - Expr e = CompUtil.parseOneExpression_fromString(root, str); + Expr e = CompUtil.parseOneExpression_fromString(root, strs[0]); if (AlloyCore.isDebug() && VerbosityPref.get() == Verbosity.FULLDEBUG) { SimInstance simInst = convert(root, ans); if (simInst.wasOverflow()) return simInst.visitThis(e).toString() + " (OF)"; } - return ans.eval(e); + return ans.eval(e, Integer.valueOf(strs[1])).toString(); } catch (HigherOrderDeclException ex) { throw new ErrorType("Higher-order quantification is not allowed in the evaluator."); } @@ -2156,7 +2178,7 @@ private void finishInit(String[] args, int width) { } // Pre-load the visualizer - viz = new VizGUI(false, "", windowmenu2, enumerator, evaluator); + viz = new VizGUI(false, "", windowmenu2, enumerator, evaluator, 2); viz.doSetFontSize(FontSize.get()); // Create the toolbar diff --git a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleReporter.java b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleReporter.java index a820aa9ad..1531dc389 100644 --- a/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleReporter.java +++ b/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/SimpleReporter.java @@ -35,6 +35,7 @@ import edu.mit.csail.sdg.alloy4.ConstList; import edu.mit.csail.sdg.alloy4.ConstMap; import edu.mit.csail.sdg.alloy4.Err; +import edu.mit.csail.sdg.alloy4.ErrorAPI; import edu.mit.csail.sdg.alloy4.ErrorSyntax; import edu.mit.csail.sdg.alloy4.ErrorType; import edu.mit.csail.sdg.alloy4.ErrorWarning; @@ -59,7 +60,23 @@ import edu.mit.csail.sdg.translator.A4SolutionWriter; import edu.mit.csail.sdg.translator.TranslateAlloyToKodkod; -/** This helper method is used by SimpleGUI. */ +/** + * This helper method is used by SimpleGUI. + * + * @modified [electrum] changed so that all commands can be executed even when + * some throw errors; the solving process now reports in which step of + * the temporal analysis is; since temporal analysis is incremental, + * solving the command from 1 to the maximum number of steps defined + * in the scope, and reports whenever each of these steps finishes; + * the SimpleReporter overrides these messages in the log panel and + * shows only the most recent one; the translation also reports the + * relevant temporal options; enumeration task enriched with + * alternative iteration operations; reporting updated with the + * decompose strategy; a call is made every time one of the parallel + * problems performs a step; the number of seen configurations is thus + * also logged (the presented step is the maximum step seen by any + * parallel problem) + */ final class SimpleReporter extends A4Reporter { @@ -70,7 +87,7 @@ public static final class SimpleCallback1 implements WorkerCallback { private final SwingLogPanel span; private final Set warnings = new HashSet(); private final List results = new ArrayList(); - private int len2 = 0, len3 = 0, verbosity = 0; + private int len2 = 0, len3 = 0, len4 = 0, verbosity = 0; private final String latestName; private final int latestVersion; @@ -204,15 +221,16 @@ else if (ex instanceof ErrorType) } if (array[0].equals("debug") && verbosity > 2) { span.log(" " + array[1] + "\n"); - len2 = len3 = span.getLength(); + len2 = len3 = len4 = span.getLength(); } if (array[0].equals("translate")) { span.log(" " + array[1]); - len3 = span.getLength(); + len3 = len4 = span.getLength(); span.logBold(" Generating CNF...\n"); } if (array[0].equals("solve")) { - span.setLength(len3); + // [electrum] len4 allows solving step info to be overwritten + span.setLength(len4); span.log(" " + array[1]); len3 = span.getLength(); span.logBold(" Solving...\n"); @@ -359,16 +377,41 @@ public void debug(final String msg) { /** {@inheritDoc} */ @Override - public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) { - lastTime = System.currentTimeMillis(); - cb("translate", "Solver=" + solver + " Bitwidth=" + bitwidth + " MaxSeq=" + maxseq + (skolemDepth == 0 ? "" : " SkolemDepth=" + skolemDepth) + " Symmetry=" + (symmetry > 0 ? ("" + symmetry) : "OFF") + '\n'); + public void translate(String solver, int bitwidth, int maxseq, int mintrace, int maxtrace, int skolemDepth, int symmetry, String strat) { + startTime = System.currentTimeMillis(); + startCount = 0; + cb("translate", "Solver=" + solver + " Steps=" + mintrace + ".." + maxtrace + " Bitwidth=" + bitwidth + " MaxSeq=" + maxseq + (skolemDepth == 0 ? "" : " SkolemDepth=" + skolemDepth) + " Symmetry=" + (symmetry > 0 ? ("" + symmetry) : "OFF") + " Mode=" + strat + "\n"); } /** {@inheritDoc} */ @Override - public void solve(final int primaryVars, final int totalVars, final int clauses) { + public void solve(final int step, final int pv, final int tv, final int cl) { + // [electrum] this may now be called multiple times in iterative temporal solving, variables are accumulated + // [electrum] in decomposed mode it also reports how many configs have been explored (and only presents the largest step seen) minimized = 0; - cb("solve", "" + totalVars + " vars. " + primaryVars + " primary vars. " + clauses + " clauses. " + (System.currentTimeMillis() - lastTime) + "ms.\n"); + if (startStep < 0) + startStep = step; + if (startStep == step) // [electrum] denotes a new config + startCount++; + seenStep = Math.max(seenStep, step); + primaryVars += pv; + totalVars += tv; + clauses += cl; + StringBuilder sb = new StringBuilder(); + if (startCount > 1) + sb.append(startCount + " configs. "); + if (seenStep > 0) + sb.append(startStep + ".." + seenStep + " steps. "); + if (totalVars >= 0) + sb.append("" + totalVars + " vars. "); + if (primaryVars >= 0) + sb.append(primaryVars + " primary vars. "); + if (clauses > 0) + sb.append(clauses + " clauses. "); + if (sb.length() == 0) + sb.append("No translation information available. "); + sb.append((System.currentTimeMillis() - startTime) + "ms.\n"); + cb("solve", sb.toString()); lastTime = System.currentTimeMillis(); } @@ -479,7 +522,13 @@ public void resultUNSAT(Object command, long solvingTime, Object solution) { * The time that the last action began; we subtract it from * System.currentTimeMillis() to determine the elapsed time. */ - private long lastTime = 0; + private long lastTime = 0, startTime = 0; + + /** + * Variables to log and accumulate solving data for each call to + * {@link #solve(int, int, int, int)} + */ + private int startStep = -1, seenStep = -1, primaryVars = 0, clauses = 0, totalVars = 0, startCount = 0; /** * If we performed unsat core minimization, then this is the start of the @@ -555,6 +604,7 @@ private static void writeXML(A4Reporter rep, Module mod, String filename, A4Solu static final class SimpleTask2 implements WorkerTask { private static final long serialVersionUID = 0; + public int index = -1; // [electrum] registers which iteration operation to perform public String filename = ""; public transient WorkerCallback out = null; @@ -594,7 +644,12 @@ public void run(WorkerCallback out) throws Exception { } int tries = 0; while (true) { - sol = sol.next(); + try { + sol = sol.fork(this.index); // [electrum] call the enumerator with appropriate operation + } catch (ErrorAPI e) { + cb("pop", e.getMessage()); + return; + } if (!sol.satisfiable()) { cb("pop", "There are no more satisfying instances.\n\n" + "Note: due to symmetry breaking and other optimizations,\n" + "some equivalent solutions may have been omitted."); return; @@ -624,7 +679,7 @@ public void run(WorkerCallback out) throws Exception { */ private static void validate(String filename) throws Exception { A4SolutionReader.read(new ArrayList(), new XMLNode(new File(filename))).toString(); - StaticInstanceReader.parseInstance(new File(filename)); + StaticInstanceReader.parseInstance(new File(filename), 0); } /** Task that perform one command. */ @@ -655,6 +710,7 @@ public void run(WorkerCallback out) throws Exception { if (rep.warn > 0 && !bundleWarningNonFatal) return; List result = new ArrayList(cmds.size()); + Exception exc = null; if (bundleIndex == -2) { final String outf = tempdir + File.separatorChar + "m.xml"; cb(out, "S2", "Generating the metamodel...\n"); @@ -681,7 +737,12 @@ public void run(WorkerCallback out) throws Exception { final Command cmd = cmds.get(i); rep.tempfile = tempCNF; cb(out, "bold", "Executing \"" + cmd + "\"\n"); - A4Solution ai = TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), cmd, options); + A4Solution ai = null; + try { // [electrum] postpones error throwing, allows other commands to still be solved + ai = TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), cmd, options); + } catch (Exception e1) { + exc = e1; + } if (ai == null) result.add(null); else if (ai.satisfiable()) @@ -735,6 +796,10 @@ else if (r.expects == 0) rep.cb("bold", "Note: There were " + rep.warn + " compilation warnings. Please scroll up to see them.\n"); if (rep.warn == 1) rep.cb("bold", "Note: There was 1 compilation warning. Please scroll up to see it.\n"); + + if (exc != null) + throw exc; + } } } diff --git a/org.alloytools.alloy.application/src/test/java/edu/mit/csail/sdg/alloy4whole/InternalTest.java b/org.alloytools.alloy.application/src/test/java/edu/mit/csail/sdg/alloy4whole/InternalTest.java index d766ff127..c510b2dad 100644 --- a/org.alloytools.alloy.application/src/test/java/edu/mit/csail/sdg/alloy4whole/InternalTest.java +++ b/org.alloytools.alloy.application/src/test/java/edu/mit/csail/sdg/alloy4whole/InternalTest.java @@ -39,6 +39,8 @@ /** * API-specific regression test suite; the larger collection of models that test * both the compiler and translator are in models/tests/*.als + * + * @modified [electrum] adapted to trace instance XML format */ public class InternalTest extends TestCase { @@ -61,6 +63,40 @@ private static void check(Object a, Object b) { public void test1() throws Exception { XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + "" + " " + " " + " " + "" + "" + " " + " " + "" + "" + "")); + String err = ""; + try { + A4SolutionReader.read(null, xml); + } catch (Throwable ex) { + err = ex.toString(); + } + check(err.contains("Missing trace")); + } + + public void test2() throws Exception { + test1(); + XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + "" + " " + " " + "" + "" + "")); + String err = ""; + try { + A4SolutionReader.read(null, xml); + } catch (Throwable ex) { + err = ex.toString(); + } + check(err.contains("Missing trace")); + } + + public void test3() throws Exception { + XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + " " + "" + "")); + String err = ""; + try { + A4SolutionReader.read(null, xml); + } catch (Throwable ex) { + err = ex.toString(); + } + check(err.contains("Missing trace")); + } + + public void test1Ele() throws Exception { + XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + "" + " " + " " + " " + "" + "" + " " + " " + "" + "" + "")); Sig state = new Sig.PrimSig("State"); A4Solution sol = A4SolutionReader.read(Arrays.asList(state), xml); SafeList skolems = new SafeList(sol.getAllSkolems()); @@ -78,9 +114,9 @@ public void test1() throws Exception { check("" + sol.eval(field2.cardinality()), "-2"); } - public void test2() throws Exception { + public void test2Ele() throws Exception { test1(); - XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + "" + " " + " " + "" + "" + "")); + XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + "" + " " + " " + "" + "" + "")); Sig activity = new Sig.PrimSig("Act"); A4Solution sol = A4SolutionReader.read(Arrays.asList(activity), xml); SafeList skolems = new SafeList(sol.getAllSkolems()); @@ -89,8 +125,8 @@ public void test2() throws Exception { check(skolems.get(0).type(), Sig.SEQIDX.type().product(activity.type())); } - public void test3() throws Exception { - XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + " " + "" + "")); + public void test3Ele() throws Exception { + XMLNode xml = new XMLNode(new StringReader("" + "" + " " + " " + " " + " " + " " + "" + "")); String err = ""; try { A4SolutionReader.read(null, xml); diff --git a/org.alloytools.alloy.core/.classpath b/org.alloytools.alloy.core/.classpath index 76b65c0d5..bcafe71e5 100644 --- a/org.alloytools.alloy.core/.classpath +++ b/org.alloytools.alloy.core/.classpath @@ -1,10 +1,12 @@ - - - - - + + + + + + + diff --git a/org.alloytools.alloy.core/.settings/org.eclipse.jdt.core.prefs b/org.alloytools.alloy.core/.settings/org.eclipse.jdt.core.prefs index 581b9f158..2f809de6d 100644 --- a/org.alloytools.alloy.core/.settings/org.eclipse.jdt.core.prefs +++ b/org.alloytools.alloy.core/.settings/org.eclipse.jdt.core.prefs @@ -133,12 +133,16 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=4 org.eclipse.jdt.core.formatter.align_type_members_on_columns=true +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=2 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=51 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=50 @@ -148,6 +152,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_e org.eclipse.jdt.core.formatter.alignment_for_assignment=2 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=2 org.eclipse.jdt.core.formatter.alignment_for_compact_if=2 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=2 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=2 @@ -191,6 +196,8 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true @@ -242,13 +249,13 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert @@ -415,6 +422,9 @@ org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false diff --git a/org.alloytools.alloy.core/.settings/org.eclipse.jdt.ui.prefs b/org.alloytools.alloy.core/.settings/org.eclipse.jdt.ui.prefs index dcee2a4d2..4282c280f 100644 --- a/org.alloytools.alloy.core/.settings/org.eclipse.jdt.ui.prefs +++ b/org.alloytools.alloy.core/.settings/org.eclipse.jdt.ui.prefs @@ -60,7 +60,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Alloy -formatter_settings_version=13 +formatter_settings_version=14 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true diff --git a/org.alloytools.alloy.core/bnd.bnd b/org.alloytools.alloy.core/bnd.bnd index d2774f018..71bffcfdc 100644 --- a/org.alloytools.alloy.core/bnd.bnd +++ b/org.alloytools.alloy.core/bnd.bnd @@ -1,22 +1,22 @@ - -includeresource: \ - src/main/resources + src/main/resources, \ + @${repo;slf4j.api}, \ -buildpath: \ - org.alloytools.kodkod.core;version=latest, \ + org.alloytools.pardinus;version=latest,\ org.sat4j.core,\ org.alloytools.kodkod.nativesat.util;version=latest,\ org.alloytools.kodkod.nativesat.amd64-linux;version=latest,\ org.alloytools.kodkod.nativesat.x86-linux;version=latest,\ org.alloytools.kodkod.nativesat.x86-mac;version=latest,\ - org.alloytools.kodkod.nativesat.x86-windows;version=latest, \ - org.eclipse.jdt.annotation + org.alloytools.kodkod.nativesat.x86-windows;version=latest,\ + org.eclipse.jdt.annotation,\ -testpath: \ osgi.enroute.junit.wrapper, \ osgi.enroute.hamcrest.wrapper, \ - src/main/resources;version=file - + src/main/resources;version=file, \ + slf4j.api, \ Export-Package: \ edu.mit.csail.sdg.alloy4,\ @@ -27,4 +27,6 @@ Export-Package: \ edu.mit.csail.sdg.translator,\ org.alloytools.util.table,\ org.alloytools.alloy.core -Private-Package: java_cup.runtime + +Private-Package: \ + java_cup.runtime diff --git a/org.alloytools.alloy.core/build.gradle b/org.alloytools.alloy.core/build.gradle index dd26cd987..23557c61b 100644 --- a/org.alloytools.alloy.core/build.gradle +++ b/org.alloytools.alloy.core/build.gradle @@ -15,6 +15,7 @@ task cup(type: JavaExec ) { outputs.files("src/main/java/edu/mit/csail/sdg/parser/CompParser.java", "src/main/java/edu/mit/csail/sdg/parser/CompSym.java") classpath file( '../cnf/jars/java-cup-11a.jar' ) + classpath file( '../cnf/jars/java-cup-runtime-0.11-a-czt01-cdh.jar' ) main = 'java_cup.Main' workingDir( "src/main/java/edu/mit/csail/sdg/parser") args( diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Preferences.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Preferences.java index 2cb7328c6..75365e8fc 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Preferences.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Preferences.java @@ -1,3 +1,17 @@ +/* Alloy Analyzer 4 -- Copyright (c) 2006-2009, Felix Chang + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package edu.mit.csail.sdg.alloy4; import java.awt.GraphicsEnvironment; @@ -16,6 +30,11 @@ import edu.mit.csail.sdg.translator.A4Options.SatSolver; +/** + * + * @modified [electrum] added decompose strategy option + * + */ @SuppressWarnings({ "serial", "unchecked" } ) @@ -501,175 +520,218 @@ public void actionPerformed(ActionEvent e) { /** * True if Alloy Analyzer should let warning be nonfatal. */ - public static final BooleanPref WarningNonfatal = new BooleanPref("WarningNonfatal", "Allow warnings"); + public static final BooleanPref WarningNonfatal = new BooleanPref("WarningNonfatal", "Allow warnings"); /** * True if Alloy Analyzer should automatically visualize the latest instance. */ - public static final BooleanPref AutoVisualize = new BooleanPref("AutoVisualize", "Visualize automatically"); + public static final BooleanPref AutoVisualize = new BooleanPref("AutoVisualize", "Visualize automatically"); /** True if Alloy Analyzer should insist on antialias. */ - public static final BooleanPref AntiAlias = new BooleanPref("AntiAlias", "Use anti-aliasing"); + public static final BooleanPref AntiAlias = new BooleanPref("AntiAlias", "Use anti-aliasing"); /** * True if Alloy Analyzer should record the raw Kodkod input and output. */ - public static final BooleanPref RecordKodkod = new BooleanPref("RecordKodkod", "Record the Kodkod input/output"); + public static final BooleanPref RecordKodkod = new BooleanPref("RecordKodkod", "Record the Kodkod input/output"); /** * True if Alloy Analyzer should enable the new Implicit This name resolution. */ - public static final BooleanPref ImplicitThis = new BooleanPref("ImplicitThis", "Enable 'implicit this' name resolution"); + public static final BooleanPref ImplicitThis = new BooleanPref("ImplicitThis", "Enable 'implicit this' name resolution"); /** * True if Alloy Analyzer should not report models that overflow. */ - public static final BooleanPref NoOverflow = new BooleanPref("NoOverflow", "Prevent overflows", true); + public static final BooleanPref NoOverflow = new BooleanPref("NoOverflow", "Prevent overflows", true); /** * The latest X coordinate of the Alloy Analyzer's main window. */ - public static final IntPref AnalyzerX = new IntPref("AnalyzerX", 0, -1, 65535); + public static final IntPref AnalyzerX = new IntPref("AnalyzerX", 0, -1, 65535); /** * The latest Y coordinate of the Alloy Analyzer's main window. */ - public static final IntPref AnalyzerY = new IntPref("AnalyzerY", 0, -1, 65535); + public static final IntPref AnalyzerY = new IntPref("AnalyzerY", 0, -1, 65535); /** The latest width of the Alloy Analyzer's main window. */ - public static final IntPref AnalyzerWidth = new IntPref("AnalyzerWidth", 0, -1, 65535); + public static final IntPref AnalyzerWidth = new IntPref("AnalyzerWidth", 0, -1, 65535); /** * The latest height of the Alloy Analyzer's main window. */ - public static final IntPref AnalyzerHeight = new IntPref("AnalyzerHeight", 0, -1, 65535); + public static final IntPref AnalyzerHeight = new IntPref("AnalyzerHeight", 0, -1, 65535); /** The latest font size of the Alloy Analyzer. */ - public static final IntChoicePref FontSize = new IntChoicePref("FontSize", "Font size", Arrays.asList(9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 44, 48, 54, 60, 66, 72), 14); + public static final IntChoicePref FontSize = new IntChoicePref("FontSize", "Font size", Arrays.asList(9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 44, 48, 54, 60, 66, 72), 14); /** The latest font name of the Alloy Analyzer. */ - public static final StringChoicePref FontName = new StringChoicePref("FontName", "Font family", Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()), "Lucida Grande"); + public static final StringChoicePref FontName = new StringChoicePref("FontName", "Font family", Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()), "Lucida Grande"); /** The latest tab distance of the Alloy Analyzer. */ - public static final IntChoicePref TabSize = IntChoicePref.range("TabSize", "Tab size", 1, 1, 16, 4); + public static final IntChoicePref TabSize = IntChoicePref.range("TabSize", "Tab size", 1, 1, 16, 4); /** The latest welcome screen that the user has seen. */ - public static final BooleanPref Welcome = new BooleanPref("Welcome", "Show welcome message at start up"); + public static final BooleanPref Welcome = new BooleanPref("Welcome", "Show welcome message at start up"); /** Look and feel */ - public static final StringChoicePref LAF = new StringChoicePref("LAF", "Look and feel", Arrays.asList("Native", "Cross-platform"), Util.onMac() || Util.onWindows() ? "Native" : "Cross-platform"); + public static final StringChoicePref LAF = new StringChoicePref("LAF", "Look and feel", Arrays.asList("Native", "Cross-platform"), Util.onMac() || Util.onWindows() ? "Native" : "Cross-platform"); /** * Whether syntax highlighting should be disabled or not. */ - public static final BooleanPref SyntaxDisabled = new BooleanPref("SyntaxHighlightingDisabled", "Disable syntax highlighting"); + public static final BooleanPref SyntaxDisabled = new BooleanPref("SyntaxHighlightingDisabled", "Disable syntax highlighting"); /** The number of recursion unrolls. */ - public static final IntChoicePref Unrolls = new IntChoicePref("Unrolls", "Recursion depth", Arrays.asList(-1, 0, 1, 2, 3), -1) { + public static final IntChoicePref Unrolls = new IntChoicePref("Unrolls", "Recursion depth", Arrays.asList(-1, 0, 1, 2, 3), -1) { - @Override - public Object renderValueShort(Integer value) { - return (value != null && value.intValue() == -1) ? "disabled" : value; - } - }; + @Override + public Object renderValueShort(Integer value) { + return (value != null && value.intValue() == -1) ? "disabled" : value; + } + }; /** The skolem depth. */ - public static final IntChoicePref SkolemDepth = new IntChoicePref("SkolemDepth3", "Skolem depth", Arrays.asList(0, 1, 2, 3, 4), 1); + public static final IntChoicePref SkolemDepth = new IntChoicePref("SkolemDepth3", "Skolem depth", Arrays.asList(0, 1, 2, 3, 4), 1); /** The unsat core minimization strategy. */ - private static final String[] coreMinimizationLabels = new String[] { - "Slow", "Slow (guarantees local minimum)", "Medium", "Medium", "Fast", "Fast (initial unsat core)" + private static final String[] coreMinimizationLabels = new String[] { + "Slow", "Slow (guarantees local minimum)", "Medium", "Medium", "Fast", "Fast (initial unsat core)" }; - public static final IntChoicePref CoreMinimization = new IntChoicePref("CoreMinimization", "Unsat core minimization", Arrays.asList(0, 1, 2), 2) { + public static final IntChoicePref CoreMinimization = new IntChoicePref("CoreMinimization", "Unsat core minimization", Arrays.asList(0, 1, 2), 2) { - @Override - public Object renderValueShort(Integer value) { - return coreMinimizationLabels[value * 2]; - } + @Override + public Object renderValueShort(Integer value) { + return coreMinimizationLabels[value * 2]; + } - @Override - public Object renderValueLong(Integer value) { - return coreMinimizationLabels[value * 2 + 1]; - } - }; + @Override + public Object renderValueLong(Integer value) { + return coreMinimizationLabels[value * 2 + 1]; + } + }; - private static final String[] coreGranularityLabels = new String[] { - "Top-level", "Top-level conjuncts only", "Flatten once", "Flatten the formula once at the beginning", "Flatten twice", "Flatten the formula at the beginning and after skolemizing", "Expand quantifiers", "In addition to flattening the formula twice, expand the quantifiers" + private static final String[] coreGranularityLabels = new String[] { + "Top-level", "Top-level conjuncts only", "Flatten once", "Flatten the formula once at the beginning", "Flatten twice", "Flatten the formula at the beginning and after skolemizing", "Expand quantifiers", "In addition to flattening the formula twice, expand the quantifiers" }; /** The unsat core granularity. */ - public static final IntChoicePref CoreGranularity = new IntChoicePref("CoreGranularity", "Unsat core granularity", Arrays.asList(0, 1, 2, 3), 0) { + public static final IntChoicePref CoreGranularity = new IntChoicePref("CoreGranularity", "Unsat core granularity", Arrays.asList(0, 1, 2, 3), 0) { + + @Override + public Object renderValueShort(Integer value) { + return coreGranularityLabels[value * 2]; + } + + @Override + public Object renderValueLong(Integer value) { + return coreGranularityLabels[value * 2 + 1]; + } + }; + + /** The decompose solving strategy. */ + public static final ChoicePref DecomposePref = new ChoicePref("Decompose strategy", Decompose.values(), Decompose.OFF) { + + @Override + protected String serialize(Decompose value) { + return value.id; + } + }; + + public enum Decompose { + /** regular amalgamated strategy. */ + OFF("0", "batch"), + /** hybrid strategy, competitive parallel vs amalgamated. */ + HYBRID("1", "hybrid"), + /** purely parallel decompose strategy. */ + PARALLEL("2", "parallel"); + + /** Returns true if it is greater than or equal to "other". */ + public boolean geq(Decompose other) { + return ordinal() >= other.ordinal(); + } - @Override - public Object renderValueShort(Integer value) { - return coreGranularityLabels[value * 2]; - } + /** + * This is a unique String for this value; it should be kept consistent in + * future versions. + */ + private final String id; + /** This is the label that the toString() method will return. */ + private final String label; - @Override - public Object renderValueLong(Integer value) { - return coreGranularityLabels[value * 2 + 1]; - } - }; + /** Constructs a new Decompose value with the given id and label. */ + private Decompose(String id, String label) { + this.id = id; + this.label = label; + } + + /** Returns the human-readable label for this enum value. */ + @Override + public final String toString() { + return label; + } + } /** * The amount of memory (in M) to allocate for Kodkod and the SAT solvers. */ - public static final IntChoicePref SubMemory = new IntChoicePref("SubMemory", "Maximum memory", Arrays.asList(768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 8192, 16384), 2084) { + public static final IntChoicePref SubMemory = new IntChoicePref("SubMemory", "Maximum memory", Arrays.asList(768, 1024, 1536, 2048, 2560, 3072, 3584, 4096, 8192, 16384), 2084) { - @Override - public Object renderValueShort(Integer value) { - return value.toString() + " MB"; - } - }; + @Override + public Object renderValueShort(Integer value) { + return value.toString() + " MB"; + } + }; /** * The amount of stack (in K) to allocate for Kodkod and the SAT solvers. */ - public static final IntChoicePref SubStack = new IntChoicePref("SubStack", "Maximum stack", Arrays.asList(1024, 2048, 4096, 8192, 16384, 32768, 65536), 8192) { + public static final IntChoicePref SubStack = new IntChoicePref("SubStack", "Maximum stack", Arrays.asList(1024, 2048, 4096, 8192, 16384, 32768, 65536), 8192) { - @Override - public Object renderValueShort(Integer value) { - return value.toString() + " k"; - } - }; + @Override + public Object renderValueShort(Integer value) { + return value.toString() + " k"; + } + }; /** * The first file in Alloy Analyzer's "open recent" list. */ - public static final StringPref Model0 = new StringPref("Model0"); + public static final StringPref Model0 = new StringPref("Model0"); /** * The second file in Alloy Analyzer's "open recent" list. */ - public static final StringPref Model1 = new StringPref("Model1"); + public static final StringPref Model1 = new StringPref("Model1"); /** * The third file in Alloy Analyzer's "open recent" list. */ - public static final StringPref Model2 = new StringPref("Model2"); + public static final StringPref Model2 = new StringPref("Model2"); /** * The fourth file in Alloy Analyzer's "open recent" list. */ - public static final StringPref Model3 = new StringPref("Model3"); + public static final StringPref Model3 = new StringPref("Model3"); /** Automatically infer partial instance from model */ - public static final BooleanPref InferPartialInstance = new BooleanPref("InferPartialInstance", "Infer partial instance"); + public static final BooleanPref InferPartialInstance = new BooleanPref("InferPartialInstance", "Infer partial instance"); - public static final DelayedChoicePref Solver = new DelayedChoicePref("SatSolver2", "Solver", SatSolver.values(), SatSolver.SAT4J) { + public static final DelayedChoicePref Solver = new DelayedChoicePref("SatSolver2", "Solver", SatSolver.values(), SatSolver.SAT4J) { - @Override - protected String serialize(SatSolver value) { - return value.id(); - } - }; + @Override + protected String serialize(SatSolver value) { + return value.id(); + } + }; - public static final ChoicePref VerbosityPref = new ChoicePref("Verbosity", Verbosity.values(), Verbosity.DEFAULT) { + public static final ChoicePref VerbosityPref = new ChoicePref("Verbosity", Verbosity.values(), Verbosity.DEFAULT) { - @Override - protected String serialize(Verbosity value) { - return value.id; - } - }; + @Override + protected String serialize(Verbosity value) { + return value.id; + } + }; public enum Verbosity { /** Level 0. */ @@ -728,7 +790,8 @@ public final String toString() { if (Pref.class.isAssignableFrom(f.getType())) { try { ans.add((Pref< ? >) f.get(self)); - } catch (Exception e) {} + } catch (Exception e) { + } } } return ans; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Reporter.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Reporter.java index f17136509..c452fc9e4 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Reporter.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/A4Reporter.java @@ -19,6 +19,11 @@ * This class receives diagnostic, progress, and warning messages from Alloy4. * (This default implementation ignores all calls; you should subclass it to do * the appropriate screen output) + * + * @modified [electrum] the solving process now reports in which step of the + * temporal analysis is (reported info should regard that step only) + * and the decompose strategy; translation also reports temporal + * parameters (max/min trace length) */ public class A4Reporter { @@ -106,26 +111,30 @@ public void bound(String msg) { * @param solver - the solver chosen by the user (eg. SAT4J, MiniSat...) * @param bitwidth - the integer bitwidth chosen by the user * @param maxseq - the scope on seq/Int chosen by the user + * @param mintrace - the minimum trace length + * @param maxtrace - the maximum trace length * @param skolemDepth - the skolem function depth chosen by the user (0, 1, * 2...) * @param symmetry - the amount of symmetry breaking chosen by the user (0...) + * @param strat - selected decompose solving strategy */ - public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) { + public void translate(String solver, int bitwidth, int maxseq, int mintrace, int maxtrace, int skolemDepth, int symmetry, String strat) { if (parent != null) - parent.translate(solver, bitwidth, maxseq, skolemDepth, symmetry); + parent.translate(solver, bitwidth, maxseq, mintrace, maxtrace, skolemDepth, symmetry, strat); } /** * This method is called by the translator just after it generated the CNF. * + * @param plength - the prefix length considered for this analysis * @param primaryVars - the total number of primary variables * @param totalVars - the total number of variables including the number of * primary variables * @param clauses - the total number of clauses */ - public void solve(int primaryVars, int totalVars, int clauses) { + public void solve(int plength, int primaryVars, int totalVars, int clauses) { if (parent != null) - parent.solve(primaryVars, totalVars, clauses); + parent.solve(plength, primaryVars, totalVars, clauses); } /** diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurConsole.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurConsole.java index ed9e5b9aa..fc2d3102a 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurConsole.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurConsole.java @@ -66,6 +66,11 @@ * be displayed in red. *

* Thread Safety: Can be called only by the AWT event thread. + * + * @modified [electrum] the evaluator now acts on the current state focused on + * the visualizer (temporal formulas can still be evaluated, but + * always from the focused state); this info is updated by the VizGUI + * and passed along to the computer */ public final class OurConsole extends JScrollPane { @@ -121,7 +126,10 @@ public final class OurConsole extends JScrollPane { /** * The position in this.history that is currently showing. */ - private int browse = 0; + private int browse = 0; + + /** The current state under which to evaluate user commands. */ + private int current = 0; /* * Helper method that construct a mutable style with the given font name, font @@ -379,7 +387,9 @@ private void do_command(Computer computer, String cmd) { boolean isBad = false; Object result; try { - result = computer.compute(cmd); + result = computer.compute(new String[] { + cmd, current + "" + }); } catch (Throwable ex) { result = ex.toString(); isBad = true; @@ -428,6 +438,12 @@ private void do_add(int where, String text, AttributeSet style) { main.getCaret().setSelectionVisible(false); } else doc.insertString(where >= 0 ? where : doc.getLength(), text, style); - } catch (BadLocationException ex) {} + } catch (BadLocationException ex) { + } + } + + /** Set the current state under which to evaluate the user command. */ + public void setCurrentState(int state) { + current = state; } } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurSyntaxDocument.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurSyntaxDocument.java index 219cbe557..eeb66807e 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurSyntaxDocument.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/OurSyntaxDocument.java @@ -39,6 +39,9 @@ * Graphical syntax-highlighting StyledDocument. *

* Thread Safety: Can be called only by the AWT event thread + * + * @modified [electrum] added the new language keywords; forbid primes in + * identifiers */ class OurSyntaxDocument extends DefaultStyledDocument { @@ -180,7 +183,7 @@ class OurSyntaxDocument extends DefaultStyledDocument { * This stores the currently recognized set of reserved keywords. */ private static final String[] keywords = new String[] { - "abstract", "all", "and", "as", "assert", "but", "check", "disj", "disjoint", "else", "enum", "exactly", "exh", "exhaustive", "expect", "extends", "fact", "for", "fun", "iden", "iff", "implies", "in", "Int", "int", "let", "lone", "module", "no", "none", "not", "one", "open", "or", "part", "partition", "pred", "private", "run", "seq", "set", "sig", "some", "String", "sum", "this", "univ" + "abstract", "var", "all", "and", "as", "assert", "but", "check", "disj", "disjoint", "else", "enum", "exactly", "exh", "exhaustive", "expect", "extends", "fact", "for", "fun", "iden", "iff", "implies", "in", "Int", "int", "let", "lone", "module", "no", "none", "not", "one", "open", "or", "part", "partition", "pred", "private", "run", "seq", "set", "sig", "some", "String", "sum", "this", "univ", "eventually", "always", "after", "once", "historically", "since", "triggered", "before", "until", "releases", "steps" }; /** @@ -188,7 +191,7 @@ class OurSyntaxDocument extends DefaultStyledDocument { * keyword. */ private static final boolean do_keyword(String array, int start, int len) { - if (len >= 2 && len <= 10) + if (len >= 2 && len <= 12) for (int i = keywords.length - 1; i >= 0; i--) { String str = keywords[i]; if (str.length() == len) @@ -205,7 +208,8 @@ else if (str.charAt(j) != array.charAt(start + j)) * Returns true if "c" can be in the start or middle or end of an identifier. */ private static final boolean do_iden(char c) { - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '$' || (c >= '0' && c <= '9') || c == '_' || c == '\'' || c == '\"'; + // [electrum] forbid primes in identifiers + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '$' || (c >= '0' && c <= '9') || c == '_' || c == '\"'; } /** Constructor. */ @@ -505,11 +509,13 @@ private final Mode do_reapply(Mode mode, final String txt, final int line) { } setCharacterAttributes(oldi, i - oldi, styleString, false); } else if (do_iden(c)) { - for (i++; i < n && do_iden(txt.charAt(i)); i++) {} + for (i++; i < n && do_iden(txt.charAt(i)); i++) { + } AttributeSet style = (c >= '0' && c <= '9') ? styleNumber : (do_keyword(txt, oldi, i - oldi) ? styleKeyword : styleNormal); setCharacterAttributes(oldi, i - oldi, style, false); } else { - for (i++; i < n && !do_iden(txt.charAt(i)) && txt.charAt(i) != '\n' && txt.charAt(i) != '-' && txt.charAt(i) != '/'; i++) {} + for (i++; i < n && !do_iden(txt.charAt(i)) && txt.charAt(i) != '\n' && txt.charAt(i) != '-' && txt.charAt(i) != '/'; i++) { + } setCharacterAttributes(oldi, i - oldi, styleSymbol, false); } } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/TableView.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/TableView.java index 79c38ee7f..c7a491ff8 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/TableView.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/TableView.java @@ -23,9 +23,15 @@ import edu.mit.csail.sdg.translator.A4Tuple; import edu.mit.csail.sdg.translator.A4TupleSet; import kodkod.instance.Instance; +import kodkod.instance.TemporalInstance; import kodkod.instance.Tuple; import kodkod.instance.TupleSet; +/** + * + * @modified [electrum] adapted to focus on particular state + * + */ public class TableView { final static String SUPERSCRIPTS = "⁰¹²³⁴⁵⁶⁷⁸⁹"; @@ -140,9 +146,11 @@ public static String revertSuffix(String cmd) { * @param solution * @param instance * @param sigs + * @param state * @return */ - public static Map toTable(A4Solution solution, Instance instance, SafeList sigs) { + // [electrum] added state to print, -1 for static + public static Map toTable(A4Solution solution, Instance instance, SafeList sigs, int state) { Map map = new HashMap(); @@ -151,11 +159,12 @@ public static Map toTable(A4Solution solution, Instance instance, if (!s.label.startsWith("this/")) continue; - TupleSet instanceTuples = instance.tuples(s.label); + TupleSet instanceTuples = (state > -1 ? ((TemporalInstance) instance).state(state) : instance).tuples(s.label); if (instanceTuples != null) { List instancesArray = toList(instanceTuples); Collections.sort(instancesArray, new Comparator() { + @Override public int compare(SimTuple simTuple1, SimTuple simTuple2) { String[] coll1 = simTuple1.get(0).toString().split("\\$"); @@ -163,8 +172,7 @@ public int compare(SimTuple simTuple1, SimTuple simTuple2) { if (coll1.length == 2 && coll2.length == 2) { try { return Integer.parseInt(coll1[1]) - Integer.parseInt(coll2[1]); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { return 0; } } @@ -194,7 +202,7 @@ public int compare(SimTuple simTuple1, SimTuple simTuple2) { c = 1; for (Field f : s.getFields()) { - SimTupleset relations = toSimTupleset(solution.eval(f)); + SimTupleset relations = toSimTupleset(state > -1 ? solution.eval(f, state) : solution.eval(f)); SimTupleset joined = leftJoin.join(relations); Table relationTable = toTable(joined); diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/WorkerEngine.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/WorkerEngine.java index 0483f039b..6d60a708c 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/WorkerEngine.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/alloy4/WorkerEngine.java @@ -47,8 +47,9 @@ * subsequent task; however, if the subprocess crashed, the crash will be * reported to the parent process via callback, and if we try to execute another * task, then a new subprocess will be spawned automatically. + * + * @modified [electrum] handle external executables */ - public final class WorkerEngine { /** @@ -180,8 +181,24 @@ private WorkerEngine() { public static void stop() { synchronized (WorkerEngine.class) { try { - if (latest_sub != null) + if (latest_sub != null) { + // [electrum] this replaces the currently WorkerTask so that it exits gracefully + try { + ObjectOutputStream main2sub = new ObjectOutputStream(wrap(latest_sub.getOutputStream())); + main2sub.writeObject(new WorkerTask() { + + private static final long serialVersionUID = 1L; + + @Override + public void run(WorkerCallback out) throws Exception { + } + }); + main2sub.close(); + } catch (IOException e) { + } + latest_sub.destroy(); + } } finally { latest_manager = null; latest_sub = null; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Attr.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Attr.java index 4b0172909..47357c89b 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Attr.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Attr.java @@ -20,6 +20,9 @@ /** * Immutable; represents attributes that can be associated with Signatures and * some other AST objects. + * + * @modified [electrum] added a new attribute AST objects, whether they are + * variable/mutable in time */ public final class Attr { @@ -86,7 +89,13 @@ public enum AttrType { * ENUM; if a PrimSig has the ENUM attribute, it is toplevel and abstract and * has only singleton children. */ - ENUM("enum"); + ENUM("enum"), + + /** + * VARIABLE; if a Sig has the VARIABLE attribute, it means its value may change + * over time. + */ + VARIABLE("variable"); /** The label for this attribute type. */ private final String label; @@ -194,6 +203,9 @@ public final String toString() { */ public static final Attr ENUM = new Attr(AttrType.ENUM, null); + /** VARIABLE; if a Sig is variable, changing in time. */ + public static final Attr VARIABLE = new Attr(AttrType.VARIABLE, null); + /** * Construct an attribute of the given type with the given position; if * pos==null, it is treated as Pos.UNKNOWN. diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Command.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Command.java index 17347559b..3e39158fc 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Command.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Command.java @@ -39,6 +39,16 @@ * Invariant: maxseq >= -1 *

* Invariant: maxstring >= -1 + *

+ * Invariant: minprefix == -1 or >= 1 + *

+ * Invariant: maxprefix == -1 or >= 1 + * + * @modified [electrum] added two special scopes to commands, the minimum and + * maximum trace prefix lengths to be considered during analysis; when + * they are omitted, defaults to -1; also, for complement model + * checking (unbounded max prefix length), the max length is assumed + * to be MAX_INTEGER */ public final class Command extends Browsable { @@ -78,6 +88,18 @@ public final class Command extends Browsable { */ public final int maxseq; + /** + * The minimum trace prefix length (1 or higher) (Or -1 if it was not + * specified). + */ + public final int minprefix; + + /** + * The maximum trace prefix length (1 or higher) (Or -1 if it was not + * specified). + */ + public final int maxprefix; + /** * The number of String atoms to allocate (0 or higher) (Or -1 if it was not * specified). @@ -116,11 +138,11 @@ public final String toString() { } boolean first = true; StringBuilder sb = new StringBuilder(check ? "Check " : "Run ").append(label); - if (overall >= 0 && (bitwidth >= 0 || maxseq >= 0 || scope.size() > 0)) + if (overall >= 0 && (bitwidth >= 0 || maxseq >= 0 || scope.size() > 0 || minprefix >= 0 || maxprefix >= 0)) sb.append(" for ").append(overall).append(" but"); else if (overall >= 0) sb.append(" for ").append(overall); - else if (bitwidth >= 0 || maxseq >= 0 || scope.size() > 0) + else if (bitwidth >= 0 || maxseq >= 0 || scope.size() > 0 || minprefix >= 0 || maxprefix >= 0) sb.append(" for"); if (bitwidth >= 0) { sb.append(" ").append(bitwidth).append(" int"); @@ -130,6 +152,15 @@ else if (bitwidth >= 0 || maxseq >= 0 || scope.size() > 0) sb.append(first ? " " : ", ").append(maxseq).append(" seq"); first = false; } + if (maxprefix >= 0) { + sb.append(" "); + if (minprefix >= 0) + sb.append(minprefix).append(".."); + if (maxprefix != Integer.MAX_VALUE) + sb.append(maxprefix); + sb.append(" steps"); + first = false; + } for (CommandScope e : scope) { sb.append(first ? " " : ", ").append(e); first = false; @@ -152,7 +183,7 @@ else if (bitwidth >= 0 || maxseq >= 0 || scope.size() > 0) * @param formula - the formula that must be satisfied by this command */ public Command(boolean check, int overall, int bitwidth, int maxseq, Expr formula) throws ErrorSyntax { - this(null, null, "", check, overall, bitwidth, maxseq, -1, null, null, formula, null); + this(null, null, "", check, overall, bitwidth, maxseq, -1, -1, -1, null, null, formula, null); } /** @@ -168,6 +199,10 @@ public Command(boolean check, int overall, int bitwidth, int maxseq, Expr formul * specified) * @param maxseq - the maximum sequence length (0 or higher) (-1 if it was not * specified) + * @param minprefix - the minimal trace prefix length (0 or higher) (-1 if it + * was not specified) + * @param maxprefix - the maximal trace prefix length (0 or higher) (-1 if it + * was not specified) * @param expects - the expected value (0 or 1) (-1 if no expectation was * specified) * @param scope - a list of scopes (can be null if we want to use default) @@ -175,7 +210,7 @@ public Command(boolean check, int overall, int bitwidth, int maxseq, Expr formul * exact though we may or may not know what the scope is yet * @param formula - the formula that must be satisfied by this command */ - public Command(Pos pos, Expr e, String label, boolean check, int overall, int bitwidth, int maxseq, int expects, Iterable scope, Iterable additionalExactSig, Expr formula, Command parent) { + public Command(Pos pos, Expr e, String label, boolean check, int overall, int bitwidth, int maxseq, int minprefix, int maxprefix, int expects, Iterable scope, Iterable additionalExactSig, Expr formula, Command parent) { if (pos == null) pos = Pos.UNKNOWN; this.nameExpr = e; @@ -186,6 +221,8 @@ public Command(Pos pos, Expr e, String label, boolean check, int overall, int bi this.overall = (overall < 0 ? -1 : overall); this.bitwidth = (bitwidth < 0 ? -1 : bitwidth); this.maxseq = (maxseq < 0 ? -1 : maxseq); + this.maxprefix = (maxprefix < 1 ? -1 : maxprefix); + this.minprefix = (minprefix < 1 ? -1 : minprefix); this.maxstring = (-1); this.expects = (expects < 0 ? -1 : (expects > 0 ? 1 : 0)); this.scope = ConstList.make(scope); @@ -198,7 +235,7 @@ public Command(Pos pos, Expr e, String label, boolean check, int overall, int bi * except with a different formula. */ public Command change(Expr newFormula) { - return new Command(pos, nameExpr, label, check, overall, bitwidth, maxseq, expects, scope, additionalExactScopes, newFormula, parent); + return new Command(pos, nameExpr, label, check, overall, bitwidth, maxseq, minprefix, maxprefix, expects, scope, additionalExactScopes, newFormula, parent); } /** @@ -206,7 +243,7 @@ public Command change(Expr newFormula) { * except with a different scope. */ public Command change(ConstList scope) { - return new Command(pos, nameExpr, label, check, overall, bitwidth, maxseq, expects, scope, additionalExactScopes, formula, parent); + return new Command(pos, nameExpr, label, check, overall, bitwidth, maxseq, minprefix, maxprefix, expects, scope, additionalExactScopes, formula, parent); } /** @@ -214,7 +251,7 @@ public Command change(ConstList scope) { * except with a different list of "additional exact sigs". */ public Command change(Sig... additionalExactScopes) { - return new Command(pos, nameExpr, label, check, overall, bitwidth, maxseq, expects, scope, Util.asList(additionalExactScopes), formula, parent); + return new Command(pos, nameExpr, label, check, overall, bitwidth, maxseq, minprefix, maxprefix, expects, scope, Util.asList(additionalExactScopes), formula, parent); } /** diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Decl.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Decl.java index 40e4b182f..37c5b1d32 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Decl.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Decl.java @@ -22,6 +22,11 @@ /** * Immutable; this declaration binds a list of names to an expression. + * + * @modified [electrum] added a new attribute to declarations, whether a + * variable/mutable expression is being declared. this is used for the + * declaration of variable fields (declarations elsewhere cannot be + * variable). */ public final class Decl { @@ -44,6 +49,11 @@ public final class Decl { */ public final Pos disjoint2; + /** + * Nonnull if this decl is variable (to be used for fields). + */ + public final Pos isVar; + /** The list of names. */ public final ConstList< ? extends ExprHasName> names; @@ -71,10 +81,11 @@ public Pos span() { /** * This constructs a declaration; the list of names must not be empty. */ - public Decl(Pos isPrivate, Pos disjoint, Pos disjoint2, List< ? extends ExprHasName> names, Expr expr) { + public Decl(Pos isPrivate, Pos disjoint, Pos disjoint2, Pos isVar, List< ? extends ExprHasName> names, Expr expr) { if (names.size() == 0) throw new NullPointerException(); this.isPrivate = isPrivate; + this.isVar = isVar; this.disjoint = (names.size() > 1 ? disjoint : null); this.disjoint2 = disjoint2; this.names = ConstList.make(names); diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Expr.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Expr.java index 5bb5ff747..336c82466 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Expr.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Expr.java @@ -40,6 +40,12 @@ * Invariant: type==EMPTY iff errors.size()>0
* Invariant: mult==0 || mult==1 || mult==2
* Invariant: weight>0 + * + * @modified [electrum] adds convenience methods to create temporal formulas + * (unary always, eventually, after, once, historically, before and + * binary until, releases, since, triggered) and expressions (primes); + * also update Decl creations which are always immutable (null isVar) + * in this context */ public abstract class Expr extends Browsable { @@ -982,7 +988,7 @@ public final Expr someOf() { public final Decl someOf(String label) throws Err { Expr x = ExprUnary.Op.SOMEOF.make(span(), this); ExprVar v = ExprVar.make(x.span(), label, type); - return new Decl(null, null, null, Arrays.asList(v), x); + return new Decl(null, null, null, null, Arrays.asList(v), x); } /** @@ -1004,7 +1010,7 @@ public final Expr loneOf() { public final Decl loneOf(String label) throws Err { Expr x = ExprUnary.Op.LONEOF.make(span(), this); ExprVar v = ExprVar.make(x.span(), label, type); - return new Decl(null, null, null, Arrays.asList(v), x); + return new Decl(null, null, null, null, Arrays.asList(v), x); } /** @@ -1026,7 +1032,7 @@ public final Expr oneOf() { public final Decl oneOf(String label) throws Err { Expr x = ExprUnary.Op.ONEOF.make(span(), this); ExprVar v = ExprVar.make(x.span(), label, type); - return new Decl(null, null, null, Arrays.asList(v), x); + return new Decl(null, null, null, null, Arrays.asList(v), x); } /** @@ -1048,7 +1054,7 @@ public final Expr setOf() { public final Decl setOf(String label) throws Err { Expr x = ExprUnary.Op.SETOF.make(span(), this); ExprVar v = ExprVar.make(x.span(), label, type); - return new Decl(null, null, null, Arrays.asList(v), x); + return new Decl(null, null, null, null, Arrays.asList(v), x); } /** @@ -1151,6 +1157,117 @@ public final Expr cast2sigint() { return ExprUnary.Op.CAST2SIGINT.make(span(), this); } + /** + * Returns the formula (always this) + *

+ * this must be a formula + */ + public final Expr always() { + return ExprUnary.Op.ALWAYS.make(span(), this); + } + + /** + * Returns the formula (eventually this) + *

+ * this must be a formula + */ + public final Expr eventually() { + return ExprUnary.Op.EVENTUALLY.make(span(), this); + } + + /** + * Returns the formula (after this) + *

+ * this must be a formula + */ + public final Expr after() { + return ExprUnary.Op.AFTER.make(span(), this); + } + + /** + * Returns the formula (before this) + *

+ * this must be a formula + */ + public final Expr before() { + return ExprUnary.Op.BEFORE.make(span(), this); + } + + /** + * Returns the formula (historically this) + *

+ * this must be a formula + */ + public final Expr historically() { + return ExprUnary.Op.HISTORICALLY.make(span(), this); + } + + /** + * Returns the formula (once this) + *

+ * this must be a formula + */ + public final Expr once() { + return ExprUnary.Op.ONCE.make(span(), this); + } + + /** + * Returns the formula (this until x) + *

+ * this and x must both be formulas + *

+ * Note: as a special guarantee, if x==null, then the method will return this + * Expr object as-is. + */ + public final Expr until(Expr x) { + return (x == null) ? this : ExprBinary.Op.UNTIL.make(span().merge(x.span()), null, this, x); + } + + /** + * Returns the formula (this releases x) + *

+ * this and x must both be formulas + *

+ * Note: as a special guarantee, if x==null, then the method will return this + * Expr object as-is. + */ + public final Expr releases(Expr x) { + return (x == null) ? this : ExprBinary.Op.RELEASES.make(span().merge(x.span()), null, this, x); + } + + /** + * Returns the formula (this since x) + *

+ * this and x must both be formulas + *

+ * Note: as a special guarantee, if x==null, then the method will return this + * Expr object as-is. + */ + public final Expr since(Expr x) { + return (x == null) ? this : ExprBinary.Op.SINCE.make(span().merge(x.span()), null, this, x); + } + + /** + * Returns the formula (this triggered x) + *

+ * this and x must both be formulas + *

+ * Note: as a special guarantee, if x==null, then the method will return this + * Expr object as-is. + */ + public final Expr triggered(Expr x) { + return (x == null) ? this : ExprBinary.Op.TRIGGERED.make(span().merge(x.span()), null, this, x); + } + + /** + * Returns the expression (this') + *

+ * this must be a set or relation + */ + public final Expr prime() { + return ExprUnary.Op.PRIME.make(span(), this); + } + /** * Get the position where this expression is referring to or null if it is not * referring to anything. diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprBinary.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprBinary.java index c4123a64f..83fc6d5c5 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprBinary.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprBinary.java @@ -49,6 +49,9 @@ *

* Invariant: type!=EMPTY => (right.mult==2 => (this.op==IN || this.op is * one of the 17 arrow operators)) + * + * @modified [electrum] add binary temporal operators (until, releases, since, + * triggered) to the AST */ public final class ExprBinary extends Expr { @@ -257,7 +260,15 @@ public static enum Op { /** || */ OR("||", false), /** <=> */ - IFF("<=>", false); + IFF("<=>", false), + /** until; */ + UNTIL("until", false), + /** release; */ + RELEASES("releases", false), + /** since; */ + SINCE("since", false), + /** trigger */ + TRIGGERED("triggered", false); /** * The constructor. @@ -319,7 +330,11 @@ public final Expr make(Pos pos, Pos closingBracket, Expr left, Expr right) { break; } case IFF : - case IMPLIES : { + case IMPLIES : + case UNTIL : + case RELEASES : + case SINCE : + case TRIGGERED : { left = left.typecheck_as_formula(); right = right.typecheck_as_formula(); break; @@ -374,6 +389,10 @@ public final Expr make(Pos pos, Pos closingBracket, Expr left, Expr right) { case OR : case IFF : case IMPLIES : + case UNTIL : + case RELEASES : + case SINCE : + case TRIGGERED : type = Type.FORMULA; break; case MUL : @@ -489,7 +508,11 @@ public Expr resolve(Type p, Collection warns) { case AND : case OR : case IFF : - case IMPLIES : { + case IMPLIES : + case UNTIL : + case RELEASES : + case SINCE : + case TRIGGERED : { a = (b = Type.FORMULA); break; } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprCall.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprCall.java index e6d858cf2..14c421bde 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprCall.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprCall.java @@ -36,6 +36,8 @@ * Immutable; represents a call. *

* Invariant: type!=EMPTY => (all x:args | x.mult==0) + * + * @modified [electrum] add temporal operators to type inference */ public final class ExprCall extends Expr { @@ -107,7 +109,8 @@ private static final class DeduceType extends VisitReturn { private final Env env = new Env(); - private DeduceType() {} + private DeduceType() { + } @Override public Type visit(ExprITE x) throws Err { @@ -131,6 +134,10 @@ public Type visit(ExprBinary x) throws Err { case IN : case OR : case AND : + case UNTIL : + case RELEASES : + case SINCE : + case TRIGGERED : case NOT_LT : case NOT_GT : case NOT_LTE : @@ -189,6 +196,7 @@ public Type visit(ExprUnary x) throws Err { case SETOF : case SOMEOF : case EXACTLYOF : + case PRIME : return t; case CARDINALITY : case CAST2INT : diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprQt.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprQt.java index 40244a9c3..3d1c76a4e 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprQt.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprQt.java @@ -46,6 +46,9 @@ *
* Invariant: type!=EMPTY => sub.mult==0
* Invariant: type!=EMPTY => vars.size()>0 + * + * @modified [electrum] adapt the creation of the Decl, always immutable (null + * isVar) in this context */ public final class ExprQt extends Expr { @@ -316,7 +319,7 @@ public Expr desugar() throws ErrorSyntax { continue; } guard = ExprList.makeDISJOINT(d.disjoint, null, d.names).and(guard); - newdecls.add(new Decl(null, null, null, d.names, d.expr)); + newdecls.add(new Decl(null, null, null, null, d.names, d.expr)); } if (guard == null) return this; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprUnary.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprUnary.java index d49478517..76c3273a0 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprUnary.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/ExprUnary.java @@ -38,6 +38,10 @@ * Immutable; represents a unary expression of the form "(OP subexpression)" *

* Invariant: type!=EMPTY => sub.mult==0 + * + * @modified [electrum] add unary temporal ops for formulas (after, always, + * eventually, before, historically, once) and expressions (primes) to + * the AST */ public final class ExprUnary extends Expr { @@ -98,6 +102,11 @@ public void toString(StringBuilder out, int indent) { sub.toString(out, -1); out.append(']'); return; + case PRIME : + out.append('('); + sub.toString(out, -1); + out.append(")'"); + return; case NOOP : break; default : @@ -158,6 +167,18 @@ public enum Op { EXACTLYOF("exactly of"), /** not f (where f is a formula) */ NOT("!"), + /** after f (where f is a formula) */ + AFTER("after"), + /** always f (where f is a formula) */ + ALWAYS("always"), + /** eventually f (where f is a formula) */ + EVENTUALLY("eventually"), + /** before f (where f is a formula) */ + BEFORE("before"), + /** historically f (where f is a formula) */ + HISTORICALLY("historically"), + /** once f (where f is a formula) */ + ONCE("once"), /** no x (where x is a set or relation) */ NO("no"), /** some x (where x is a set or relation) */ @@ -168,6 +189,8 @@ public enum Op { ONE("one"), /** transpose */ TRANSPOSE("~"), + /** post */ + PRIME("\'"), /** reflexive closure */ RCLOSURE("*"), /** closure */ @@ -256,6 +279,12 @@ public final Expr make(Pos pos, Expr sub, Err extraError, long extraWeight) { case NOOP : break; case NOT : + case AFTER : + case ALWAYS : + case EVENTUALLY : + case BEFORE : + case HISTORICALLY : + case ONCE : sub = sub.typecheck_as_formula(); break; case CAST2SIGINT : @@ -298,6 +327,12 @@ public final Expr make(Pos pos, Expr sub, Err extraError, long extraWeight) { case SOME : case LONE : case ONE : + case AFTER : + case ALWAYS : + case EVENTUALLY : + case BEFORE : + case HISTORICALLY : + case ONCE : type = Type.FORMULA; break; case TRANSPOSE : @@ -357,6 +392,12 @@ public Expr resolve(Type p, Collection warns) { Type s = p; switch (op) { case NOT : + case AFTER : + case ALWAYS : + case EVENTUALLY : + case BEFORE : + case HISTORICALLY : + case ONCE : s = Type.FORMULA; break; case TRANSPOSE : diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Sig.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Sig.java index b57b1d9d0..211040e65 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Sig.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/ast/Sig.java @@ -34,24 +34,30 @@ import edu.mit.csail.sdg.alloy4.Version; import edu.mit.csail.sdg.ast.Attr.AttrType; -/** Mutable; represents a signature. */ - +/** + * Mutable; represents a signature. + * + * @modified [electrum] support the creation of variable/mutable sigs and + * fields; constructors adapted accordingly, as are the creation of + * Decl objects (in this case only those of tricky fields are ever + * variable, the ones arising from parsed field declarations) + */ public abstract class Sig extends Expr implements Clause { /** The built-in "univ" signature. */ - public static final PrimSig UNIV = new PrimSig("univ", null, false); + public static final PrimSig UNIV = new PrimSig("univ", null, true, false); /** The built-in "Int" signature. */ - public static final PrimSig SIGINT = new PrimSig("Int", UNIV, false); + public static final PrimSig SIGINT = new PrimSig("Int", UNIV, false, false); /** The built-in "seq/Int" signature. */ - public static final PrimSig SEQIDX = new PrimSig("seq/Int", SIGINT, true); + public static final PrimSig SEQIDX = new PrimSig("seq/Int", SIGINT, false, true); /** The built-in "String" signature. */ - public static final PrimSig STRING = new PrimSig("String", UNIV, true); + public static final PrimSig STRING = new PrimSig("String", UNIV, false, true); /** The built-in "none" signature. */ - public static final PrimSig NONE = new PrimSig("none", null, false); + public static final PrimSig NONE = new PrimSig("none", null, false, false); /** The built-in "none" signature. */ public static final PrimSig GHOST = mkGhostSig(); @@ -215,6 +221,11 @@ public final T accept(VisitReturn visitor) throws Err { */ public final Pos isMeta; + /** + * Nonnull if this sig is variable. + */ + public final Pos isVariable; + /** * The label for this sig; this name does not need to be unique. */ @@ -240,11 +251,11 @@ public final boolean isTopLevel() { } /** Constructs a new builtin PrimSig. */ - private Sig(String label) { + private Sig(String label, boolean var) { super(Pos.UNKNOWN, null); Expr oneof = ExprUnary.Op.ONEOF.make(null, this); ExprVar v = ExprVar.make(null, "this", oneof.type); - this.decl = new Decl(null, null, null, Util.asList(v), oneof); + this.decl = new Decl(null, null, null, null, Util.asList(v), oneof); this.builtin = true; this.isAbstract = null; this.isLone = null; @@ -256,6 +267,7 @@ private Sig(String label) { this.isPrivate = null; this.isMeta = null; this.isEnum = null; + this.isVariable = var ? Pos.UNKNOWN : null; this.attributes = ConstList.make(); } @@ -265,9 +277,9 @@ private Sig(Type type, String label, Attr... attributes) throws Err { this.attributes = Util.asList(attributes); Expr oneof = ExprUnary.Op.ONEOF.make(null, this); ExprVar v = ExprVar.make(null, "this", oneof.type); - this.decl = new Decl(null, null, null, Util.asList(v), oneof); + this.decl = new Decl(null, null, null, null, Util.asList(v), oneof); Pos isAbstract = null, isLone = null, isOne = null, isSome = null, isSubsig = null, isSubset = null, - isPrivate = null, isMeta = null, isEnum = null; + isPrivate = null, isMeta = null, isEnum = null, isVariable = null; for (Attr a : attributes) if (a != null) switch (a.type) { @@ -298,6 +310,9 @@ private Sig(Type type, String label, Attr... attributes) throws Err { case SUBSIG : isSubsig = a.pos.merge(isSubsig); break; + case VARIABLE : + isVariable = a.pos.merge(isVariable); + break; default : //TODO throw new ErrorWarning("Undefined case " + a); } @@ -310,6 +325,7 @@ private Sig(Type type, String label, Attr... attributes) throws Err { this.isSome = isSome; this.isSubset = isSubset; this.isSubsig = isSubsig; + this.isVariable = isVariable; this.label = label; this.builtin = false; if (isLone != null && isOne != null) @@ -454,8 +470,8 @@ public Iterable descendents() throws Err { public final PrimSig parent; /** Constructs a builtin PrimSig. */ - private PrimSig(String label, PrimSig parent, boolean add) { - super(label); + private PrimSig(String label, PrimSig parent, boolean var, boolean add) { + super(label, var); this.parent = parent; if (add) this.parent.children.add(this); @@ -671,6 +687,9 @@ public static final class Field extends ExprHasName implements Clause { /** Nonnull if this field is a meta field. */ public final Pos isMeta; + /** Nonnull if this field is variable. */ + public final Pos isVariable; + /** True if this is a defined field. */ public final boolean defined; @@ -683,7 +702,7 @@ public Decl decl() { } /** Constructs a new Field object. */ - private Field(Pos pos, Pos isPrivate, Pos isMeta, Pos disjoint, Pos disjoint2, Sig sig, String label, Expr bound) throws Err { + private Field(Pos pos, Pos isPrivate, Pos isMeta, Pos disjoint, Pos disjoint2, Pos isVar, Sig sig, String label, Expr bound) throws Err { super(pos, label, sig.type.product(bound.type)); this.defined = bound.mult() == ExprUnary.Op.EXACTLYOF; if (sig.builtin) @@ -696,6 +715,7 @@ private Field(Pos pos, Pos isPrivate, Pos isMeta, Pos disjoint, Pos disjoint2, S throw new ErrorType(pos, "Cannot bind field " + label + " to the empty set or empty relation."); this.isPrivate = (isPrivate != null ? isPrivate : sig.isPrivate); this.isMeta = (isMeta != null ? isMeta : sig.isMeta); + this.isVariable = isVar; this.sig = sig; } @@ -817,8 +837,8 @@ public final Field addField(String label, Expr bound) throws Err { // multiplicity // symbol, we assume // it's oneOf - final Field f = new Field(null, null, null, null, null, this, label, bound); - final Decl d = new Decl(null, null, null, Arrays.asList(f), bound); + final Field f = new Field(null, null, null, null, null, null, this, label, bound); + final Decl d = new Decl(null, null, null, null, Arrays.asList(f), bound); f.decl = d; fields.add(d); realFields.add(f); @@ -837,6 +857,7 @@ public final Field addField(String label, Expr bound) throws Err { * "private" * @param isMeta - if nonnull, that means the user intended this field to be * "meta" + * @param isVar - if nonnull, then this field has been declared as variable * @param labels - the names of the fields to be added (these names does not * need to be unique) * @param bound - the new field will be bound by "all x: one ThisSig | @@ -846,7 +867,7 @@ public final Field addField(String label, Expr bound) throws Err { * @throws ErrorType if the bound is not fully typechecked or is not a * set/relation */ - public final Field[] addTrickyField(Pos pos, Pos isPrivate, Pos isDisjoint, Pos isDisjoint2, Pos isMeta, String[] labels, Expr bound) throws Err { + public final Field[] addTrickyField(Pos pos, Pos isPrivate, Pos isDisjoint, Pos isDisjoint2, Pos isMeta, Pos isVar, String[] labels, Expr bound) throws Err { bound = bound.typecheck_as_set(); if (bound.ambiguous) bound = bound.resolve_as_set(null); @@ -857,8 +878,8 @@ public final Field[] addTrickyField(Pos pos, Pos isPrivate, Pos isDisjoint, Pos // it's oneOf final Field[] f = new Field[labels.length]; for (int i = 0; i < f.length; i++) - f[i] = new Field(pos, isPrivate, isMeta, isDisjoint, isDisjoint2, this, labels[i], bound); - final Decl d = new Decl(isPrivate, isDisjoint, isDisjoint2, Arrays.asList(f), bound); + f[i] = new Field(pos, isPrivate, isMeta, isDisjoint, isDisjoint2, isVar, this, labels[i], bound); + final Decl d = new Decl(isPrivate, isDisjoint, isDisjoint2, isVar, Arrays.asList(f), bound); for (int i = 0; i < f.length; i++) { f[i].decl = d; realFields.add(f[i]); @@ -896,8 +917,8 @@ public final Field addDefinedField(Pos pos, Pos isPrivate, Pos isMeta, String la bound = bound.resolve_as_set(null); if (bound.mult() != ExprUnary.Op.EXACTLYOF) bound = ExprUnary.Op.EXACTLYOF.make(null, bound); - final Field f = new Field(pos, isPrivate, isMeta, null, null, this, label, bound); - final Decl d = new Decl(null, null, null, Arrays.asList(f), bound); + final Field f = new Field(pos, isPrivate, isMeta, null, null, null, this, label, bound); + final Decl d = new Decl(null, null, null, null, Arrays.asList(f), bound); f.decl = d; fields.add(d); realFields.add(f); diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.cup b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.cup index bee7d3214..7d4f26005 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.cup +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.cup @@ -59,6 +59,15 @@ import edu.mit.csail.sdg.ast.ExprVar; import edu.mit.csail.sdg.ast.Sig; import edu.mit.csail.sdg.ast.Sig.PrimSig; +// @modified [electrum] added temporal operators to the AST (unary temporal operators +// have the same precedence as other unary operators, binary ones have the +// highest precedence); also added a trace sequence operator which has the +// lowest precedence (not actually translated into AST but expanded during +// parsing) added time scopes to commands (reused scope ranges but extended +// to open ranges); support for open ended time scopes; additional syntax +// errors: trace scope increments must be 1; trace scope must be larger than +// 0; open ended trace scopes must start at 1 + //===========================================================================// parser code {: @@ -83,13 +92,13 @@ parser code {: for (_done_parsing = false; !_done_parsing; ) { act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym); if (act > 0) { // "shift"; thus, we shift to the encoded state by pushing it on the stack - if (logging) System.out.println("shift " + cur_token.sym); + // if (logging) System.out.println("shift " + cur_token.sym); cur_token.parse_state = act-1; stack.push(cur_token); tos++; cur_token = scan(); } else if (act<0) { // "reduce" - if (logging) System.out.println("reduce " + ((-act)-1)); + // if (logging) System.out.println("reduce " + ((-act)-1)); lhs_sym = do_action((-act)-1, this, stack, tos); lhs_sym_num = production_tab[(-act)-1][0]; handle_size = production_tab[(-act)-1][1]; @@ -223,6 +232,20 @@ parser code {: ch.put(CompSym.ID, "NAME"); ch.put(CompSym.NUMBER, "NUMBER"); ch.put(CompSym.STR, "STRING"); + ch.put(CompSym.VAR, "var"); + ch.put(CompSym.ALWAYS, "always"); + ch.put(CompSym.EVENTUALLY, "eventually"); + ch.put(CompSym.AFTER, "after"); + ch.put(CompSym.BEFORE, "before"); + ch.put(CompSym.HISTORICALLY, "historically"); + ch.put(CompSym.ONCE, "once"); + ch.put(CompSym.RELEASES, "releases"); + ch.put(CompSym.UNTIL, "until"); + ch.put(CompSym.SINCE, "since"); + ch.put(CompSym.TRIGGERED, "triggered"); + ch.put(CompSym.TRCSEQ, ";"); + ch.put(CompSym.PRIME, "'"); + ch.put(CompSym.TIME, "steps"); TreeSet list = new TreeSet(); Pos p=Pos.UNKNOWN; if (x!=null && x.value instanceof Pos) p=(Pos)(x.value); @@ -333,6 +356,7 @@ action code {: private void c(boolean follow, ExprVar o, ExprVar x, ExprVar n, Expr e, List s, ExprConstant c) throws Err { if (n!=null) nod(n); int bitwidth=(-1), maxseq=(-1), overall=(-1), expects=(c==null ? -1 : c.num); + int maxtime = (-1), mintime = (-1); Pos p = o.pos.merge(n!=null ? n.span() : e.span()); for(int i=s.size()-1; i>=0; i--) { Sig j=s.get(i).sig; int k=s.get(i).startingScope; @@ -340,11 +364,23 @@ action code {: if (j.label.equals("univ")) { overall=k; s.remove(i); continue; } if (j.label.equals("int")) { if (bitwidth>=0) throw new ErrorSyntax(j.pos, "The bitwidth cannot be specified more than once."); bitwidth=k; s.remove(i); continue; } if (j.label.equals("seq")) { if (maxseq>=0) throw new ErrorSyntax(j.pos, "The maximum sequence length cannot be specified more than once."); maxseq=k; s.remove(i); continue; } + // [electrum] process time scopes + if (j.label.equals("steps")) { + if (s.get(i).endingScope == Integer.MAX_VALUE && s.get(i).startingScope != 1) throw new ErrorSyntax(j.pos, "Unbounded time scope must start at 1."); + if (s.get(i).increment != 1) throw new ErrorSyntax(j.pos, "Step scopes must be incremented by 1."); + if (k<1) throw new ErrorSyntax(j.pos, "Trace solutions must contain at least one step."); + if (maxtime>=0) throw new ErrorSyntax(j.pos, "Steps scope cannot be specified more than once."); + maxtime=k; + if (s.get(i).isExact) mintime = k; + else if (s.get(i).endingScope != s.get(i).startingScope) { + maxtime = s.get(i).endingScope; mintime = s.get(i).startingScope; } + s.remove(i); continue; + } } if (n!=null) - parser.alloymodule.addCommand(follow, p, n, o.label.equals("c"), overall, bitwidth, maxseq, expects, s, x); + parser.alloymodule.addCommand(follow, p, n, o.label.equals("c"), overall, bitwidth, maxseq, mintime, maxtime, expects, s, x); else - parser.alloymodule.addCommand(follow, p, e, o.label.equals("c"), overall, bitwidth, maxseq, expects, s, x); + parser.alloymodule.addCommand(follow, p, e, o.label.equals("c"), overall, bitwidth, maxseq, mintime, maxtime, expects, s, x); } private Expr t(Pos pos, Pos oldClosing, Expr left, Expr right, Pos close) throws Err { if (right instanceof ExprVar) { @@ -476,6 +512,21 @@ terminal Pos THIS; // this terminal Pos TILDE; // ~ terminal Pos UNIV; // univ +terminal Pos VAR; // var +terminal Pos ALWAYS; // always +terminal Pos EVENTUALLY; // eventually +terminal Pos AFTER; // after +terminal Pos ONCE; // once +terminal Pos HISTORICALLY; // historically +terminal Pos BEFORE; // before +terminal Pos RELEASES; // releases +terminal Pos UNTIL; // until +terminal Pos SINCE; // since +terminal Pos TRIGGERED; // triggered +terminal Pos TRCSEQ; // trace seq +terminal Pos TIME; // steps +terminal Pos PRIME; // ' + terminal ExprVar ID; terminal ExprConstant NUMBER, STR; @@ -527,8 +578,8 @@ nonterminal ExprVar Name; nonterminal ExprVar NameHelper; nonterminal List Names; nonterminal List Namex; -nonterminal Expr NegExprA; -nonterminal Expr NegExprB; +nonterminal Expr UnaryExprA; +nonterminal Expr UnaryExprB; nonterminal Expr NumUnopExprA; nonterminal Expr NumUnopExprB; nonterminal Expr OrExprA; @@ -564,6 +615,23 @@ nonterminal Expr UnionDiffExprB; nonterminal Expr UnopExprA; nonterminal Expr UnopExprB; nonterminal Pos Vis; +nonterminal Expr TempBinaryA; +nonterminal Expr TempBinaryB; +nonterminal Expr ExprNoSeq; + +precedence right TRCSEQ; +precedence nonassoc BAR; +precedence left OR; +precedence left IFF; +precedence right IMPLIES; +precedence left AND; +precedence nonassoc RELEASES, SINCE, UNTIL, TRIGGERED; +precedence nonassoc AFTER, ALWAYS, EVENTUALLY, BEFORE, HISTORICALLY, ONCE; +precedence nonassoc NOT; +precedence nonassoc EQUALS, NOTEQUALS, IN, NOTIN; +precedence nonassoc NO, SOME, LONE, ONE; +precedence nonassoc PRIME; +precedence nonassoc TILDE, CARET, STAR; //===========================================================================// @@ -644,18 +712,27 @@ Typescope ::= TypeNumber:e UNIV:f {: if (1==1) throw new ErrorSyntax(e.pos.m Typescope ::= TypeNumber:a STRING:b {: RESULT = new CommandScope(a.pos.merge(b), new PrimSig("String", AttrType.WHERE.make(a.pos.merge(b))), a.isExact, a.startingScope, a.endingScope, a.increment); :}; +// [electrum] scope on Time +Typescope ::= TypeNumber:a TIME:b {: + Pos p = a.pos.merge(b); + RESULT = new CommandScope(p, new PrimSig("steps", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.endingScope, a.increment); +:}; + //[AM] Typescope ::= TypeNumber:e SIGINT:f {: if (1==1) throw new ErrorSyntax(e.pos.merge(f), "You can no longer set a scope on Int; the number of Int atoms is always exactly equal to 2^(integer bitwidth).\n"); :}; Typescope ::= TypeNumber:e NONE:f {: if (1==1) throw new ErrorSyntax(e.pos.merge(f), "You cannot set a scope on none."); :}; -TypeNumber ::= EXACTLY:e NUMBER:a {: RESULT = new CommandScope( e.merge(a.pos), Sig.NONE, true, a.num, a.num, 1 ); :}; -TypeNumber ::= EXACTLY:e NUMBER:a DOT DOT NUMBER:b {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(b.pos), Sig.NONE, true, a.num, b.num, 1 ); :}; -TypeNumber ::= EXACTLY:e NUMBER:a DOT DOT NUMBER:b COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, b.num, i.num); :}; -TypeNumber ::= EXACTLY:e NUMBER:a COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, Integer.MAX_VALUE, i.num); :}; -TypeNumber ::= NUMBER:a {: RESULT = new CommandScope(a.pos , Sig.NONE, false, a.num, a.num, 1 ); :}; -TypeNumber ::= NUMBER:a DOT DOT NUMBER:b {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(b.pos), Sig.NONE, false, a.num, b.num, 1 ); :}; -TypeNumber ::= NUMBER:a DOT DOT NUMBER:b COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, false, a.num, b.num, i.num); :}; -TypeNumber ::= NUMBER:a COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, false, a.num, Integer.MAX_VALUE, i.num); :}; +// [electrum] distinguish between "n" and "n..n", the latter become exact; open ended scopes "n.." +TypeNumber ::= EXACTLY:e NUMBER:a {: RESULT = new CommandScope( e.merge(a.pos), Sig.NONE, true, a.num, a.num, 1 ); :}; +TypeNumber ::= EXACTLY:e NUMBER:a DOT DOT NUMBER:b {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(b.pos), Sig.NONE, true, a.num, b.num, 1 ); :}; +TypeNumber ::= EXACTLY:e NUMBER:a DOT DOT {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e , Sig.NONE, true, a.num, Integer.MAX_VALUE, 1 ); :}; +TypeNumber ::= EXACTLY:e NUMBER:a DOT DOT NUMBER:b COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, b.num, i.num); :}; +TypeNumber ::= EXACTLY:e NUMBER:a COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, Integer.MAX_VALUE, i.num); :}; +TypeNumber ::= NUMBER:a {: RESULT = new CommandScope(a.pos , Sig.NONE, false, a.num, a.num, 1 ); :}; +TypeNumber ::= NUMBER:a DOT DOT NUMBER:b {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(b.pos), Sig.NONE, a.num == b.num, a.num, b.num, 1 ); :}; +TypeNumber ::= NUMBER:a DOT DOT {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos , Sig.NONE, false, a.num, Integer.MAX_VALUE, 1 ); :}; +TypeNumber ::= NUMBER:a DOT DOT NUMBER:b COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, a.num == b.num, a.num, b.num, i.num); :}; +TypeNumber ::= NUMBER:a COLON NUMBER:i {: if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, false, a.num, Integer.MAX_VALUE, i.num); :}; Macro ::= Vis:p LET:o Name:n LPAREN Names:d RPAREN MacroBody:v {: nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, d , v); :}; Macro ::= Vis:p LET:o Name:n LPAREN RPAREN MacroBody:v {: nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); :}; @@ -694,18 +771,21 @@ Sig ::= SigQuals:a Names:b SigIn:c LBRACE Decls:d RBRACE:o SuperOpt:e AttrType.LONE .makenull(a.get(1)), AttrType.ONE .makenull(a.get(2)), AttrType.SOME .makenull(a.get(3)), - AttrType.PRIVATE .makenull(a.get(4))); + AttrType.PRIVATE .makenull(a.get(4)), + AttrType.VARIABLE.makenull(a.get(5))); } :}; -SigQual ::= ABSTRACT:x {: RESULT=new ArrayList(5); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; -SigQual ::= LONE:x {: RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; -SigQual ::= ONE:x {: RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); :}; -SigQual ::= SOME:x {: RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); :}; -SigQual ::= PRIVATE:x {: RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); :}; +// [electrum] additional attribute for variable sigs +SigQual ::= ABSTRACT:x {: RESULT=new ArrayList(6); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; +SigQual ::= LONE:x {: RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; +SigQual ::= ONE:x {: RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; +SigQual ::= SOME:x {: RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); :}; +SigQual ::= PRIVATE:x {: RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); :}; +SigQual ::= VAR:x {: RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); :}; -SigQuals ::= SIG {: RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; -SigQuals ::= SigQual:a SigQuals:b {: RESULT=a; for(int i=0;i<5;i++) if (a.get(i)==null) a.set(i,b.get(i)); else if (b.get(i)!=null) throw new ErrorSyntax(b.get(i), "The same qualifer cannot be specified more than once for the same sig."); :}; +SigQuals ::= SIG {: RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); :}; +SigQuals ::= SigQual:a SigQuals:b {: RESULT=a; for(int i=0;i<6;i++) if (a.get(i)==null) a.set(i,b.get(i)); else if (b.get(i)!=null) throw new ErrorSyntax(b.get(i), "The same qualifer cannot be specified more than once for the same sig."); :}; SigIn ::= EXTENDS:a SigRef:x {: RESULT=new ArrayList(2); RESULT.add(x); RESULT.add(ExprVar.make(a, "extends")); :}; SigIn ::= IN:a SigRefu:x {: RESULT=x; x.add(ExprVar.make(a,"in")); :}; @@ -715,6 +795,7 @@ SigIn ::= {: RESULT=null; SigRef ::= Name:x {: RESULT=x; :}; SigRef ::= UNIV:x {: RESULT=ExprVar.make(x, "univ"); :}; SigRef ::= STRING:x {: RESULT=ExprVar.make(x, "String"); :}; +SigRef ::= TIME:x {: RESULT=ExprVar.make(x, "steps"); :}; SigRef ::= SIGINT:x {: RESULT=ExprVar.make(x, "Int"); :}; SigRef ::= SEQ:a SLASH SIGINT:b {: RESULT=ExprVar.make(a.merge(b), "seq/Int"); :}; SigRef ::= NONE:x {: RESULT=ExprVar.make(x, "none"); :}; @@ -743,31 +824,42 @@ Namex ::= EXACTLY Name:x {: nod(x); RESULT=new ArrayList( Namex ::= Namex:a COMMA Name:b {: nod(b); a.add(b); RESULT=a; :}; Namex ::= Namex:a COMMA EXACTLY Name:b {: nod(b); a.add(null); a.add(b); RESULT=a; :}; +// [electrum] additional parameter for variable declarations (for fields) Decla ::= PART:k Names COLON Expr {: if (1==1) throw CompModule.hint(k, "part"); :}; Decla ::= EXH:k Names COLON Expr {: if (1==1) throw CompModule.hint(k, "exh"); :}; -Decla ::= DISJ:k Names:a COLON Expr:b {: RESULT=new Decl(null, k, null, a, mult(b)); :}; -Decla ::= PRIVATE:p DISJ:k Names:a COLON Expr:b {: RESULT=new Decl(p, k, null, a, mult(b)); :}; -Decla ::= PRIVATE:p Names:a COLON Expr:b {: RESULT=new Decl(p, null, null, a, mult(b)); :}; -Decla ::= Names:a COLON Expr:b {: RESULT=new Decl(null, null, null, a, mult(b)); :}; +Decla ::= DISJ:k Names:a COLON Expr:b {: RESULT=new Decl(null, k, null, null, a, mult(b)); :}; +Decla ::= PRIVATE:p DISJ:k Names:a COLON Expr:b {: RESULT=new Decl(p, k, null, null, a, mult(b)); :}; +Decla ::= PRIVATE:p Names:a COLON Expr:b {: RESULT=new Decl(p, null, null, null, a, mult(b)); :}; +Decla ::= Names:a COLON Expr:b {: RESULT=new Decl(null, null, null, null, a, mult(b)); :}; + +Decla ::= VAR:v DISJ:k Names:a COLON Expr:b {: RESULT=new Decl(null, k, null, v, a, mult(b)); :}; +Decla ::= VAR:v PRIVATE:p DISJ:k Names:a COLON Expr:b {: RESULT=new Decl(p, k, null, v, a, mult(b)); :}; +Decla ::= VAR:v PRIVATE:p Names:a COLON Expr:b {: RESULT=new Decl(p, null, null, v, a, mult(b)); :}; +Decla ::= VAR:v Names:a COLON Expr:b {: RESULT=new Decl(null, null, null, v, a, mult(b)); :}; Decla ::= PART:k Names COLON DISJ Expr {: if (1==1) throw CompModule.hint(k, "part"); :}; Decla ::= EXH:k Names COLON DISJ Expr {: if (1==1) throw CompModule.hint(k, "exh"); :}; -Decla ::= DISJ:k Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(null, k, d, a, mult(b)); :}; -Decla ::= PRIVATE:p DISJ:k Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(p, k, d, a, mult(b)); :}; -Decla ::= PRIVATE:p Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(p, null, d, a, mult(b)); :}; -Decla ::= Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(null, null, d, a, mult(b)); :}; +Decla ::= DISJ:k Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(null, k, d, null, a, mult(b)); :}; +Decla ::= PRIVATE:p DISJ:k Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(p, k, d, null, a, mult(b)); :}; +Decla ::= PRIVATE:p Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(p, null, d, null, a, mult(b)); :}; +Decla ::= Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(null, null, d, null, a, mult(b)); :}; + +Decla ::= VAR:v DISJ:k Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(null, k, d, v, a, mult(b)); :}; +Decla ::= VAR:v PRIVATE:p DISJ:k Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(p, k, d, v, a, mult(b)); :}; +Decla ::= VAR:v PRIVATE:p Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(p, null, d, v, a, mult(b)); :}; +Decla ::= VAR:v Names:a COLON DISJ:d Expr:b {: RESULT=new Decl(null, null, d, v, a, mult(b)); :}; Declb ::= Decla:x {: RESULT=x; :}; -Declb ::= PART:k Names EQUALS Expr {: if (1==1) throw CompModule.hint(k, "part"); :}; -Declb ::= EXH:k Names EQUALS Expr {: if (1==1) throw CompModule.hint(k, "exh"); :}; -Declb ::= DISJ:d Names EQUALS Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; -Declb ::= PRIVATE DISJ:d Names EQUALS Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; -Declb ::= PRIVATE:p Names:a EQUALS Expr:b {: RESULT=new Decl(p, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); :}; -Declb ::= Names:a EQUALS Expr:b {: RESULT=new Decl(null, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); :}; +Declb ::= PART:k Names EQUALS Expr {: if (1==1) throw CompModule.hint(k, "part"); :}; +Declb ::= EXH:k Names EQUALS Expr {: if (1==1) throw CompModule.hint(k, "exh"); :}; +Declb ::= DISJ:d Names EQUALS Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; +Declb ::= PRIVATE DISJ:d Names EQUALS Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; +Declb ::= PRIVATE:p Names:a EQUALS Expr:b {: RESULT=new Decl(p, null, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); :}; +Declb ::= Names:a EQUALS Expr:b {: RESULT=new Decl(null, null, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); :}; -Declb ::= PART:k Names EQUALS DISJ Expr {: if (1==1) throw CompModule.hint(k, "part"); :}; -Declb ::= EXH:k Names EQUALS DISJ Expr {: if (1==1) throw CompModule.hint(k, "exh"); :}; +Declb ::= PART:k Names EQUALS DISJ Expr {: if (1==1) throw CompModule.hint(k, "part"); :}; +Declb ::= EXH:k Names EQUALS DISJ Expr {: if (1==1) throw CompModule.hint(k, "exh"); :}; Declb ::= DISJ Names EQUALS DISJ:d Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; Declb ::= PRIVATE DISJ Names EQUALS DISJ:d Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; Declb ::= PRIVATE Names EQUALS DISJ:d Expr {: if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); :}; @@ -798,15 +890,18 @@ Let ::= Name:a EQUALS:o Expr:b COMMA Let:x {: RESULT = ExprLet.make(o, ExprVar.make(a.pos, a.label), b, x); :}; -SuperOpt ::= {: RESULT=null; :}; -SuperOpt ::= Super:x {: RESULT=x; :}; -Super ::= LBRACE:a SuperP:x RBRACE:b {: RESULT=ExprUnary.Op.NOOP.make(a.merge(b), x); :}; -Super ::= LBRACE:a RBRACE:b {: RESULT=ExprConstant.Op.TRUE.make(a.merge(b), 0); :}; -SuperP ::= Expr:a {: RESULT=a; :}; -SuperP ::= SuperP:a Expr:b {: RESULT=ExprBinary.Op.AND.make(null, null, a, b); :}; +// [electrum] temporal seq expressions have the lowest precedence +SuperOpt ::= {: RESULT=null; :}; +SuperOpt ::= Super:x {: RESULT=x; :}; +Super ::= LBRACE:a SuperP:x RBRACE:b {: RESULT=ExprUnary.Op.NOOP.make(a.merge(b), x); :}; +Super ::= LBRACE:a RBRACE:b {: RESULT=ExprConstant.Op.TRUE.make(a.merge(b), 0); :}; +SuperP ::= Expr:a {: RESULT=a; :}; +SuperP ::= SuperP:a Expr:b {: RESULT=ExprBinary.Op.AND.make(null, null, a, b); :}; +SuperP ::= Expr:a TRCSEQ:o SuperP:b {: RESULT=ExprBinary.Op.AND.make(o, null, a, ExprUnary.Op.AFTER.make(o, b)); :}; -SuperOrBar ::= BAR Expr:x {: RESULT=x; :}; -SuperOrBar ::= Super:x {: RESULT=x; :}; +SuperOrBar ::= BAR ExprNoSeq:x {: RESULT=x; :}; +SuperOrBar ::= Super:x {: RESULT=x; :}; +SuperOrBar ::= BAR ExprNoSeq:x TRCSEQ:o Expr:y {: RESULT=ExprBinary.Op.AND.make(o, null, x, ExprUnary.Op.AFTER.make(o, y)); :}; Exprs ::= {: RESULT=new ArrayList(); :}; Exprs ::= Exprp:x {: RESULT=x; :}; @@ -815,16 +910,19 @@ Exprp ::= Exprp:a COMMA Expr:b {: a.add(b); RESULT=a; //============================================================================= -Expr ::= OrExprA:x {: RESULT = x; :}; -Expr ::= OrExprB:x {: RESULT = x; :}; -Expr ::= Bind:x {: RESULT = x; :}; -Bind ::= LET Let:x {: RESULT = x; :}; -Bind ::= ALL2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.ALL .make(o, null, a, b); :}; -Bind ::= NO2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.NO .make(o, null, a, b); :}; -Bind ::= SOME2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.SOME.make(o, null, a, b); :}; -Bind ::= LONE2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.LONE.make(o, null, a, b); :}; -Bind ::= ONE2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.ONE .make(o, null, a, b); :}; -Bind ::= SUM2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.SUM .make(o, null, a, b); :}; +Expr ::= ExprNoSeq:a {: RESULT=a; :}; +Expr ::= ExprNoSeq:a TRCSEQ:o Expr:b {: RESULT=ExprBinary.Op.AND.make(o, null, a, ExprUnary.Op.AFTER.make(o, b)); :}; + +ExprNoSeq ::= OrExprA:x {: RESULT = x; :}; +ExprNoSeq ::= OrExprB:x {: RESULT = x; :}; +ExprNoSeq ::= Bind:x {: RESULT = x; :}; +Bind ::= LET Let:x {: RESULT = x; :}; +Bind ::= ALL2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.ALL .make(o, null, a, b); :}; +Bind ::= NO2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.NO .make(o, null, a, b); :}; +Bind ::= SOME2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.SOME.make(o, null, a, b); :}; +Bind ::= LONE2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.LONE.make(o, null, a, b); :}; +Bind ::= ONE2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.ONE .make(o, null, a, b); :}; +Bind ::= SUM2:o Declp:a SuperOrBar:b {: RESULT = ExprQt.Op.SUM .make(o, null, a, b); :}; OrExprA ::= EquivExprA:a {: RESULT=a; :}; OrExprA ::= OrExprB:a OR:o Bind:b {: RESULT=ExprBinary.Op.OR.make(o, null, a, b); :}; @@ -853,16 +951,47 @@ ImpliesExprCloseB ::= AndExprB:a IMPLIES:o ImpliesExprCloseB:b ELSE ImpliesExprC ImpliesExprOpenB ::= AndExprB:a IMPLIES:o ImpliesExprCloseB:b ELSE ImpliesExprOpenB:c {: RESULT = ExprITE.make(o,a,b,c); :}; ImpliesExprOpenB ::= AndExprB:a IMPLIES:o ImpliesExprB:b {: RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); :}; -AndExprA ::= NegExprA:a {: RESULT=a; :}; -AndExprA ::= AndExprB:a AND:o Bind:b {: RESULT=ExprBinary.Op.AND.make(o, null, a, b); :}; -AndExprB ::= NegExprB:b {: RESULT=b; :}; -AndExprB ::= AndExprB:a AND:o NegExprB:b {: RESULT=ExprBinary.Op.AND.make(o, null, a, b); :}; - -NegExprA ::= CompareExprA:b {: RESULT=b; :}; -NegExprA ::= NOT:o Bind:b {: RESULT=ExprUnary.Op.NOT.make(o, b); :}; -NegExprA ::= NOT:o NegExprA:b {: RESULT=ExprUnary.Op.NOT.make(o, b); :}; -NegExprB ::= CompareExprB:b {: RESULT=b; :}; -NegExprB ::= NOT:o NegExprB:b {: RESULT=ExprUnary.Op.NOT.make(o, b); :}; +AndExprA ::= TempBinaryA:a {: RESULT=a; :}; +AndExprA ::= AndExprB:a AND:o Bind:b {: RESULT=ExprBinary.Op.AND.make(o, null, a, b); :}; +AndExprB ::= TempBinaryB:b {: RESULT=b; :}; +AndExprB ::= AndExprB:a AND:o TempBinaryB:b {: RESULT=ExprBinary.Op.AND.make(o, null, a, b); :}; + +// [electrum] binary temporal formulas, highest precedence among binary operators +TempBinaryA ::= UnaryExprA:a {: RESULT=a; :}; +TempBinaryA ::= TempBinaryB:a UNTIL:o Bind:b {: RESULT=ExprBinary.Op.UNTIL .make(o, null, a, b); :}; +TempBinaryA ::= TempBinaryB:a SINCE:o Bind:b {: RESULT=ExprBinary.Op.SINCE .make(o, null, a, b); :}; +TempBinaryA ::= TempBinaryB:a TRIGGERED:o Bind:b {: RESULT=ExprBinary.Op.TRIGGERED.make(o, null, a, b); :}; +TempBinaryA ::= TempBinaryB:a RELEASES:o Bind:b {: RESULT=ExprBinary.Op.RELEASES .make(o, null, a, b); :}; +TempBinaryB ::= UnaryExprB:b {: RESULT=b; :}; +TempBinaryB ::= TempBinaryB:a UNTIL:o UnaryExprB:b {: RESULT=ExprBinary.Op.UNTIL .make(o, null, a, b); :}; +TempBinaryB ::= TempBinaryB:a SINCE:o UnaryExprB:b {: RESULT=ExprBinary.Op.SINCE .make(o, null, a, b); :}; +TempBinaryB ::= TempBinaryB:a RELEASES:o UnaryExprB:b {: RESULT=ExprBinary.Op.RELEASES .make(o, null, a, b); :}; +TempBinaryB ::= TempBinaryB:a TRIGGERED:o UnaryExprB:b {: RESULT=ExprBinary.Op.TRIGGERED.make(o, null, a, b); :}; + +// [electrum] unary temporal formulas, same precedence as other unary operators +UnaryExprA ::= CompareExprA:b {: RESULT=b; :}; +UnaryExprA ::= NOT:o Bind:b {: RESULT=ExprUnary.Op.NOT.make(o, b); :}; +UnaryExprA ::= NOT:o UnaryExprA:b {: RESULT=ExprUnary.Op.NOT.make(o, b); :}; +UnaryExprA ::= ALWAYS:o Bind:b {: RESULT=ExprUnary.Op.ALWAYS.make(o, b); :}; +UnaryExprA ::= ALWAYS:o UnaryExprA:b {: RESULT=ExprUnary.Op.ALWAYS.make(o, b); :}; +UnaryExprA ::= EVENTUALLY:o Bind:b {: RESULT=ExprUnary.Op.EVENTUALLY.make(o, b); :}; +UnaryExprA ::= EVENTUALLY:o UnaryExprA:b {: RESULT=ExprUnary.Op.EVENTUALLY.make(o, b); :}; +UnaryExprA ::= AFTER:o Bind:b {: RESULT=ExprUnary.Op.AFTER.make(o, b); :}; +UnaryExprA ::= AFTER:o UnaryExprA:b {: RESULT=ExprUnary.Op.AFTER.make(o, b); :}; +UnaryExprA ::= HISTORICALLY:o Bind:b {: RESULT=ExprUnary.Op.HISTORICALLY.make(o, b); :}; +UnaryExprA ::= HISTORICALLY:o UnaryExprA:b {: RESULT=ExprUnary.Op.HISTORICALLY.make(o, b); :}; +UnaryExprA ::= ONCE:o Bind:b {: RESULT=ExprUnary.Op.ONCE.make(o, b); :}; +UnaryExprA ::= ONCE:o UnaryExprA:b {: RESULT=ExprUnary.Op.ONCE.make(o, b); :}; +UnaryExprA ::= BEFORE:o Bind:b {: RESULT=ExprUnary.Op.BEFORE.make(o, b); :}; +UnaryExprA ::= BEFORE:o UnaryExprA:b {: RESULT=ExprUnary.Op.BEFORE.make(o, b); :}; +UnaryExprB ::= CompareExprB:b {: RESULT=b; :}; +UnaryExprB ::= NOT:o UnaryExprB:b {: RESULT=ExprUnary.Op.NOT.make(o, b); :}; +UnaryExprB ::= ALWAYS:o UnaryExprB:b {: RESULT=ExprUnary.Op.ALWAYS.make(o, b); :}; +UnaryExprB ::= EVENTUALLY:o UnaryExprB:b {: RESULT=ExprUnary.Op.EVENTUALLY.make(o, b); :}; +UnaryExprB ::= AFTER:o UnaryExprB:b {: RESULT=ExprUnary.Op.AFTER.make(o, b); :}; +UnaryExprB ::= HISTORICALLY:o UnaryExprB:b {: RESULT=ExprUnary.Op.HISTORICALLY.make(o, b); :}; +UnaryExprB ::= ONCE:o UnaryExprB:b {: RESULT=ExprUnary.Op.ONCE.make(o, b); :}; +UnaryExprB ::= BEFORE:o UnaryExprB:b {: RESULT=ExprUnary.Op.BEFORE.make(o, b); :}; CompareExprA ::= CompareExprB:a IN:o ShiftExprA:b {: RESULT=ExprBinary.Op.IN .make(o, null, a, mult(b)); :}; CompareExprA ::= CompareExprB:a EQUALS:o ShiftExprA:b {: RESULT=ExprBinary.Op.EQUALS .make(o, null, a, b); :}; @@ -1011,6 +1140,7 @@ DotExprB ::= BracketExprB:a DOT:o TOTALORDER:b {: RESULT=t(o, null, a, ExprVar.m DotExprB ::= BracketExprB:a DOT:o INT {: RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, a)); :}; DotExprB ::= BracketExprB:a DOT:o SUM {: RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, a)); :}; +// [electrum] unary temporal expressions, same precedence as other unary operators UnopExprA ::= TILDE:o Bind:b {: RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); :}; UnopExprA ::= STAR:o Bind:b {: RESULT=ExprUnary.Op.RCLOSURE .make(o,b); :}; UnopExprA ::= CARET:o Bind:b {: RESULT=ExprUnary.Op.CLOSURE .make(o,b); :}; @@ -1021,6 +1151,9 @@ UnopExprB ::= BaseExpr:b {: RESULT=b; UnopExprB ::= TILDE:o UnopExprB:b {: RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); :}; UnopExprB ::= STAR:o UnopExprB:b {: RESULT=ExprUnary.Op.RCLOSURE .make(o,b); :}; UnopExprB ::= CARET:o UnopExprB:b {: RESULT=ExprUnary.Op.CLOSURE .make(o,b); :}; +UnopExprA ::= Bind:b PRIME:o {: RESULT=ExprUnary.Op.PRIME .make(o,b); :}; +UnopExprA ::= UnopExprA:b PRIME:o {: RESULT=ExprUnary.Op.PRIME .make(o,b); :}; +UnopExprB ::= UnopExprB:b PRIME:o {: RESULT=ExprUnary.Op.PRIME .make(o,b); :}; BaseExpr ::= NUMBER:x {: RESULT = x; :}; BaseExpr ::= STR:x {: RESULT = x; :}; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.lex b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.lex index 2db55333e..4ec7c4cac 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.lex +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/Alloy.lex @@ -25,6 +25,9 @@ import java_cup.runtime.*; /** Autogenerated by JFlex 1.4.1 */ +// @modified [electrum] added temporal keywords and operators (single quotes also +// interpreted as primes); forbade primes in identifiers + %% // There are 3 sets of "special tokens" that the lexer will not output. @@ -83,7 +86,7 @@ import java_cup.runtime.*; i++; if (i>=txt.length()) throw new ErrorSyntax(p, "String literal cannot end with a single \\"); c = txt.charAt(i); - if (c=='n') c='\n'; else if (c!='\'' && c!='\"' && c!='\\') throw new ErrorSyntax(p, "String literal currenty only supports\nfour escape sequences: \\\\, \\n, \\\', and \\\""); + if (c=='n') c='\n'; else if (c!='\"' && c!='\\') throw new ErrorSyntax(p, "String literal currently only supports\nthree escape sequences: \\\\, \\n, and \\\""); } sb.append(c); } @@ -218,15 +221,31 @@ import java_cup.runtime.*; "sum" { return alloy_sym(yytext(), CompSym.SUM );} "this" { return alloy_sym(yytext(), CompSym.THIS );} "univ" { return alloy_sym(yytext(), CompSym.UNIV );} +"always" { return alloy_sym(yytext(), CompSym.ALWAYS );} +"after" { return alloy_sym(yytext(), CompSym.AFTER );} +"eventually" { return alloy_sym(yytext(), CompSym.EVENTUALLY );} +"historically" { return alloy_sym(yytext(), CompSym.HISTORICALLY);} +"before" { return alloy_sym(yytext(), CompSym.BEFORE );} +"once" { return alloy_sym(yytext(), CompSym.ONCE );} +"releases" { return alloy_sym(yytext(), CompSym.RELEASES );} +"until" { return alloy_sym(yytext(), CompSym.UNTIL );} +"since" { return alloy_sym(yytext(), CompSym.SINCE );} +"triggered" { return alloy_sym(yytext(), CompSym.TRIGGERED );} +";" { return alloy_sym(yytext(), CompSym.TRCSEQ );} +"var" { return alloy_sym(yytext(), CompSym.VAR );} +"steps" { return alloy_sym(yytext(), CompSym.TIME );} +"'" { return alloy_sym(yytext(), CompSym.PRIME );} +"‘" { return alloy_sym(yytext(), CompSym.PRIME );} +"’" { return alloy_sym(yytext(), CompSym.PRIME );} -[\"] ([^\\\"] | ("\\" .))* [\"] [\$0-9a-zA-Z_\'\"] [\$0-9a-zA-Z_\'\"]* { throw new ErrorSyntax(alloy_here(yytext()),"String literal cannot be followed by a legal identifier character."); } +[\"] ([^\\\"] | ("\\" .))* [\"] [\$0-9a-zA-Z_\"] [\$0-9a-zA-Z_\"]* { throw new ErrorSyntax(alloy_here(yytext()),"String literal cannot be followed by a legal identifier character."); } [\"] ([^\\\"] | ("\\" .))* [\"] { return alloy_string(yytext()); } [\"] ([^\\\"] | ("\\" .))* { throw new ErrorSyntax(alloy_here(yytext()),"String literal is missing its closing \" character"); } [0]"x"([_]|([0-9A-Fa-f][0-9A-Fa-f]))+ { return alloy_hexnum (yytext()); } [0]"b"[01_]+ { return alloy_binarynum (yytext()); } -[0-9][0-9]*[\$a-zA-Z_\'\"][\$0-9a-zA-Z_\'\"]* { throw new ErrorSyntax(alloy_here(yytext()),"Name cannot start with a number."); } +[0-9][0-9]*[\$a-zA-Z_\"][\$0-9a-zA-Z_\"]* { throw new ErrorSyntax(alloy_here(yytext()),"Name cannot start with a number."); } [0-9][0-9_]* { return alloy_num (yytext()); } -[:jletter:][[:jletterdigit:]\'\"]* { return alloy_id (yytext()); } +[:jletter:][[:jletterdigit:]\"]* { return alloy_id (yytext()); } "/**" ~"*/" { } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompLexer.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompLexer.java index 3e4bedefc..e51f5eb46 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompLexer.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompLexer.java @@ -1,4 +1,4 @@ -/* The following code was generated by JFlex 1.4.1 on 4/8/18 9:54 AM */ +/* The following code was generated by JFlex 1.4.1 on 2/21/21 3:30 PM */ // Alloy Analyzer 4 -- Copyright (c) 2006-2008, Felix Chang // @@ -27,7 +27,16 @@ /** Autogenerated by JFlex 1.4.1 */ +// @modified [electrum] added temporal keywords and operators (single quotes also +// interpreted as primes); forbade primes in identifiers + +/** + * This class is a scanner generated by + * JFlex 1.4.1 + * on 2/21/21 3:30 PM from the specification file + * src/main/java/edu/mit/csail/sdg/parser/Alloy.lex + */ public final class CompLexer implements java_cup.runtime.Scanner { /** This character denotes the end of file */ @@ -43,120 +52,120 @@ public final class CompLexer implements java_cup.runtime.Scanner { * Translates characters to character classes */ private static final String ZZ_CMAP_PACKED = - "\11\75\1\77\1\64\1\0\1\77\1\76\16\75\4\0\1\77\1\1"+ - "\1\62\1\2\1\74\1\0\1\3\1\65\1\4\1\5\1\6\1\7"+ - "\1\10\1\11\1\13\1\14\1\66\1\71\10\72\1\15\1\0\1\16"+ - "\1\17\1\12\1\0\1\20\6\70\2\74\1\56\11\74\1\61\7\74"+ - "\1\21\1\63\1\22\1\23\1\67\1\0\1\30\1\31\1\35\1\40"+ + "\11\77\1\101\1\67\1\0\1\101\1\100\16\77\4\0\1\101\1\1"+ + "\1\65\1\2\1\70\1\0\1\3\1\64\1\4\1\5\1\6\1\7"+ + "\1\10\1\11\1\13\1\14\1\71\1\74\10\75\1\15\1\63\1\16"+ + "\1\17\1\12\1\0\1\20\6\73\2\70\1\56\11\70\1\61\7\70"+ + "\1\21\1\66\1\22\1\23\1\72\1\0\1\30\1\31\1\35\1\40"+ "\1\41\1\55\1\60\1\43\1\45\1\46\1\44\1\36\1\50\1\37"+ - "\1\47\1\54\1\57\1\34\1\32\1\33\1\42\1\53\1\74\1\51"+ - "\1\52\1\74\1\24\1\25\1\26\1\27\41\75\2\0\4\73\4\0"+ - "\1\73\2\0\1\75\7\0\1\73\4\0\1\73\5\0\27\73\1\0"+ - "\37\73\1\0\u01ca\73\4\0\14\73\16\0\5\73\7\0\1\73\1\0"+ - "\1\73\21\0\160\75\5\73\1\0\2\73\2\0\4\73\10\0\1\73"+ - "\1\0\3\73\1\0\1\73\1\0\24\73\1\0\123\73\1\0\213\73"+ - "\1\0\5\75\2\0\236\73\11\0\46\73\2\0\1\73\7\0\47\73"+ - "\7\0\1\73\1\0\55\75\1\0\1\75\1\0\2\75\1\0\2\75"+ - "\1\0\1\75\10\0\33\73\5\0\3\73\15\0\5\75\6\0\1\73"+ - "\4\0\13\75\5\0\53\73\37\75\4\0\2\73\1\75\143\73\1\0"+ - "\1\73\10\75\1\0\6\75\2\73\2\75\1\0\4\75\2\73\12\75"+ - "\3\73\2\0\1\73\17\0\1\75\1\73\1\75\36\73\33\75\2\0"+ - "\131\73\13\75\1\73\16\0\12\75\41\73\11\75\2\73\4\0\1\73"+ - "\5\0\26\73\4\75\1\73\11\75\1\73\3\75\1\73\5\75\22\0"+ - "\31\73\3\75\104\0\1\73\1\0\13\73\67\0\33\75\1\0\4\75"+ - "\66\73\3\75\1\73\22\75\1\73\7\75\12\73\2\75\2\0\12\75"+ - "\1\0\7\73\1\0\7\73\1\0\3\75\1\0\10\73\2\0\2\73"+ - "\2\0\26\73\1\0\7\73\1\0\1\73\3\0\4\73\2\0\1\75"+ - "\1\73\7\75\2\0\2\75\2\0\3\75\1\73\10\0\1\75\4\0"+ - "\2\73\1\0\3\73\2\75\2\0\12\75\4\73\7\0\1\73\5\0"+ - "\3\75\1\0\6\73\4\0\2\73\2\0\26\73\1\0\7\73\1\0"+ - "\2\73\1\0\2\73\1\0\2\73\2\0\1\75\1\0\5\75\4\0"+ - "\2\75\2\0\3\75\3\0\1\75\7\0\4\73\1\0\1\73\7\0"+ - "\14\75\3\73\1\75\13\0\3\75\1\0\11\73\1\0\3\73\1\0"+ - "\26\73\1\0\7\73\1\0\2\73\1\0\5\73\2\0\1\75\1\73"+ - "\10\75\1\0\3\75\1\0\3\75\2\0\1\73\17\0\2\73\2\75"+ - "\2\0\12\75\1\0\1\73\17\0\3\75\1\0\10\73\2\0\2\73"+ - "\2\0\26\73\1\0\7\73\1\0\2\73\1\0\5\73\2\0\1\75"+ - "\1\73\7\75\2\0\2\75\2\0\3\75\10\0\2\75\4\0\2\73"+ - "\1\0\3\73\2\75\2\0\12\75\1\0\1\73\20\0\1\75\1\73"+ - "\1\0\6\73\3\0\3\73\1\0\4\73\3\0\2\73\1\0\1\73"+ - "\1\0\2\73\3\0\2\73\3\0\3\73\3\0\14\73\4\0\5\75"+ - "\3\0\3\75\1\0\4\75\2\0\1\73\6\0\1\75\16\0\12\75"+ - "\11\0\1\73\7\0\3\75\1\0\10\73\1\0\3\73\1\0\27\73"+ - "\1\0\12\73\1\0\5\73\3\0\1\73\7\75\1\0\3\75\1\0"+ - "\4\75\7\0\2\75\1\0\2\73\6\0\2\73\2\75\2\0\12\75"+ - "\22\0\2\75\1\0\10\73\1\0\3\73\1\0\27\73\1\0\12\73"+ - "\1\0\5\73\2\0\1\75\1\73\7\75\1\0\3\75\1\0\4\75"+ - "\7\0\2\75\7\0\1\73\1\0\2\73\2\75\2\0\12\75\1\0"+ - "\2\73\17\0\2\75\1\0\10\73\1\0\3\73\1\0\51\73\2\0"+ - "\1\73\7\75\1\0\3\75\1\0\4\75\1\73\10\0\1\75\10\0"+ - "\2\73\2\75\2\0\12\75\12\0\6\73\2\0\2\75\1\0\22\73"+ - "\3\0\30\73\1\0\11\73\1\0\1\73\2\0\7\73\3\0\1\75"+ - "\4\0\6\75\1\0\1\75\1\0\10\75\22\0\2\75\15\0\60\73"+ - "\1\75\2\73\7\75\4\0\10\73\10\75\1\0\12\75\47\0\2\73"+ - "\1\0\1\73\2\0\2\73\1\0\1\73\2\0\1\73\6\0\4\73"+ - "\1\0\7\73\1\0\3\73\1\0\1\73\1\0\1\73\2\0\2\73"+ - "\1\0\4\73\1\75\2\73\6\75\1\0\2\75\1\73\2\0\5\73"+ - "\1\0\1\73\1\0\6\75\2\0\12\75\2\0\4\73\40\0\1\73"+ - "\27\0\2\75\6\0\12\75\13\0\1\75\1\0\1\75\1\0\1\75"+ - "\4\0\2\75\10\73\1\0\44\73\4\0\24\75\1\0\2\75\5\73"+ - "\13\75\1\0\44\75\11\0\1\75\71\0\53\73\24\75\1\73\12\75"+ - "\6\0\6\73\4\75\4\73\3\75\1\73\3\75\2\73\7\75\3\73"+ - "\4\75\15\73\14\75\1\73\17\75\2\0\46\73\1\0\1\73\5\0"+ - "\1\73\2\0\53\73\1\0\u014d\73\1\0\4\73\2\0\7\73\1\0"+ - "\1\73\1\0\4\73\2\0\51\73\1\0\4\73\2\0\41\73\1\0"+ - "\4\73\2\0\7\73\1\0\1\73\1\0\4\73\2\0\17\73\1\0"+ - "\71\73\1\0\4\73\2\0\103\73\2\0\3\75\40\0\20\73\20\0"+ - "\125\73\14\0\u026c\73\2\0\21\73\1\0\32\73\5\0\113\73\3\0"+ - "\3\73\17\0\15\73\1\0\4\73\3\75\13\0\22\73\3\75\13\0"+ - "\22\73\2\75\14\0\15\73\1\0\3\73\1\0\2\75\14\0\64\73"+ - "\40\75\3\0\1\73\3\0\2\73\1\75\2\0\12\75\41\0\3\75"+ - "\2\0\12\75\6\0\130\73\10\0\51\73\1\75\1\73\5\0\106\73"+ - "\12\0\35\73\3\0\14\75\4\0\14\75\12\0\12\75\36\73\2\0"+ - "\5\73\13\0\54\73\4\0\21\75\7\73\2\75\6\0\12\75\46\0"+ - "\27\73\5\75\4\0\65\73\12\75\1\0\35\75\2\0\13\75\6\0"+ - "\12\75\15\0\1\73\130\0\5\75\57\73\21\75\7\73\4\0\12\75"+ - "\21\0\11\75\14\0\3\75\36\73\15\75\2\73\12\75\54\73\16\75"+ - "\14\0\44\73\24\75\10\0\12\75\3\0\3\73\12\75\44\73\122\0"+ - "\3\75\1\0\25\75\4\73\1\75\4\73\3\75\2\73\11\0\300\73"+ - "\47\75\25\0\4\75\u0116\73\2\0\6\73\2\0\46\73\2\0\6\73"+ - "\2\0\10\73\1\0\1\73\1\0\1\73\1\0\1\73\1\0\37\73"+ - "\2\0\65\73\1\0\7\73\1\0\1\73\3\0\3\73\1\0\7\73"+ - "\3\0\4\73\2\0\6\73\4\0\15\73\5\0\3\73\1\0\7\73"+ - "\16\0\5\75\32\0\5\75\20\0\2\73\23\0\1\73\13\0\5\75"+ - "\5\0\6\75\1\0\1\73\15\0\1\73\20\0\15\73\3\0\33\73"+ - "\25\0\15\75\4\0\1\75\3\0\14\75\21\0\1\73\4\0\1\73"+ - "\2\0\12\73\1\0\1\73\3\0\5\73\6\0\1\73\1\0\1\73"+ - "\1\0\1\73\1\0\4\73\1\0\13\73\2\0\4\73\5\0\5\73"+ - "\4\0\1\73\21\0\51\73\u0a77\0\57\73\1\0\57\73\1\0\205\73"+ - "\6\0\4\73\3\75\2\73\14\0\46\73\1\0\1\73\5\0\1\73"+ - "\2\0\70\73\7\0\1\73\17\0\1\75\27\73\11\0\7\73\1\0"+ - "\7\73\1\0\7\73\1\0\7\73\1\0\7\73\1\0\7\73\1\0"+ - "\7\73\1\0\7\73\1\0\40\75\57\0\1\73\u01d5\0\3\73\31\0"+ - "\11\73\6\75\1\0\5\73\2\0\5\73\4\0\126\73\2\0\2\75"+ - "\2\0\3\73\1\0\132\73\1\0\4\73\5\0\51\73\3\0\136\73"+ - "\21\0\33\73\65\0\20\73\u0200\0\u19b6\73\112\0\u51cd\73\63\0\u048d\73"+ - "\103\0\56\73\2\0\u010d\73\3\0\20\73\12\75\2\73\24\0\57\73"+ - "\1\75\4\0\12\75\1\0\31\73\7\0\1\75\120\73\2\75\45\0"+ - "\11\73\2\0\147\73\2\0\4\73\1\0\4\73\14\0\13\73\115\0"+ - "\12\73\1\75\3\73\1\75\4\73\1\75\27\73\5\75\20\0\1\73"+ - "\7\0\64\73\14\0\2\75\62\73\21\75\13\0\12\75\6\0\22\75"+ - "\6\73\3\0\1\73\4\0\12\75\34\73\10\75\2\0\27\73\15\75"+ - "\14\0\35\73\3\0\4\75\57\73\16\75\16\0\1\73\12\75\46\0"+ - "\51\73\16\75\11\0\3\73\1\75\10\73\2\75\2\0\12\75\6\0"+ - "\27\73\3\0\1\73\1\75\4\0\60\73\1\75\1\73\3\75\2\73"+ - "\2\75\5\73\2\75\1\73\1\75\1\73\30\0\3\73\2\0\13\73"+ - "\5\75\2\0\3\73\2\75\12\0\6\73\2\0\6\73\2\0\6\73"+ - "\11\0\7\73\1\0\7\73\221\0\43\73\10\75\1\0\2\75\2\0"+ - "\12\75\6\0\u2ba4\73\14\0\27\73\4\0\61\73\u2104\0\u016e\73\2\0"+ - "\152\73\46\0\7\73\14\0\5\73\5\0\1\73\1\75\12\73\1\0"+ - "\15\73\1\0\5\73\1\0\1\73\1\0\2\73\1\0\2\73\1\0"+ - "\154\73\41\0\u016b\73\22\0\100\73\2\0\66\73\50\0\15\73\3\0"+ - "\20\75\20\0\7\75\14\0\2\73\30\0\3\73\31\0\1\73\6\0"+ - "\5\73\1\0\207\73\2\0\1\75\4\0\1\73\13\0\12\75\7\0"+ - "\32\73\4\0\1\73\1\0\32\73\13\0\131\73\3\0\6\73\2\0"+ - "\6\73\2\0\6\73\2\0\3\73\3\0\2\73\3\0\2\73\22\0"+ - "\3\75\4\0"; + "\1\47\1\54\1\57\1\34\1\32\1\33\1\42\1\53\1\62\1\51"+ + "\1\52\1\70\1\24\1\25\1\26\1\27\41\77\2\0\4\76\4\0"+ + "\1\76\2\0\1\77\7\0\1\76\4\0\1\76\5\0\27\76\1\0"+ + "\37\76\1\0\u01ca\76\4\0\14\76\16\0\5\76\7\0\1\76\1\0"+ + "\1\76\21\0\160\77\5\76\1\0\2\76\2\0\4\76\10\0\1\76"+ + "\1\0\3\76\1\0\1\76\1\0\24\76\1\0\123\76\1\0\213\76"+ + "\1\0\5\77\2\0\236\76\11\0\46\76\2\0\1\76\7\0\47\76"+ + "\7\0\1\76\1\0\55\77\1\0\1\77\1\0\2\77\1\0\2\77"+ + "\1\0\1\77\10\0\33\76\5\0\3\76\15\0\5\77\6\0\1\76"+ + "\4\0\13\77\5\0\53\76\37\77\4\0\2\76\1\77\143\76\1\0"+ + "\1\76\10\77\1\0\6\77\2\76\2\77\1\0\4\77\2\76\12\77"+ + "\3\76\2\0\1\76\17\0\1\77\1\76\1\77\36\76\33\77\2\0"+ + "\131\76\13\77\1\76\16\0\12\77\41\76\11\77\2\76\4\0\1\76"+ + "\5\0\26\76\4\77\1\76\11\77\1\76\3\77\1\76\5\77\22\0"+ + "\31\76\3\77\104\0\1\76\1\0\13\76\67\0\33\77\1\0\4\77"+ + "\66\76\3\77\1\76\22\77\1\76\7\77\12\76\2\77\2\0\12\77"+ + "\1\0\7\76\1\0\7\76\1\0\3\77\1\0\10\76\2\0\2\76"+ + "\2\0\26\76\1\0\7\76\1\0\1\76\3\0\4\76\2\0\1\77"+ + "\1\76\7\77\2\0\2\77\2\0\3\77\1\76\10\0\1\77\4\0"+ + "\2\76\1\0\3\76\2\77\2\0\12\77\4\76\7\0\1\76\5\0"+ + "\3\77\1\0\6\76\4\0\2\76\2\0\26\76\1\0\7\76\1\0"+ + "\2\76\1\0\2\76\1\0\2\76\2\0\1\77\1\0\5\77\4\0"+ + "\2\77\2\0\3\77\3\0\1\77\7\0\4\76\1\0\1\76\7\0"+ + "\14\77\3\76\1\77\13\0\3\77\1\0\11\76\1\0\3\76\1\0"+ + "\26\76\1\0\7\76\1\0\2\76\1\0\5\76\2\0\1\77\1\76"+ + "\10\77\1\0\3\77\1\0\3\77\2\0\1\76\17\0\2\76\2\77"+ + "\2\0\12\77\1\0\1\76\17\0\3\77\1\0\10\76\2\0\2\76"+ + "\2\0\26\76\1\0\7\76\1\0\2\76\1\0\5\76\2\0\1\77"+ + "\1\76\7\77\2\0\2\77\2\0\3\77\10\0\2\77\4\0\2\76"+ + "\1\0\3\76\2\77\2\0\12\77\1\0\1\76\20\0\1\77\1\76"+ + "\1\0\6\76\3\0\3\76\1\0\4\76\3\0\2\76\1\0\1\76"+ + "\1\0\2\76\3\0\2\76\3\0\3\76\3\0\14\76\4\0\5\77"+ + "\3\0\3\77\1\0\4\77\2\0\1\76\6\0\1\77\16\0\12\77"+ + "\11\0\1\76\7\0\3\77\1\0\10\76\1\0\3\76\1\0\27\76"+ + "\1\0\12\76\1\0\5\76\3\0\1\76\7\77\1\0\3\77\1\0"+ + "\4\77\7\0\2\77\1\0\2\76\6\0\2\76\2\77\2\0\12\77"+ + "\22\0\2\77\1\0\10\76\1\0\3\76\1\0\27\76\1\0\12\76"+ + "\1\0\5\76\2\0\1\77\1\76\7\77\1\0\3\77\1\0\4\77"+ + "\7\0\2\77\7\0\1\76\1\0\2\76\2\77\2\0\12\77\1\0"+ + "\2\76\17\0\2\77\1\0\10\76\1\0\3\76\1\0\51\76\2\0"+ + "\1\76\7\77\1\0\3\77\1\0\4\77\1\76\10\0\1\77\10\0"+ + "\2\76\2\77\2\0\12\77\12\0\6\76\2\0\2\77\1\0\22\76"+ + "\3\0\30\76\1\0\11\76\1\0\1\76\2\0\7\76\3\0\1\77"+ + "\4\0\6\77\1\0\1\77\1\0\10\77\22\0\2\77\15\0\60\76"+ + "\1\77\2\76\7\77\4\0\10\76\10\77\1\0\12\77\47\0\2\76"+ + "\1\0\1\76\2\0\2\76\1\0\1\76\2\0\1\76\6\0\4\76"+ + "\1\0\7\76\1\0\3\76\1\0\1\76\1\0\1\76\2\0\2\76"+ + "\1\0\4\76\1\77\2\76\6\77\1\0\2\77\1\76\2\0\5\76"+ + "\1\0\1\76\1\0\6\77\2\0\12\77\2\0\4\76\40\0\1\76"+ + "\27\0\2\77\6\0\12\77\13\0\1\77\1\0\1\77\1\0\1\77"+ + "\4\0\2\77\10\76\1\0\44\76\4\0\24\77\1\0\2\77\5\76"+ + "\13\77\1\0\44\77\11\0\1\77\71\0\53\76\24\77\1\76\12\77"+ + "\6\0\6\76\4\77\4\76\3\77\1\76\3\77\2\76\7\77\3\76"+ + "\4\77\15\76\14\77\1\76\17\77\2\0\46\76\1\0\1\76\5\0"+ + "\1\76\2\0\53\76\1\0\u014d\76\1\0\4\76\2\0\7\76\1\0"+ + "\1\76\1\0\4\76\2\0\51\76\1\0\4\76\2\0\41\76\1\0"+ + "\4\76\2\0\7\76\1\0\1\76\1\0\4\76\2\0\17\76\1\0"+ + "\71\76\1\0\4\76\2\0\103\76\2\0\3\77\40\0\20\76\20\0"+ + "\125\76\14\0\u026c\76\2\0\21\76\1\0\32\76\5\0\113\76\3\0"+ + "\3\76\17\0\15\76\1\0\4\76\3\77\13\0\22\76\3\77\13\0"+ + "\22\76\2\77\14\0\15\76\1\0\3\76\1\0\2\77\14\0\64\76"+ + "\40\77\3\0\1\76\3\0\2\76\1\77\2\0\12\77\41\0\3\77"+ + "\2\0\12\77\6\0\130\76\10\0\51\76\1\77\1\76\5\0\106\76"+ + "\12\0\35\76\3\0\14\77\4\0\14\77\12\0\12\77\36\76\2\0"+ + "\5\76\13\0\54\76\4\0\21\77\7\76\2\77\6\0\12\77\46\0"+ + "\27\76\5\77\4\0\65\76\12\77\1\0\35\77\2\0\13\77\6\0"+ + "\12\77\15\0\1\76\130\0\5\77\57\76\21\77\7\76\4\0\12\77"+ + "\21\0\11\77\14\0\3\77\36\76\15\77\2\76\12\77\54\76\16\77"+ + "\14\0\44\76\24\77\10\0\12\77\3\0\3\76\12\77\44\76\122\0"+ + "\3\77\1\0\25\77\4\76\1\77\4\76\3\77\2\76\11\0\300\76"+ + "\47\77\25\0\4\77\u0116\76\2\0\6\76\2\0\46\76\2\0\6\76"+ + "\2\0\10\76\1\0\1\76\1\0\1\76\1\0\1\76\1\0\37\76"+ + "\2\0\65\76\1\0\7\76\1\0\1\76\3\0\3\76\1\0\7\76"+ + "\3\0\4\76\2\0\6\76\4\0\15\76\5\0\3\76\1\0\7\76"+ + "\16\0\5\77\10\0\1\64\1\64\20\0\5\77\20\0\2\76\23\0"+ + "\1\76\13\0\5\77\5\0\6\77\1\0\1\76\15\0\1\76\20\0"+ + "\15\76\3\0\33\76\25\0\15\77\4\0\1\77\3\0\14\77\21\0"+ + "\1\76\4\0\1\76\2\0\12\76\1\0\1\76\3\0\5\76\6\0"+ + "\1\76\1\0\1\76\1\0\1\76\1\0\4\76\1\0\13\76\2\0"+ + "\4\76\5\0\5\76\4\0\1\76\21\0\51\76\u0a77\0\57\76\1\0"+ + "\57\76\1\0\205\76\6\0\4\76\3\77\2\76\14\0\46\76\1\0"+ + "\1\76\5\0\1\76\2\0\70\76\7\0\1\76\17\0\1\77\27\76"+ + "\11\0\7\76\1\0\7\76\1\0\7\76\1\0\7\76\1\0\7\76"+ + "\1\0\7\76\1\0\7\76\1\0\7\76\1\0\40\77\57\0\1\76"+ + "\u01d5\0\3\76\31\0\11\76\6\77\1\0\5\76\2\0\5\76\4\0"+ + "\126\76\2\0\2\77\2\0\3\76\1\0\132\76\1\0\4\76\5\0"+ + "\51\76\3\0\136\76\21\0\33\76\65\0\20\76\u0200\0\u19b6\76\112\0"+ + "\u51cd\76\63\0\u048d\76\103\0\56\76\2\0\u010d\76\3\0\20\76\12\77"+ + "\2\76\24\0\57\76\1\77\4\0\12\77\1\0\31\76\7\0\1\77"+ + "\120\76\2\77\45\0\11\76\2\0\147\76\2\0\4\76\1\0\4\76"+ + "\14\0\13\76\115\0\12\76\1\77\3\76\1\77\4\76\1\77\27\76"+ + "\5\77\20\0\1\76\7\0\64\76\14\0\2\77\62\76\21\77\13\0"+ + "\12\77\6\0\22\77\6\76\3\0\1\76\4\0\12\77\34\76\10\77"+ + "\2\0\27\76\15\77\14\0\35\76\3\0\4\77\57\76\16\77\16\0"+ + "\1\76\12\77\46\0\51\76\16\77\11\0\3\76\1\77\10\76\2\77"+ + "\2\0\12\77\6\0\27\76\3\0\1\76\1\77\4\0\60\76\1\77"+ + "\1\76\3\77\2\76\2\77\5\76\2\77\1\76\1\77\1\76\30\0"+ + "\3\76\2\0\13\76\5\77\2\0\3\76\2\77\12\0\6\76\2\0"+ + "\6\76\2\0\6\76\11\0\7\76\1\0\7\76\221\0\43\76\10\77"+ + "\1\0\2\77\2\0\12\77\6\0\u2ba4\76\14\0\27\76\4\0\61\76"+ + "\u2104\0\u016e\76\2\0\152\76\46\0\7\76\14\0\5\76\5\0\1\76"+ + "\1\77\12\76\1\0\15\76\1\0\5\76\1\0\1\76\1\0\2\76"+ + "\1\0\2\76\1\0\154\76\41\0\u016b\76\22\0\100\76\2\0\66\76"+ + "\50\0\15\76\3\0\20\77\20\0\7\77\14\0\2\76\30\0\3\76"+ + "\31\0\1\76\6\0\5\76\1\0\207\76\2\0\1\77\4\0\1\76"+ + "\13\0\12\77\7\0\32\76\4\0\1\76\1\0\32\76\13\0\131\76"+ + "\3\0\6\76\2\0\6\76\2\0\6\76\2\0\3\76\3\0\2\76"+ + "\3\0\2\76\22\0\3\77\4\0"; /** * Translates characters to character classes @@ -172,23 +181,26 @@ public final class CompLexer implements java_cup.runtime.Scanner { "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ "\1\10\1\11\1\12\1\13\1\14\1\15\1\16\1\17"+ "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27"+ - "\1\30\23\31\1\32\1\33\2\34\1\35\1\36\1\33"+ - "\1\37\1\40\1\41\1\0\1\42\1\43\1\44\1\45"+ - "\1\46\1\45\1\47\1\31\1\50\14\31\1\51\5\31"+ - "\1\52\3\31\1\47\12\31\1\53\1\0\3\54\1\55"+ - "\2\0\1\56\2\31\1\57\1\35\1\60\1\61\1\62"+ - "\1\63\1\64\2\31\1\65\1\31\1\66\1\31\1\2"+ - "\6\31\1\67\2\31\1\70\2\31\1\56\1\71\6\31"+ - "\1\72\1\73\1\74\1\31\1\75\1\76\1\54\1\77"+ - "\1\0\1\33\2\31\1\100\1\101\1\31\1\102\1\103"+ - "\1\104\1\105\1\106\4\31\1\107\1\110\1\31\1\111"+ - "\1\31\1\112\1\113\1\31\1\114\3\31\1\115\13\31"+ - "\1\116\4\31\1\117\1\31\1\120\2\31\1\121\2\31"+ - "\1\122\1\123\1\31\1\46\1\31\1\124\1\125\1\104"+ - "\3\31\1\112\1\67"; + "\1\30\25\31\1\32\1\33\1\34\1\35\2\36\1\37"+ + "\1\40\1\35\1\41\1\42\1\43\1\0\1\44\1\45"+ + "\1\46\1\47\1\50\1\47\1\51\1\31\1\52\21\31"+ + "\1\53\7\31\1\54\3\31\1\51\13\31\1\55\1\0"+ + "\3\56\1\57\2\0\1\60\2\31\1\61\1\31\1\37"+ + "\2\31\1\62\1\31\1\63\1\64\1\65\1\31\1\66"+ + "\4\31\1\67\1\31\1\70\1\31\1\2\6\31\1\71"+ + "\5\31\1\72\2\31\1\60\1\31\1\73\2\31\1\74"+ + "\4\31\1\75\1\76\1\77\1\31\1\100\1\101\1\56"+ + "\1\102\1\0\1\35\7\31\1\103\1\31\1\104\2\31"+ + "\1\105\1\106\1\107\1\110\1\111\6\31\1\112\1\31"+ + "\1\113\1\31\1\114\1\115\1\31\1\116\1\117\1\31"+ + "\1\120\4\31\1\121\1\31\1\122\1\123\2\31\1\124"+ + "\6\31\1\125\7\31\1\126\1\127\1\130\6\31\1\131"+ + "\3\31\1\132\2\31\1\133\4\31\1\134\1\135\3\31"+ + "\1\50\1\31\1\136\1\137\1\31\1\140\1\107\4\31"+ + "\1\141\3\31\1\116\1\71\1\142\2\31\1\143"; private static int [] zzUnpackAction() { - int [] result = new int[216]; + int [] result = new int[282]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -213,36 +225,45 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\100\0\100\0\100\0\200\0\100\0\100\0\100"+ - "\0\300\0\100\0\u0100\0\u0140\0\100\0\u0180\0\u01c0\0\u0200"+ - "\0\u0240\0\100\0\100\0\100\0\100\0\100\0\u0280\0\100"+ - "\0\100\0\u02c0\0\u0300\0\u0340\0\u0380\0\u03c0\0\u0400\0\u0440"+ - "\0\u0480\0\u04c0\0\u0500\0\u0540\0\u0580\0\u05c0\0\u0600\0\u0640"+ - "\0\u0680\0\u06c0\0\u0700\0\u0740\0\u0780\0\100\0\u07c0\0\u0800"+ - "\0\100\0\100\0\u0840\0\100\0\u0880\0\100\0\u08c0\0\100"+ - "\0\100\0\100\0\u0900\0\100\0\100\0\100\0\u0940\0\u0980"+ - "\0\u09c0\0\u0a00\0\u0a40\0\u0a80\0\u0ac0\0\u0b00\0\u0b40\0\u0b80"+ - "\0\u0bc0\0\u0c00\0\u0c40\0\u0c80\0\u0cc0\0\u0d00\0\u0d40\0\u0d80"+ - "\0\u0dc0\0\u0e00\0\u0e40\0\u0e80\0\u0ec0\0\u0f00\0\u0580\0\u0f40"+ - "\0\u0f80\0\u0fc0\0\u1000\0\u1040\0\u1080\0\u10c0\0\u1100\0\u1140"+ - "\0\u1180\0\u11c0\0\u1200\0\u1240\0\u1280\0\u12c0\0\100\0\u1300"+ - "\0\u1340\0\100\0\u1380\0\u13c0\0\u0580\0\u0580\0\u0580\0\u0580"+ - "\0\u0580\0\u0580\0\u0580\0\u1400\0\u1440\0\u0580\0\u1480\0\u0580"+ - "\0\u14c0\0\u0580\0\u1500\0\u1540\0\u1580\0\u15c0\0\u1600\0\u1640"+ - "\0\u1680\0\u16c0\0\u1700\0\u0580\0\u1740\0\u1780\0\u0580\0\u0580"+ - "\0\u17c0\0\u1800\0\u1840\0\u1880\0\u18c0\0\u1900\0\u0580\0\u0580"+ - "\0\u0580\0\u1940\0\u11c0\0\u1280\0\u1980\0\u12c0\0\u19c0\0\u1300"+ - "\0\u1a00\0\u1a40\0\u0580\0\u0580\0\u1a80\0\u0580\0\u0580\0\u1ac0"+ - "\0\u0580\0\u0580\0\u1b00\0\u1b40\0\u1b80\0\u1bc0\0\u0580\0\u0580"+ - "\0\u1c00\0\u0580\0\u1c40\0\u1c80\0\u0580\0\u1cc0\0\u0580\0\u1d00"+ - "\0\u1d40\0\u1d80\0\u0580\0\u1dc0\0\u1e00\0\u1e40\0\u1e80\0\u1ec0"+ - "\0\u1f00\0\u1f40\0\u1f80\0\u1fc0\0\u2000\0\u2040\0\u0580\0\u2080"+ - "\0\u20c0\0\u2100\0\u2140\0\u0580\0\u2180\0\u0580\0\u21c0\0\u2200"+ - "\0\u0580\0\u2240\0\u2280\0\u0580\0\u0580\0\u22c0\0\u0580\0\u2300"+ - "\0\u0580\0\u0580\0\u0580\0\u2340\0\u2380\0\u23c0\0\u0580\0\u0580"; + "\0\0\0\102\0\102\0\102\0\204\0\102\0\102\0\102"+ + "\0\306\0\102\0\u0108\0\u014a\0\102\0\u018c\0\u01ce\0\u0210"+ + "\0\u0252\0\102\0\102\0\102\0\102\0\102\0\u0294\0\102"+ + "\0\102\0\u02d6\0\u0318\0\u035a\0\u039c\0\u03de\0\u0420\0\u0462"+ + "\0\u04a4\0\u04e6\0\u0528\0\u056a\0\u05ac\0\u05ee\0\u0630\0\u0672"+ + "\0\u06b4\0\u06f6\0\u0738\0\u077a\0\u07bc\0\u07fe\0\102\0\102"+ + "\0\u0840\0\102\0\u0882\0\u08c4\0\102\0\102\0\u0906\0\102"+ + "\0\u0948\0\102\0\u098a\0\102\0\102\0\102\0\u09cc\0\102"+ + "\0\102\0\102\0\u0a0e\0\u0a50\0\u0a92\0\u0ad4\0\u0b16\0\u0b58"+ + "\0\u0b9a\0\u0bdc\0\u0c1e\0\u0c60\0\u0ca2\0\u0ce4\0\u0d26\0\u0d68"+ + "\0\u0daa\0\u0dec\0\u0e2e\0\u0e70\0\u0eb2\0\u0ef4\0\u0f36\0\u0f78"+ + "\0\u0fba\0\u0ffc\0\u103e\0\u1080\0\u10c2\0\u1104\0\u1146\0\u1188"+ + "\0\u11ca\0\u05ee\0\u120c\0\u124e\0\u1290\0\u12d2\0\u1314\0\u1356"+ + "\0\u1398\0\u13da\0\u141c\0\u145e\0\u14a0\0\u14e2\0\u1524\0\u1566"+ + "\0\u15a8\0\u15ea\0\102\0\u162c\0\u166e\0\102\0\u16b0\0\u16f2"+ + "\0\u05ee\0\u1734\0\u05ee\0\u1776\0\u17b8\0\u05ee\0\u17fa\0\u05ee"+ + "\0\u05ee\0\u05ee\0\u183c\0\u05ee\0\u187e\0\u18c0\0\u1902\0\u1944"+ + "\0\u05ee\0\u1986\0\u05ee\0\u19c8\0\u05ee\0\u1a0a\0\u1a4c\0\u1a8e"+ + "\0\u1ad0\0\u1b12\0\u1b54\0\u1b96\0\u1bd8\0\u1c1a\0\u1c5c\0\u1c9e"+ + "\0\u1ce0\0\u05ee\0\u1d22\0\u1d64\0\u05ee\0\u1da6\0\u05ee\0\u1de8"+ + "\0\u1e2a\0\u05ee\0\u1e6c\0\u1eae\0\u1ef0\0\u1f32\0\u05ee\0\u05ee"+ + "\0\u05ee\0\u1f74\0\u14e2\0\u15a8\0\u1fb6\0\u15ea\0\u1ff8\0\u162c"+ + "\0\u203a\0\u207c\0\u20be\0\u2100\0\u2142\0\u2184\0\u21c6\0\u05ee"+ + "\0\u2208\0\u05ee\0\u224a\0\u228c\0\u05ee\0\u05ee\0\u22ce\0\u05ee"+ + "\0\u05ee\0\u2310\0\u2352\0\u2394\0\u23d6\0\u2418\0\u245a\0\u05ee"+ + "\0\u249c\0\u05ee\0\u24de\0\u05ee\0\u05ee\0\u2520\0\u2562\0\u05ee"+ + "\0\u25a4\0\u05ee\0\u25e6\0\u2628\0\u266a\0\u26ac\0\u05ee\0\u26ee"+ + "\0\u05ee\0\u05ee\0\u2730\0\u2772\0\u05ee\0\u27b4\0\u27f6\0\u2838"+ + "\0\u287a\0\u28bc\0\u28fe\0\u05ee\0\u2940\0\u2982\0\u29c4\0\u2a06"+ + "\0\u2a48\0\u2a8a\0\u2acc\0\u05ee\0\u05ee\0\u05ee\0\u2b0e\0\u2b50"+ + "\0\u2b92\0\u2bd4\0\u2c16\0\u2c58\0\u05ee\0\u2c9a\0\u2cdc\0\u2d1e"+ + "\0\u05ee\0\u2d60\0\u2da2\0\u05ee\0\u2de4\0\u2e26\0\u2e68\0\u2eaa"+ + "\0\u05ee\0\u05ee\0\u2eec\0\u2f2e\0\u2f70\0\u05ee\0\u2fb2\0\u05ee"+ + "\0\u05ee\0\u2ff4\0\u05ee\0\u05ee\0\u3036\0\u3078\0\u30ba\0\u30fc"+ + "\0\u05ee\0\u313e\0\u3180\0\u31c2\0\u05ee\0\u05ee\0\u05ee\0\u3204"+ + "\0\u3246\0\u05ee"; private static int [] zzUnpackRowMap() { - int [] result = new int[216]; + int [] result = new int[282]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -269,122 +290,206 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { "\1\12\1\13\1\14\1\15\1\16\1\17\1\20\1\21"+ "\1\22\1\23\1\24\1\25\1\26\1\27\1\30\1\31"+ "\1\32\1\33\1\34\1\35\1\36\1\37\1\40\1\41"+ - "\1\42\1\43\1\44\2\45\1\46\1\45\1\47\1\50"+ - "\3\45\1\51\1\52\1\53\2\45\1\54\1\55\1\2"+ - "\1\56\1\2\1\57\2\45\2\60\2\45\1\2\2\56"+ - "\103\0\1\61\103\0\1\62\101\0\1\63\1\64\77\0"+ - "\1\65\4\0\1\66\66\0\1\67\5\0\1\63\75\0"+ - "\1\70\2\0\1\15\77\0\1\71\1\72\1\73\72\0"+ - "\1\74\3\0\1\75\106\0\1\76\102\0\1\45\1\77"+ - "\1\100\3\45\1\101\1\102\23\45\2\0\11\45\32\0"+ - "\12\45\1\103\20\45\2\0\11\45\32\0\11\45\1\104"+ - "\1\105\2\45\1\106\1\45\1\107\13\45\2\0\11\45"+ - "\32\0\13\45\1\110\17\45\2\0\11\45\32\0\12\45"+ - "\1\111\20\45\2\0\11\45\32\0\13\45\1\112\17\45"+ - "\2\0\11\45\32\0\11\45\1\113\5\45\1\114\13\45"+ - "\2\0\11\45\32\0\17\45\1\115\13\45\2\0\11\45"+ - "\32\0\15\45\1\116\15\45\2\0\11\45\32\0\6\45"+ - "\1\117\1\120\11\45\1\121\11\45\2\0\11\45\32\0"+ - "\7\45\1\122\23\45\2\0\11\45\32\0\33\45\2\0"+ - "\11\45\32\0\7\45\1\123\1\124\7\45\1\125\4\45"+ - "\1\126\5\45\2\0\11\45\32\0\4\45\1\127\2\45"+ - "\1\130\14\45\1\131\6\45\2\0\11\45\32\0\17\45"+ - "\1\132\13\45\2\0\11\45\32\0\1\133\3\45\1\134"+ - "\26\45\2\0\11\45\32\0\1\135\11\45\1\136\4\45"+ - "\1\137\13\45\2\0\11\45\32\0\7\45\1\140\23\45"+ - "\2\0\11\45\32\0\3\45\1\141\27\45\2\0\11\45"+ - "\2\0\62\55\1\142\1\143\14\55\30\0\1\144\1\145"+ - "\17\144\1\146\11\144\2\0\1\144\1\60\2\144\2\60"+ - "\1\0\1\144\33\0\33\144\2\0\1\144\1\60\2\144"+ - "\2\60\1\0\1\144\3\0\64\63\1\56\11\63\1\56"+ - "\1\63\12\0\1\147\65\0\6\150\1\151\71\150\12\0"+ - "\1\152\115\0\2\45\1\153\30\45\2\0\11\45\32\0"+ - "\2\45\1\154\30\45\2\0\11\45\32\0\6\45\1\155"+ - "\24\45\2\0\11\45\32\0\10\45\1\156\22\45\2\0"+ - "\11\45\32\0\3\45\1\157\27\45\2\0\11\45\32\0"+ - "\3\45\1\160\23\45\1\161\3\45\2\0\11\45\32\0"+ - "\20\45\1\162\12\45\2\0\11\45\32\0\30\45\1\163"+ - "\2\45\2\0\11\45\32\0\20\45\1\164\12\45\2\0"+ - "\11\45\32\0\15\45\1\165\15\45\2\0\11\45\32\0"+ - "\7\45\1\166\23\45\2\0\11\45\32\0\11\45\1\167"+ - "\21\45\2\0\11\45\32\0\3\45\1\170\27\45\2\0"+ - "\11\45\32\0\7\45\1\171\23\45\2\0\11\45\32\0"+ - "\3\45\1\172\3\45\1\173\23\45\2\0\11\45\32\0"+ - "\2\45\1\174\30\45\2\0\11\45\32\0\2\45\1\175"+ - "\30\45\2\0\11\45\32\0\12\45\1\176\20\45\2\0"+ - "\11\45\32\0\1\177\2\45\1\200\7\45\1\201\10\45"+ - "\1\202\6\45\2\0\11\45\32\0\15\45\1\203\15\45"+ - "\2\0\11\45\32\0\3\45\1\204\27\45\2\0\11\45"+ - "\32\0\11\45\1\205\21\45\2\0\11\45\32\0\24\45"+ - "\1\206\6\45\2\0\11\45\32\0\25\45\1\207\5\45"+ - "\2\0\11\45\32\0\11\45\1\210\21\45\2\0\11\45"+ - "\32\0\11\45\1\211\21\45\2\0\11\45\32\0\10\45"+ - "\1\212\22\45\2\0\11\45\32\0\4\45\1\213\26\45"+ - "\2\0\11\45\32\0\11\45\1\214\3\45\1\215\15\45"+ - "\2\0\11\45\32\0\5\45\1\216\25\45\2\0\11\45"+ - "\32\0\7\45\1\217\23\45\2\0\11\45\32\0\4\45"+ - "\1\220\26\45\2\0\11\45\32\0\3\45\1\221\27\45"+ - "\2\0\11\45\32\0\4\45\1\222\26\45\2\0\11\45"+ - "\32\0\33\223\2\0\6\223\1\0\1\223\3\0\64\55"+ - "\1\0\13\55\30\0\33\144\2\0\6\144\1\0\1\144"+ - "\33\0\33\144\2\0\1\144\2\224\1\144\1\224\1\144"+ - "\1\0\1\144\33\0\2\225\3\144\1\225\2\144\2\225"+ - "\13\144\1\225\5\144\2\0\1\144\1\225\1\226\3\225"+ - "\1\0\1\144\3\0\6\150\1\227\77\150\1\227\5\150"+ - "\1\230\63\150\30\0\3\45\1\231\27\45\2\0\11\45"+ - "\32\0\11\45\1\232\21\45\2\0\11\45\32\0\11\45"+ - "\1\233\21\45\2\0\11\45\32\0\2\45\1\234\30\45"+ - "\2\0\11\45\32\0\5\45\1\235\25\45\2\0\11\45"+ - "\32\0\11\45\1\236\21\45\2\0\11\45\32\0\11\45"+ - "\1\237\21\45\2\0\11\45\32\0\16\45\1\240\14\45"+ - "\2\0\11\45\32\0\11\45\1\241\21\45\2\0\11\45"+ - "\32\0\20\45\1\242\12\45\2\0\11\45\32\0\5\45"+ - "\1\243\25\45\2\0\11\45\32\0\11\45\1\244\21\45"+ - "\2\0\11\45\32\0\1\245\32\45\2\0\11\45\32\0"+ - "\11\45\1\246\21\45\2\0\11\45\32\0\23\45\1\247"+ - "\7\45\2\0\11\45\32\0\7\45\1\250\23\45\2\0"+ - "\11\45\32\0\6\45\1\251\24\45\2\0\11\45\32\0"+ - "\7\45\1\252\23\45\2\0\11\45\32\0\12\45\1\253"+ - "\20\45\2\0\11\45\32\0\3\45\1\254\27\45\2\0"+ - "\11\45\32\0\10\45\1\255\22\45\2\0\11\45\32\0"+ - "\23\45\1\256\7\45\2\0\11\45\32\0\3\45\1\257"+ - "\27\45\2\0\11\45\32\0\15\45\1\260\15\45\2\0"+ - "\11\45\32\0\2\226\3\144\1\226\2\144\2\226\13\144"+ - "\1\226\5\144\2\0\1\144\1\226\1\144\3\226\1\0"+ - "\1\144\3\0\6\150\1\227\5\150\1\56\63\150\30\0"+ - "\4\45\1\261\26\45\2\0\11\45\32\0\4\45\1\262"+ - "\26\45\2\0\11\45\32\0\14\45\1\263\16\45\2\0"+ - "\11\45\32\0\17\45\1\264\13\45\2\0\11\45\32\0"+ - "\3\45\1\265\27\45\2\0\11\45\32\0\7\45\1\266"+ - "\23\45\2\0\11\45\32\0\12\45\1\267\20\45\2\0"+ - "\11\45\32\0\5\45\1\270\25\45\2\0\11\45\32\0"+ - "\15\45\1\271\15\45\2\0\11\45\32\0\6\45\1\272"+ - "\24\45\2\0\11\45\32\0\15\45\1\273\15\45\2\0"+ - "\11\45\32\0\1\274\32\45\2\0\11\45\32\0\7\45"+ - "\1\275\23\45\2\0\11\45\32\0\1\276\32\45\2\0"+ - "\11\45\32\0\3\45\1\277\27\45\2\0\11\45\32\0"+ - "\15\45\1\300\15\45\2\0\11\45\32\0\6\45\1\301"+ - "\24\45\2\0\11\45\32\0\10\45\1\302\22\45\2\0"+ - "\11\45\32\0\2\45\1\303\30\45\2\0\11\45\32\0"+ - "\3\45\1\304\27\45\2\0\11\45\32\0\11\45\1\305"+ - "\21\45\2\0\11\45\32\0\11\45\1\306\21\45\2\0"+ - "\11\45\32\0\3\45\1\307\27\45\2\0\11\45\32\0"+ - "\3\45\1\310\27\45\2\0\11\45\32\0\30\45\1\311"+ - "\2\45\2\0\11\45\32\0\5\45\1\312\25\45\2\0"+ - "\11\45\32\0\7\45\1\313\23\45\2\0\11\45\32\0"+ - "\22\45\1\314\10\45\2\0\11\45\32\0\2\45\1\315"+ - "\30\45\2\0\11\45\32\0\3\45\1\316\27\45\2\0"+ - "\11\45\32\0\2\45\1\317\30\45\2\0\11\45\32\0"+ - "\15\45\1\320\15\45\2\0\11\45\32\0\11\45\1\321"+ - "\21\45\2\0\11\45\32\0\3\45\1\322\27\45\2\0"+ - "\11\45\32\0\3\45\1\323\27\45\2\0\11\45\32\0"+ - "\15\45\1\324\15\45\2\0\11\45\32\0\17\45\1\325"+ - "\13\45\2\0\11\45\32\0\23\45\1\326\7\45\2\0"+ - "\11\45\32\0\7\45\1\327\23\45\2\0\11\45\32\0"+ - "\11\45\1\330\21\45\2\0\11\45\2\0"; + "\1\42\1\43\1\44\1\45\1\46\1\47\1\46\1\50"+ + "\1\51\2\46\1\52\1\53\1\54\1\55\2\46\1\56"+ + "\1\46\1\57\1\60\1\61\1\2\1\62\1\46\1\63"+ + "\2\46\2\64\1\46\1\2\2\62\105\0\1\65\105\0"+ + "\1\66\103\0\1\67\1\70\101\0\1\71\4\0\1\72"+ + "\70\0\1\73\5\0\1\67\77\0\1\74\2\0\1\15"+ + "\101\0\1\75\1\76\1\77\74\0\1\100\3\0\1\101"+ + "\110\0\1\102\104\0\1\46\1\103\1\104\3\46\1\105"+ + "\1\106\15\46\1\107\5\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\110\1\111\20\46\2\0\1\46\2\0"+ + "\10\46\32\0\3\46\1\112\5\46\1\113\1\114\2\46"+ + "\1\115\1\46\1\116\13\46\2\0\1\46\2\0\10\46"+ + "\32\0\4\46\1\117\6\46\1\120\17\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\121\1\122\20\46\2\0"+ + "\1\46\2\0\10\46\32\0\13\46\1\123\17\46\2\0"+ + "\1\46\2\0\10\46\32\0\11\46\1\124\5\46\1\125"+ + "\13\46\2\0\1\46\2\0\10\46\32\0\17\46\1\126"+ + "\13\46\2\0\1\46\2\0\10\46\32\0\15\46\1\127"+ + "\15\46\2\0\1\46\2\0\10\46\32\0\6\46\1\130"+ + "\1\131\11\46\1\132\1\46\1\133\7\46\2\0\1\46"+ + "\2\0\10\46\32\0\7\46\1\134\23\46\2\0\1\46"+ + "\2\0\10\46\32\0\15\46\1\135\15\46\2\0\1\46"+ + "\2\0\10\46\32\0\33\46\2\0\1\46\2\0\10\46"+ + "\32\0\7\46\1\136\1\137\7\46\1\140\4\46\1\141"+ + "\5\46\2\0\1\46\2\0\10\46\32\0\4\46\1\142"+ + "\2\46\1\143\14\46\1\144\6\46\2\0\1\46\2\0"+ + "\10\46\32\0\17\46\1\145\13\46\2\0\1\46\2\0"+ + "\10\46\32\0\1\146\32\46\2\0\1\46\2\0\10\46"+ + "\32\0\1\147\3\46\1\150\26\46\2\0\1\46\2\0"+ + "\10\46\32\0\1\151\11\46\1\152\4\46\1\153\13\46"+ + "\2\0\1\46\2\0\10\46\32\0\7\46\1\154\23\46"+ + "\2\0\1\46\2\0\10\46\32\0\3\46\1\155\27\46"+ + "\2\0\1\46\2\0\10\46\2\0\65\61\1\156\1\157"+ + "\13\61\30\0\1\160\1\161\17\160\1\162\11\160\2\0"+ + "\1\160\2\0\1\160\1\64\2\160\2\64\34\0\33\160"+ + "\2\0\1\160\2\0\1\160\1\64\2\160\2\64\4\0"+ + "\67\67\1\62\10\67\1\62\1\67\12\0\1\163\67\0"+ + "\6\164\1\165\73\164\12\0\1\166\117\0\2\46\1\167"+ + "\30\46\2\0\1\46\2\0\10\46\32\0\2\46\1\170"+ + "\30\46\2\0\1\46\2\0\10\46\32\0\6\46\1\171"+ + "\23\46\1\172\2\0\1\46\2\0\10\46\32\0\10\46"+ + "\1\173\22\46\2\0\1\46\2\0\10\46\32\0\3\46"+ + "\1\174\27\46\2\0\1\46\2\0\10\46\32\0\25\46"+ + "\1\175\5\46\2\0\1\46\2\0\10\46\32\0\3\46"+ + "\1\176\27\46\2\0\1\46\2\0\10\46\32\0\11\46"+ + "\1\177\21\46\2\0\1\46\2\0\10\46\32\0\3\46"+ + "\1\200\23\46\1\201\3\46\2\0\1\46\2\0\10\46"+ + "\32\0\20\46\1\202\12\46\2\0\1\46\2\0\10\46"+ + "\32\0\7\46\1\203\20\46\1\204\2\46\2\0\1\46"+ + "\2\0\10\46\32\0\20\46\1\205\12\46\2\0\1\46"+ + "\2\0\10\46\32\0\15\46\1\206\15\46\2\0\1\46"+ + "\2\0\10\46\32\0\15\46\1\207\15\46\2\0\1\46"+ + "\2\0\10\46\32\0\6\46\1\210\24\46\2\0\1\46"+ + "\2\0\10\46\32\0\7\46\1\211\23\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\212\21\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\213\27\46\2\0\1\46"+ + "\2\0\10\46\32\0\7\46\1\214\23\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\215\3\46\1\216\23\46"+ + "\2\0\1\46\2\0\10\46\32\0\2\46\1\217\30\46"+ + "\2\0\1\46\2\0\10\46\32\0\2\46\1\220\30\46"+ + "\2\0\1\46\2\0\10\46\32\0\12\46\1\221\20\46"+ + "\2\0\1\46\2\0\10\46\32\0\1\222\2\46\1\223"+ + "\7\46\1\224\10\46\1\225\6\46\2\0\1\46\2\0"+ + "\10\46\32\0\11\46\1\226\21\46\2\0\1\46\2\0"+ + "\10\46\32\0\3\46\1\227\11\46\1\230\15\46\2\0"+ + "\1\46\2\0\10\46\32\0\2\46\1\231\30\46\2\0"+ + "\1\46\2\0\10\46\32\0\3\46\1\232\27\46\2\0"+ + "\1\46\2\0\10\46\32\0\11\46\1\233\21\46\2\0"+ + "\1\46\2\0\10\46\32\0\24\46\1\234\6\46\2\0"+ + "\1\46\2\0\10\46\32\0\25\46\1\235\5\46\2\0"+ + "\1\46\2\0\10\46\32\0\5\46\1\236\3\46\1\237"+ + "\21\46\2\0\1\46\2\0\10\46\32\0\11\46\1\240"+ + "\21\46\2\0\1\46\2\0\10\46\32\0\10\46\1\241"+ + "\22\46\2\0\1\46\2\0\10\46\32\0\4\46\1\242"+ + "\26\46\2\0\1\46\2\0\10\46\32\0\4\46\1\243"+ + "\26\46\2\0\1\46\2\0\10\46\32\0\11\46\1\244"+ + "\3\46\1\245\15\46\2\0\1\46\2\0\10\46\32\0"+ + "\5\46\1\246\25\46\2\0\1\46\2\0\10\46\32\0"+ + "\7\46\1\247\23\46\2\0\1\46\2\0\10\46\32\0"+ + "\4\46\1\250\26\46\2\0\1\46\2\0\10\46\32\0"+ + "\3\46\1\251\27\46\2\0\1\46\2\0\10\46\32\0"+ + "\4\46\1\252\26\46\2\0\1\46\2\0\10\46\32\0"+ + "\33\253\2\0\1\253\2\0\6\253\4\0\67\61\1\0"+ + "\12\61\30\0\33\160\2\0\1\160\2\0\6\160\34\0"+ + "\33\160\2\0\1\160\2\0\1\160\2\254\1\160\1\254"+ + "\1\160\34\0\2\255\3\160\1\255\2\160\2\255\13\160"+ + "\1\255\5\160\2\0\1\160\2\0\1\160\1\255\1\256"+ + "\3\255\4\0\6\164\1\257\101\164\1\257\5\164\1\260"+ + "\65\164\30\0\3\46\1\261\27\46\2\0\1\46\2\0"+ + "\10\46\32\0\11\46\1\262\21\46\2\0\1\46\2\0"+ + "\10\46\32\0\1\263\32\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\264\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\17\46\1\265\13\46\2\0\1\46\2\0\10\46"+ + "\32\0\24\46\1\266\6\46\2\0\1\46\2\0\10\46"+ + "\32\0\5\46\1\267\25\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\270\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\30\46\1\271\2\46\2\0\1\46\2\0\10\46"+ + "\32\0\2\46\1\272\30\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\273\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\5\46\1\274\25\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\275\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\276\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\16\46\1\277\14\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\300\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\20\46\1\301\12\46\2\0\1\46\2\0\10\46"+ + "\32\0\5\46\1\302\25\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\303\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\1\304\32\46\2\0\1\46\2\0\10\46\32\0"+ + "\11\46\1\305\21\46\2\0\1\46\2\0\10\46\32\0"+ + "\7\46\1\306\23\46\2\0\1\46\2\0\10\46\32\0"+ + "\15\46\1\307\15\46\2\0\1\46\2\0\10\46\32\0"+ + "\23\46\1\310\7\46\2\0\1\46\2\0\10\46\32\0"+ + "\3\46\1\311\27\46\2\0\1\46\2\0\10\46\32\0"+ + "\7\46\1\312\23\46\2\0\1\46\2\0\10\46\32\0"+ + "\6\46\1\313\24\46\2\0\1\46\2\0\10\46\32\0"+ + "\11\46\1\314\21\46\2\0\1\46\2\0\10\46\32\0"+ + "\7\46\1\315\23\46\2\0\1\46\2\0\10\46\32\0"+ + "\12\46\1\316\20\46\2\0\1\46\2\0\10\46\32\0"+ + "\3\46\1\317\27\46\2\0\1\46\2\0\10\46\32\0"+ + "\10\46\1\320\22\46\2\0\1\46\2\0\10\46\32\0"+ + "\23\46\1\321\7\46\2\0\1\46\2\0\10\46\32\0"+ + "\3\46\1\322\27\46\2\0\1\46\2\0\10\46\32\0"+ + "\15\46\1\323\15\46\2\0\1\46\2\0\10\46\32\0"+ + "\2\256\3\160\1\256\2\160\2\256\13\160\1\256\5\160"+ + "\2\0\1\160\2\0\1\160\1\256\1\160\3\256\4\0"+ + "\6\164\1\257\5\164\1\62\65\164\30\0\4\46\1\324"+ + "\26\46\2\0\1\46\2\0\10\46\32\0\4\46\1\325"+ + "\26\46\2\0\1\46\2\0\10\46\32\0\22\46\1\326"+ + "\10\46\2\0\1\46\2\0\10\46\32\0\4\46\1\327"+ + "\26\46\2\0\1\46\2\0\10\46\32\0\4\46\1\330"+ + "\26\46\2\0\1\46\2\0\10\46\32\0\2\46\1\331"+ + "\30\46\2\0\1\46\2\0\10\46\32\0\11\46\1\332"+ + "\21\46\2\0\1\46\2\0\10\46\32\0\30\46\1\333"+ + "\2\46\2\0\1\46\2\0\10\46\32\0\1\334\32\46"+ + "\2\0\1\46\2\0\10\46\32\0\14\46\1\335\16\46"+ + "\2\0\1\46\2\0\10\46\32\0\17\46\1\336\13\46"+ + "\2\0\1\46\2\0\10\46\32\0\3\46\1\337\27\46"+ + "\2\0\1\46\2\0\10\46\32\0\7\46\1\340\23\46"+ + "\2\0\1\46\2\0\10\46\32\0\12\46\1\341\20\46"+ + "\2\0\1\46\2\0\10\46\32\0\5\46\1\342\25\46"+ + "\2\0\1\46\2\0\10\46\32\0\3\46\1\343\27\46"+ + "\2\0\1\46\2\0\10\46\32\0\6\46\1\344\24\46"+ + "\2\0\1\46\2\0\10\46\32\0\17\46\1\345\13\46"+ + "\2\0\1\46\2\0\10\46\32\0\15\46\1\346\15\46"+ + "\2\0\1\46\2\0\10\46\32\0\6\46\1\347\24\46"+ + "\2\0\1\46\2\0\10\46\32\0\15\46\1\350\15\46"+ + "\2\0\1\46\2\0\10\46\32\0\1\351\32\46\2\0"+ + "\1\46\2\0\10\46\32\0\7\46\1\352\23\46\2\0"+ + "\1\46\2\0\10\46\32\0\1\353\32\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\354\27\46\2\0\1\46"+ + "\2\0\10\46\32\0\2\46\1\355\30\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\356\21\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\357\21\46\2\0\1\46"+ + "\2\0\10\46\32\0\2\46\1\360\30\46\2\0\1\46"+ + "\2\0\10\46\32\0\15\46\1\361\15\46\2\0\1\46"+ + "\2\0\10\46\32\0\6\46\1\362\24\46\2\0\1\46"+ + "\2\0\10\46\32\0\10\46\1\363\22\46\2\0\1\46"+ + "\2\0\10\46\32\0\2\46\1\364\30\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\365\27\46\2\0\1\46"+ + "\2\0\10\46\32\0\12\46\1\366\20\46\2\0\1\46"+ + "\2\0\10\46\32\0\4\46\1\367\26\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\370\21\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\371\21\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\372\27\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\373\27\46\2\0\1\46"+ + "\2\0\10\46\32\0\30\46\1\374\2\46\2\0\1\46"+ + "\2\0\10\46\32\0\5\46\1\375\25\46\2\0\1\46"+ + "\2\0\10\46\32\0\4\46\1\376\26\46\2\0\1\46"+ + "\2\0\10\46\32\0\11\46\1\377\21\46\2\0\1\46"+ + "\2\0\10\46\32\0\7\46\1\u0100\23\46\2\0\1\46"+ + "\2\0\10\46\32\0\22\46\1\u0101\10\46\2\0\1\46"+ + "\2\0\10\46\32\0\2\46\1\u0102\30\46\2\0\1\46"+ + "\2\0\10\46\32\0\3\46\1\u0103\27\46\2\0\1\46"+ + "\2\0\10\46\32\0\1\u0104\32\46\2\0\1\46\2\0"+ + "\10\46\32\0\15\46\1\u0105\15\46\2\0\1\46\2\0"+ + "\10\46\32\0\2\46\1\u0106\30\46\2\0\1\46\2\0"+ + "\10\46\32\0\15\46\1\u0107\15\46\2\0\1\46\2\0"+ + "\10\46\32\0\11\46\1\u0108\21\46\2\0\1\46\2\0"+ + "\10\46\32\0\3\46\1\u0109\27\46\2\0\1\46\2\0"+ + "\10\46\32\0\11\46\1\u010a\21\46\2\0\1\46\2\0"+ + "\10\46\32\0\2\46\1\u010b\30\46\2\0\1\46\2\0"+ + "\10\46\32\0\3\46\1\u010c\27\46\2\0\1\46\2\0"+ + "\10\46\32\0\15\46\1\u010d\15\46\2\0\1\46\2\0"+ + "\10\46\32\0\6\46\1\u010e\24\46\2\0\1\46\2\0"+ + "\10\46\32\0\5\46\1\u010f\25\46\2\0\1\46\2\0"+ + "\10\46\32\0\17\46\1\u0110\13\46\2\0\1\46\2\0"+ + "\10\46\32\0\10\46\1\u0111\22\46\2\0\1\46\2\0"+ + "\10\46\32\0\23\46\1\u0112\7\46\2\0\1\46\2\0"+ + "\10\46\32\0\6\46\1\u0113\24\46\2\0\1\46\2\0"+ + "\10\46\32\0\1\u0114\32\46\2\0\1\46\2\0\10\46"+ + "\32\0\7\46\1\u0115\23\46\2\0\1\46\2\0\10\46"+ + "\32\0\11\46\1\u0116\21\46\2\0\1\46\2\0\10\46"+ + "\32\0\22\46\1\u0117\10\46\2\0\1\46\2\0\10\46"+ + "\32\0\6\46\1\u0118\24\46\2\0\1\46\2\0\10\46"+ + "\32\0\6\46\1\u0119\24\46\2\0\1\46\2\0\10\46"+ + "\32\0\22\46\1\u011a\10\46\2\0\1\46\2\0\10\46"+ + "\2\0"; private static int [] zzUnpackTrans() { - int [] result = new int[9216]; + int [] result = new int[12936]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -423,13 +528,13 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { private static final String ZZ_ATTRIBUTE_PACKED_0 = "\1\0\3\11\1\1\3\11\1\1\1\11\2\1\1\11"+ - "\4\1\5\11\1\1\2\11\24\1\1\11\2\1\2\11"+ - "\1\1\1\11\1\1\1\11\1\0\3\11\1\1\3\11"+ - "\44\1\1\0\3\1\1\11\2\0\1\11\54\1\1\0"+ - "\101\1"; + "\4\1\5\11\1\1\2\11\25\1\2\11\1\1\1\11"+ + "\2\1\2\11\1\1\1\11\1\1\1\11\1\0\3\11"+ + "\1\1\3\11\54\1\1\0\3\1\1\11\2\0\1\11"+ + "\70\1\1\0\153\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[216]; + int [] result = new int[282]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -521,7 +626,7 @@ private final Symbol alloy_string(String txt) throws Err { i++; if (i>=txt.length()) throw new ErrorSyntax(p, "String literal cannot end with a single \\"); c = txt.charAt(i); - if (c=='n') c='\n'; else if (c!='\'' && c!='\"' && c!='\\') throw new ErrorSyntax(p, "String literal currenty only supports\nfour escape sequences: \\\\, \\n, \\\', and \\\""); + if (c=='n') c='\n'; else if (c!='\"' && c!='\\') throw new ErrorSyntax(p, "String literal currently only supports\nthree escape sequences: \\\\, \\n, and \\\""); } sb.append(c); } @@ -599,7 +704,7 @@ public CompLexer(java.io.InputStream in) { char [] map = new char[0x10000]; int i = 0; /* index in packed string */ int j = 0; /* index in unpacked array */ - while (i < 2264) { + while (i < 2270) { int count = packed.charAt(i++); char value = packed.charAt(i++); do map[j++] = value; while (--count > 0); @@ -922,343 +1027,399 @@ else if (zzAtEOF) { case 4: { return alloy_sym(yytext(), CompSym.AMPERSAND ); } - case 86: break; - case 50: + case 100: break; + case 52: { return alloy_sym(yytext(), CompSym.SEQ ); } - case 87: break; - case 62: + case 101: break; + case 65: { return alloy_binarynum (yytext()); } - case 88: break; - case 38: + case 102: break; + case 40: { return alloy_sym(yytext(), CompSym.IMPLIES ); } - case 89: break; + case 103: break; case 23: { return alloy_sym(yytext(), CompSym.RBRACE ); } - case 90: break; - case 82: + case 104: break; + case 99: + { return alloy_sym(yytext(), CompSym.HISTORICALLY); + } + case 105: break; + case 97: + { return alloy_sym(yytext(), CompSym.TRIGGERED ); + } + case 106: break; + case 60: + { return alloy_sym(yytext(), CompSym.VAR ); + } + case 107: break; + case 92: { return alloy_sym(yytext(), CompSym.EXACTLY ); } - case 91: break; + case 108: break; case 1: { throw new ErrorSyntax(alloy_here(" "), "Syntax error at the "+yytext()+" character. HEX: \\u"+Integer.toString(yytext().charAt(0),16)+")"); } - case 92: break; - case 53: + case 109: break; + case 55: { return alloy_sym(yytext(), CompSym.RUN ); } - case 93: break; - case 36: + case 110: break; + case 38: { return alloy_sym(yytext(), CompSym.SHL ); } - case 94: break; - case 35: + case 111: break; + case 37: { return alloy_sym(yytext(), CompSym.DOMAIN ); } - case 95: break; - case 60: + case 112: break; + case 63: { return alloy_sym(yytext(), CompSym.SIGINT ); } - case 96: break; + case 113: break; case 24: { return alloy_sym(yytext(), CompSym.TILDE ); } - case 97: break; + case 114: break; + case 96: + { return alloy_sym(yytext(), CompSym.RELEASES ); + } + case 115: break; + case 82: + { return alloy_sym(yytext(), CompSym.TIME ); + } + case 116: break; case 21: { return alloy_sym(yytext(), CompSym.LBRACE ); } - case 98: break; + case 117: break; case 7: { return alloy_sym(yytext(), CompSym.STAR ); } - case 99: break; - case 30: + case 118: break; + case 32: { return alloy_sym(yytext(), CompSym.PLUSPLUS ); } - case 100: break; - case 58: + case 119: break; + case 61: { return alloy_sym(yytext(), CompSym.FUN ); } - case 101: break; - case 81: + case 120: break; + case 91: { return alloy_sym(yytext(), CompSym.STRING ); } - case 102: break; - case 55: + case 121: break; + case 57: { return alloy_sym(yytext(), CompSym.EXH ); } - case 103: break; - case 56: + case 122: break; + case 58: { return alloy_sym(yytext(), CompSym.INT ); } - case 104: break; - case 52: + case 123: break; + case 54: { return alloy_sym(yytext(), CompSym.SIG ); } - case 105: break; - case 75: + case 124: break; + case 79: { return alloy_sym(yytext(), CompSym.PRED ); } - case 106: break; + case 125: break; case 25: { return alloy_id (yytext()); } - case 107: break; - case 66: + case 126: break; + case 83: + { return alloy_sym(yytext(), CompSym.SINCE ); + } + case 127: break; + case 69: { return alloy_sym(yytext(), CompSym.LONE ); } - case 108: break; - case 41: + case 128: break; + case 43: { return alloy_sym(yytext(), CompSym.NO ); } - case 109: break; + case 129: break; case 9: { return alloy_sym(yytext(), CompSym.COMMA ); } - case 110: break; - case 40: + case 130: break; + case 42: { return alloy_sym(yytext(), CompSym.AS ); } - case 111: break; - case 65: + case 131: break; + case 68: { return alloy_sym(yytext(), CompSym.THIS ); } - case 112: break; + case 132: break; case 13: { return alloy_sym(yytext(), CompSym.SLASH ); } - case 113: break; - case 48: + case 133: break; + case 81: + { return alloy_sym(yytext(), CompSym.AFTER ); + } + case 134: break; + case 50: { return alloy_sym(yytext(), CompSym.BUT ); } - case 114: break; - case 43: + case 135: break; + case 45: { return alloy_string(yytext()); } - case 115: break; - case 68: + case 136: break; + case 71: { return alloy_sym(yytext(), CompSym.DISJ ); } - case 116: break; - case 32: + case 137: break; + case 34: { return alloy_sym(yytext(), CompSym.SHA ); } - case 117: break; - case 39: + case 138: break; + case 27: + { return alloy_sym(yytext(), CompSym.PRIME ); + } + case 139: break; + case 41: { return alloy_sym(yytext(), CompSym.OR ); } - case 118: break; - case 45: + case 140: break; + case 47: { return alloy_sym(yytext(), CompSym.SHR ); } - case 119: break; - case 84: + case 141: break; + case 94: { return alloy_sym(yytext(), CompSym.PRIVATE ); } - case 120: break; - case 31: + case 142: break; + case 33: { return alloy_sym(yytext(), CompSym.ARROW ); } - case 121: break; - case 33: + case 143: break; + case 35: { return alloy_sym(yytext(), CompSym.GTE ); } - case 122: break; + case 144: break; case 20: { return alloy_sym(yytext(), CompSym.CARET ); } - case 123: break; - case 46: + case 145: break; + case 48: { return alloy_sym(yytext(), CompSym.IFF ); } - case 124: break; - case 69: + case 146: break; + case 26: + { return alloy_sym(yytext(), CompSym.TRCSEQ ); + } + case 147: break; + case 72: { return alloy_sym(yytext(), CompSym.ELSE ); } - case 125: break; + case 148: break; case 3: { return alloy_sym(yytext(), CompSym.HASH ); } - case 126: break; + case 149: break; case 12: { return alloy_sym(yytext(), CompSym.DOT ); } - case 127: break; + case 150: break; case 22: { return alloy_sym(yytext(), CompSym.BAR ); } - case 128: break; - case 79: + case 151: break; + case 89: { return alloy_sym(yytext(), CompSym.EXPECT ); } - case 129: break; + case 152: break; case 8: { return alloy_sym(yytext(), CompSym.PLUS ); } - case 130: break; - case 37: + case 153: break; + case 85: + { return alloy_sym(yytext(), CompSym.UNTIL ); + } + case 154: break; + case 39: { return alloy_sym(yytext(), CompSym.LTE ); } - case 131: break; - case 57: + case 155: break; + case 59: { return alloy_sym(yytext(), CompSym.ONE ); } - case 132: break; - case 73: + case 156: break; + case 77: { return alloy_sym(yytext(), CompSym.OPEN ); } - case 133: break; - case 63: + case 157: break; + case 87: + { return alloy_sym(yytext(), CompSym.ALWAYS ); + } + case 158: break; + case 66: { return alloy_hexnum (yytext()); } - case 134: break; + case 159: break; case 11: { return alloy_sym(yytext(), CompSym.GT ); } - case 135: break; - case 80: + case 160: break; + case 90: { return alloy_sym(yytext(), CompSym.MODULE ); } - case 136: break; + case 161: break; case 14: { return alloy_sym(yytext(), CompSym.COLON ); } - case 137: break; - case 51: + case 162: break; + case 53: { return alloy_sym(yytext(), CompSym.SUM ); } - case 138: break; - case 74: + case 163: break; + case 78: { return alloy_sym(yytext(), CompSym.PART ); } - case 139: break; + case 164: break; case 16: { return alloy_sym(yytext(), CompSym.EQUALS ); } - case 140: break; - case 83: + case 165: break; + case 93: { return alloy_sym(yytext(), CompSym.EXTENDS ); } - case 141: break; - case 26: + case 166: break; + case 28: { throw new ErrorSyntax(alloy_here(yytext()),"String literal is missing its closing \" character"); } - case 142: break; - case 59: + case 167: break; + case 62: { return alloy_sym(yytext(), CompSym.FOR ); } - case 143: break; - case 28: + case 168: break; + case 30: { return alloy_num (yytext()); } - case 144: break; - case 72: + case 169: break; + case 76: + { return alloy_sym(yytext(), CompSym.ONCE ); + } + case 170: break; + case 75: { return alloy_sym(yytext(), CompSym.IDEN ); } - case 145: break; + case 171: break; case 15: { return alloy_sym(yytext(), CompSym.LT ); } - case 146: break; + case 172: break; case 17: { return alloy_sym(yytext(), CompSym.AT ); } - case 147: break; - case 34: + case 173: break; + case 36: { return alloy_sym(yytext(), CompSym.RANGE ); } - case 148: break; - case 71: + case 174: break; + case 74: { return alloy_sym(yytext(), CompSym.UNIV ); } - case 149: break; + case 175: break; case 2: { return alloy_sym(yytext(), CompSym.NOT ); } - case 150: break; - case 49: + case 176: break; + case 51: { return alloy_sym(yytext(), CompSym.SET ); } - case 151: break; + case 177: break; case 6: { return alloy_sym(yytext(), CompSym.RPAREN ); } - case 152: break; - case 42: + case 178: break; + case 88: + { return alloy_sym(yytext(), CompSym.BEFORE ); + } + case 179: break; + case 98: + { return alloy_sym(yytext(), CompSym.EVENTUALLY ); + } + case 180: break; + case 44: { return alloy_sym(yytext(), CompSym.IN ); } - case 153: break; - case 77: + case 181: break; + case 84: { return alloy_sym(yytext(), CompSym.CHECK ); } - case 154: break; - case 29: + case 182: break; + case 31: { return alloy_sym(yytext(), CompSym.AND ); } - case 155: break; - case 64: + case 183: break; + case 67: { return alloy_sym(yytext(), CompSym.SOME ); } - case 156: break; - case 76: + case 184: break; + case 80: { return alloy_sym(yytext(), CompSym.FACT ); } - case 157: break; + case 185: break; case 10: { return alloy_sym(yytext(), CompSym.MINUS ); } - case 158: break; + case 186: break; case 5: { return alloy_sym(yytext(), CompSym.LPAREN ); } - case 159: break; - case 67: + case 187: break; + case 70: { return alloy_sym(yytext(), CompSym.NONE ); } - case 160: break; + case 188: break; case 18: { return alloy_sym(yytext(), CompSym.LBRACKET ); } - case 161: break; + case 189: break; case 19: { return alloy_sym(yytext(), CompSym.RBRACKET ); } - case 162: break; - case 70: + case 190: break; + case 73: { return alloy_sym(yytext(), CompSym.ENUM ); } - case 163: break; - case 47: + case 191: break; + case 49: { return alloy_sym(yytext(), CompSym.ALL ); } - case 164: break; - case 85: + case 192: break; + case 95: { return alloy_sym(yytext(), CompSym.ABSTRACT ); } - case 165: break; - case 78: + case 193: break; + case 86: { return alloy_sym(yytext(), CompSym.ASSERT ); } - case 166: break; - case 61: + case 194: break; + case 64: { throw new ErrorSyntax(alloy_here(yytext()),"String literal cannot be followed by a legal identifier character."); } - case 167: break; - case 54: + case 195: break; + case 56: { return alloy_sym(yytext(), CompSym.LET ); } - case 168: break; - case 27: + case 196: break; + case 29: { } - case 169: break; - case 44: + case 197: break; + case 46: { throw new ErrorSyntax(alloy_here(yytext()),"Name cannot start with a number."); } - case 170: break; + case 198: break; default: if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { zzAtEOF = true; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompModule.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompModule.java index 85c23ae84..7fff7c4e0 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompModule.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompModule.java @@ -85,12 +85,33 @@ import edu.mit.csail.sdg.ast.Sig.PrimSig; import edu.mit.csail.sdg.ast.Sig.SubsetSig; import edu.mit.csail.sdg.ast.Type; +import edu.mit.csail.sdg.ast.VisitQuery; import edu.mit.csail.sdg.ast.VisitQueryOnce; import edu.mit.csail.sdg.ast.VisitReturn; /** * Mutable; this class represents an Alloy module; equals() uses object * identity. + * + * @modified [electrum] adapted methods to support commands with trace prefix + * length scopes; added the detection of errors and warnings during + * signature/field/command resolution; note that up Alloy5 signature + * resolution did not throw warnings since those arose only from type + * system warnings + * + * the following warnings are thrown: if a static sig is in a variable + * sig (since this makes part of the parent immutable); if a static + * sig extends a variable sig (since this makes part of the parent + * immutable); if a variable sig extends a static sig (redundant since + * it will be immutable anyway); if a static field is declared in a + * variable sig (since this makes part of the sig immutable); if a + * static field is declared with a variable bounding expression (since + * this makes part bounding expression immutable) + * + * the following errors are thrown: if scopes are assigned to + * non-top-level variable sigs; if exact scopes are assigned to + * variable sigs; if a module declares a parameter as exact and a + * variable argument is passed */ public final class CompModule extends Browsable implements Module { @@ -588,7 +609,7 @@ else if (some) TempList n = new TempList(d.names.size()); for (ExprHasName v : d.names) n.add(ExprVar.make(v.pos, v.label, exp.type())); - Decl dd = new Decl(d.isPrivate, d.disjoint, d.disjoint2, n.makeConst(), exp); + Decl dd = new Decl(d.isPrivate, d.disjoint, d.disjoint2, null, n.makeConst(), exp); for (ExprHasName newname : dd.names) put(newname.label, newname); decls.add(dd); @@ -1483,7 +1504,11 @@ void addEnum(Pos pos, Pos priv, ExprVar name, List atoms, Pos closingBr } /** The given Sig will now point to a nonnull Sig. */ - private static Sig resolveSig(CompModule res, Set topo, Sig oldS) throws Err { + private static Sig resolveSig(CompModule res, Set topo, Sig oldS, final List warns) throws Err { + // When typechecking each sig: + // * a static sig should NOT be included in a variable sig [electrum] + // * a static sig should NOT extend a variable sig [electrum] + // * a variable sig should NOT extend a static sig [electrum] if (res.new2old.containsKey(oldS)) return oldS; Sig realSig; @@ -1499,19 +1524,26 @@ private static Sig resolveSig(CompModule res, Set topo, Sig oldS) throws Sig parentAST = u.getRawSIG(n.pos, n.label); if (parentAST == null) throw new ErrorSyntax(n.pos, "The sig \"" + n.label + "\" cannot be found."); - parents.add(resolveSig(res, topo, parentAST)); + parents.add(resolveSig(res, topo, parentAST, warns)); } realSig = new SubsetSig(fullname, parents, oldS.attributes.toArray(new Attr[0])); + for (Sig n : parents) + if (n != UNIV && n.isVariable != null && realSig.isVariable == null) + warns.add(new ErrorWarning(realSig.isSubset, "Part of " + n.label + " is static.\n" + "Sig " + realSig.label + " is static but " + n.label + " is variable.")); } else { Sig sup = ((PrimSig) oldS).parent; Sig parentAST = u.getRawSIG(sup.pos, sup.label); if (parentAST == null) throw new ErrorSyntax(sup.pos, "The sig \"" + sup.label + "\" cannot be found."); - Sig parent = resolveSig(res, topo, parentAST); + Sig parent = resolveSig(res, topo, parentAST, warns); if (!(parent instanceof PrimSig)) throw new ErrorSyntax(sup.pos, "Cannot extend the subset signature \"" + parent + "\".\n" + "A signature can only extend a toplevel signature or a subsignature."); PrimSig p = (PrimSig) parent; realSig = new PrimSig(fullname, p, oldS.attributes.toArray(new Attr[0])); + if (parent != UNIV && parent.isVariable != null && realSig.isVariable == null) + warns.add(new ErrorWarning(realSig.isSubsig, "Part of " + parent.label + " is static.\n" + "Sig " + realSig.label + " is static but " + parent.label + " is variable.")); + if (parent != UNIV && parent.isVariable == null && realSig.isVariable != null) + warns.add(new ErrorWarning(realSig.isSubsig, "Marking sig " + realSig.label + " as var is redundant.\n" + "Sig " + realSig.label + " is variable but " + parent.label + " is static.")); } res.new2old.put(realSig, oldS); res.sig2module.put(realSig, u); @@ -1566,7 +1598,7 @@ void addFunc(Pos p, Pos isPrivate, String n, Expr f, List decls, Expr t, E else decls = new ArrayList(decls); if (f != null) - decls.add(0, new Decl(null, null, null, Util.asList(ExprVar.make(f.span(), "this")), f)); + decls.add(0, new Decl(null, null, null, null, Util.asList(ExprVar.make(f.span(), "this")), f)); for (Decl d : decls) { if (d.isPrivate != null) { ExprHasName name = d.names.get(0); @@ -1618,7 +1650,7 @@ private JoinableList resolveFuncDecls(A4Reporter rep, JoinableList err tmpvars.add(v); rep.typecheck((f.isPred ? "pred " : "fun ") + fullname + ", Param " + n.label + ": " + v.type() + "\n"); } - tmpdecls.add(new Decl(d.isPrivate, d.disjoint, d.disjoint2, tmpvars.makeConst(), val)); + tmpdecls.add(new Decl(d.isPrivate, d.disjoint, d.disjoint2, null, tmpvars.makeConst(), val)); } Expr ret = null; if (!f.isPred) { @@ -1819,8 +1851,7 @@ public Expr getAllReachableFacts() { // ============================================================================================================================// /** Add a COMMAND declaration. */ - - void addCommand(boolean followUp, Pos pos, ExprVar name, boolean check, int overall, int bitwidth, int seq, int exp, List scopes, ExprVar label) throws Err { + void addCommand(boolean followUp, Pos pos, ExprVar name, boolean check, int overall, int bitwidth, int seq, int tmn, int tmx, int exp, List scopes, ExprVar label) throws Err { if (followUp && !Version.experimental) throw new ErrorSyntax(pos, "Syntax error encountering => symbol."); if (label != null) @@ -1832,7 +1863,7 @@ void addCommand(boolean followUp, Pos pos, ExprVar name, boolean check, int over throw new ErrorSyntax(pos, "Predicate/assertion name cannot contain \'@\'"); String labelName = (label == null || label.label.length() == 0) ? name.label : label.label; Command parent = followUp ? commands.get(commands.size() - 1) : null; - Command newcommand = new Command(pos, name, labelName, check, overall, bitwidth, seq, exp, scopes, null, name, parent); + Command newcommand = new Command(pos, name, labelName, check, overall, bitwidth, seq, tmn, tmx, exp, scopes, null, name, parent); if (parent != null) commands.set(commands.size() - 1, newcommand); else @@ -1840,7 +1871,7 @@ void addCommand(boolean followUp, Pos pos, ExprVar name, boolean check, int over } /** Add a COMMAND declaration. */ - void addCommand(boolean followUp, Pos pos, Expr e, boolean check, int overall, int bitwidth, int seq, int expects, List scopes, ExprVar label) throws Err { + void addCommand(boolean followUp, Pos pos, Expr e, boolean check, int overall, int bitwidth, int seq, int tmn, int tmx, int expects, List scopes, ExprVar label) throws Err { if (followUp && !Version.experimental) throw new ErrorSyntax(pos, "Syntax error encountering => symbol."); @@ -1856,7 +1887,7 @@ void addCommand(boolean followUp, Pos pos, Expr e, boolean check, int overall, i addFunc(e.span().merge(pos), Pos.UNKNOWN, n = "run$" + (1 + commands.size()), null, new ArrayList(), null, e); String labelName = (label == null || label.label.length() == 0) ? n : label.label; Command parent = followUp ? commands.get(commands.size() - 1) : null; - Command newcommand = new Command(e.span().merge(pos), e, labelName, check, overall, bitwidth, seq, expects, scopes, null, ExprVar.make(null, n), parent); + Command newcommand = new Command(e.span().merge(pos), e, labelName, check, overall, bitwidth, seq, tmn, tmx, expects, scopes, null, ExprVar.make(null, n), parent); if (parent != null) commands.set(commands.size() - 1, newcommand); else @@ -1866,7 +1897,7 @@ void addCommand(boolean followUp, Pos pos, Expr e, boolean check, int overall, i public void addDefaultCommand() { if (commands.isEmpty()) { addFunc(Pos.UNKNOWN, Pos.UNKNOWN, "$$Default", null, new ArrayList(), null, ExprConstant.TRUE); - commands.add(new Command(Pos.UNKNOWN, ExprConstant.TRUE, "Default", false, 4, 4, 4, 1, null, null, ExprVar.make(null, "$$Default"), null)); + commands.add(new Command(Pos.UNKNOWN, ExprConstant.TRUE, "Default", false, 4, 4, 4, -1, -1, 1, null, null, ExprVar.make(null, "$$Default"), null)); } } @@ -1912,13 +1943,17 @@ private Command resolveCommand(Command cmd, ConstList exactSigs, Expr globa Sig s = getRawSIG(et.sig.pos, et.sig.label); if (s == null) throw new ErrorSyntax(et.sig.pos, "The sig \"" + et.sig.label + "\" cannot be found."); + if (!s.isTopLevel() && s.isVariable != null) + throw new ErrorSyntax(cmd.pos, "Mutable sig " + et.sig + " is not top-level thus cannot have scopes assigned."); + if (et.isExact && s.isVariable != null) + throw new ErrorSyntax(cmd.pos, "Sig " + et.sig + " is variable thus scope cannot be exact."); sc.add(new CommandScope(null, s, et.isExact, et.startingScope, et.endingScope, et.increment)); } if (cmd.nameExpr != null) { cmd.nameExpr.setReferenced(declaringClause); } - return new Command(cmd.pos, cmd.nameExpr, cmd.label, cmd.check, cmd.overall, cmd.bitwidth, cmd.maxseq, cmd.expects, sc.makeConst(), exactSigs, globalFacts.and(e), parent); + return new Command(cmd.pos, cmd.nameExpr, cmd.label, cmd.check, cmd.overall, cmd.bitwidth, cmd.maxseq, cmd.minprefix, cmd.maxprefix, cmd.expects, sc.makeConst(), exactSigs, globalFacts.and(e), parent); } @@ -1961,6 +1996,8 @@ private static void resolveFieldDecl(CompModule res, final A4Reporter rep, final // visible ancestor sig // * it is allowed to refer to visible sigs // * it is NOT allowed to refer to any predicate or function + // * it should NOT to refer to variable fields/sigs unless it is also variable [electrum] + // * it should NOT to be defined in a variable sigs unless it is also variable [electrum] // For example, if A.als opens B.als, and B/SIGX extends A/SIGY, // then B/SIGX's fields cannot refer to A/SIGY, nor any fields in // A/SIGY) @@ -1990,7 +2027,22 @@ private static void resolveFieldDecl(CompModule res, final A4Reporter rep, final String[] names = new String[d.names.size()]; for (int i = 0; i < names.length; i++) names[i] = d.names.get(i).label; - Field[] fields = s.addTrickyField(d.span(), d.isPrivate, d.disjoint, d.disjoint2, null, names, bound); + Field[] fields = s.addTrickyField(d.span(), d.isPrivate, d.disjoint, d.disjoint2, null, d.isVar, names, bound); + final VisitQuery q = new VisitQuery() { + + @Override + public final Sig visit(Sig x) { + if (x.isVariable != null) + return x; + else + return null; + } + }; + Sig qr = q.visitThis(bound); + if (d.isVar == null && qr != null) + warns.add(new ErrorWarning(d.span(), "Static field types with variable bound.\n" + "Field " + d.names.get(0) + " is static but " + qr.label + " is variable.")); + if (d.isVar == null && s.isVariable != null) + warns.add(new ErrorWarning(d.span(), "Static field inside variable sig.\n" + "Field " + d.names.get(0) + " is static but " + s.label + " is variable.")); for (Field f : fields) { rep.typecheck("Sig " + s + ", Field " + f.label + ": " + f.type() + "\n"); } @@ -2122,7 +2174,7 @@ static CompModule resolveAll(final A4Reporter rep, final CompModule root) throws HashSet topo = new HashSet(); for (CompModule m : root.allModules) for (Sig s : m.sigs.values()) - resolveSig(root, topo, s); + resolveSig(root, topo, s, warns); // [electrum] sigs may also throw warnings // Add the non-defined fields to the sigs in topologically sorted order // (since fields in subsigs are allowed to refer to parent's fields) for (Sig oldS : root.new2old.keySet()) @@ -2150,8 +2202,11 @@ static CompModule resolveAll(final A4Reporter rep, final CompModule root) throws // root module's list of exact sigs for (String n : x.exactParams) { Sig sig = x.params.get(n); - if (sig != null) + if (sig != null) { + if (sig.isVariable != null) + errors = errors.make(new ErrorSyntax(root.opens.get(x.path).pos, "Module " + x.moduleName + " forces parameter to be exact but " + sig + " variable.")); root.exactSigs.add(sig); + } } } if (!errors.isEmpty()) diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompParser.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompParser.java index 729a17d2f..d36848b87 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompParser.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompParser.java @@ -1,7 +1,7 @@ //---------------------------------------------------- -// The following code was generated by CUP v0.11a beta 20060608 -// Sun Apr 08 09:54:30 PDT 2018 +// The following code was generated by CUP v0.11a czt01 beta +// Sun Feb 21 15:30:14 WET 2021 //---------------------------------------------------- package edu.mit.csail.sdg.parser; @@ -42,8 +42,8 @@ import edu.mit.csail.sdg.ast.Sig; import edu.mit.csail.sdg.ast.Sig.PrimSig; -/** CUP v0.11a beta 20060608 generated parser. - * @version Sun Apr 08 09:54:30 PDT 2018 +/** CUP v0.11a czt01 beta generated parser. + * @version Sun Feb 21 15:30:14 WET 2021 */ public class CompParser extends java_cup.runtime.lr_parser { @@ -59,7 +59,7 @@ public class CompParser extends java_cup.runtime.lr_parser { /** Production table. */ protected static final short _production_table[][] = unpackFromStrings(new String[] { - "\000\u015e\000\002\106\003\000\002\002\004\000\002\107" + + "\000\u018e\000\002\106\003\000\002\002\004\000\002\107" + "\005\000\002\107\010\000\002\107\006\000\002\107\010" + "\000\002\107\011\000\002\107\013\000\002\107\011\000" + "\002\107\010\000\002\107\005\000\002\107\006\000\002" + @@ -73,30 +73,34 @@ public class CompParser extends java_cup.runtime.lr_parser { "\002\075\006\000\002\075\004\000\002\075\002\000\002" + "\112\003\000\002\112\005\000\002\111\004\000\002\111" + "\004\000\002\111\004\000\002\111\004\000\002\111\004" + - "\000\002\111\004\000\002\111\004\000\002\110\004\000" + - "\002\110\007\000\002\110\011\000\002\110\006\000\002" + - "\110\003\000\002\110\006\000\002\110\010\000\002\110" + - "\005\000\002\051\011\000\002\051\010\000\002\051\011" + - "\000\002\051\010\000\002\051\006\000\002\052\003\000" + - "\002\052\004\000\002\037\013\000\002\037\013\000\002" + - "\037\010\000\002\037\015\000\002\037\015\000\002\037" + - "\012\000\002\067\011\000\002\067\011\000\002\067\006" + - "\000\002\067\013\000\002\067\013\000\002\067\010\000" + - "\002\123\002\000\002\123\003\000\002\076\011\000\002" + - "\100\003\000\002\100\003\000\002\100\003\000\002\100" + - "\003\000\002\100\003\000\002\101\003\000\002\101\004" + - "\000\002\077\004\000\002\077\004\000\002\077\004\000" + - "\002\077\002\000\002\102\003\000\002\102\003\000\002" + - "\102\003\000\002\102\003\000\002\102\005\000\002\102" + - "\003\000\002\104\002\000\002\104\003\000\002\103\003" + - "\000\002\103\005\000\002\105\003\000\002\105\005\000" + - "\002\053\003\000\002\053\005\000\002\053\005\000\002" + - "\054\003\000\002\054\005\000\002\055\003\000\002\055" + - "\005\000\002\056\003\000\002\056\004\000\002\056\005" + - "\000\002\056\006\000\002\014\006\000\002\014\006\000" + - "\002\014\006\000\002\014\007\000\002\014\006\000\002" + - "\014\005\000\002\014\007\000\002\014\007\000\002\014" + - "\007\000\002\014\010\000\002\014\007\000\002\014\006" + + "\000\002\111\004\000\002\111\004\000\002\111\004\000" + + "\002\110\004\000\002\110\007\000\002\110\006\000\002" + + "\110\011\000\002\110\006\000\002\110\003\000\002\110" + + "\006\000\002\110\005\000\002\110\010\000\002\110\005" + + "\000\002\051\011\000\002\051\010\000\002\051\011\000" + + "\002\051\010\000\002\051\006\000\002\052\003\000\002" + + "\052\004\000\002\037\013\000\002\037\013\000\002\037" + + "\010\000\002\037\015\000\002\037\015\000\002\037\012" + + "\000\002\067\011\000\002\067\011\000\002\067\006\000" + + "\002\067\013\000\002\067\013\000\002\067\010\000\002" + + "\123\002\000\002\123\003\000\002\076\011\000\002\100" + + "\003\000\002\100\003\000\002\100\003\000\002\100\003" + + "\000\002\100\003\000\002\100\003\000\002\101\003\000" + + "\002\101\004\000\002\077\004\000\002\077\004\000\002" + + "\077\004\000\002\077\002\000\002\102\003\000\002\102" + + "\003\000\002\102\003\000\002\102\003\000\002\102\003" + + "\000\002\102\005\000\002\102\003\000\002\104\002\000" + + "\002\104\003\000\002\103\003\000\002\103\005\000\002" + + "\105\003\000\002\105\005\000\002\053\003\000\002\053" + + "\005\000\002\053\005\000\002\054\003\000\002\054\005" + + "\000\002\055\003\000\002\055\005\000\002\056\003\000" + + "\002\056\004\000\002\056\005\000\002\056\006\000\002" + + "\014\006\000\002\014\006\000\002\014\006\000\002\014" + + "\007\000\002\014\006\000\002\014\005\000\002\014\007" + + "\000\002\014\010\000\002\014\007\000\002\014\006\000" + + "\002\014\007\000\002\014\007\000\002\014\007\000\002" + + "\014\010\000\002\014\007\000\002\014\006\000\002\014" + + "\010\000\002\014\011\000\002\014\010\000\002\014\007" + "\000\002\015\003\000\002\015\006\000\002\015\006\000" + "\002\015\006\000\002\015\007\000\002\015\006\000\002" + "\015\005\000\002\015\007\000\002\015\007\000\002\015" + @@ -106,1919 +110,2491 @@ public class CompParser extends java_cup.runtime.lr_parser { "\017\005\000\002\017\004\000\002\050\006\000\002\050" + "\007\000\002\032\002\000\002\032\003\000\002\031\005" + "\000\002\031\004\000\002\033\003\000\002\033\004\000" + - "\002\034\004\000\002\034\003\000\002\035\002\000\002" + - "\035\003\000\002\036\003\000\002\036\005\000\002\030" + - "\003\000\002\030\003\000\002\030\003\000\002\005\004" + - "\000\002\005\005\000\002\005\005\000\002\005\005\000" + - "\002\005\005\000\002\005\005\000\002\005\005\000\002" + - "\063\003\000\002\063\005\000\002\064\003\000\002\064" + - "\005\000\002\025\003\000\002\025\005\000\002\026\003" + - "\000\002\026\005\000\002\040\003\000\002\040\003\000" + - "\002\042\003\000\002\042\007\000\002\044\007\000\002" + - "\044\005\000\002\042\007\000\002\044\005\000\002\041" + - "\003\000\002\041\003\000\002\043\003\000\002\043\007" + - "\000\002\045\007\000\002\045\005\000\002\002\003\000" + - "\002\002\005\000\002\003\003\000\002\003\005\000\002" + - "\057\003\000\002\057\004\000\002\057\004\000\002\060" + - "\003\000\002\060\004\000\002\010\005\000\002\010\005" + - "\000\002\010\005\000\002\010\005\000\002\010\005\000" + - "\002\010\005\000\002\010\005\000\002\010\005\000\002" + + "\002\033\005\000\002\034\004\000\002\034\003\000\002" + + "\034\006\000\002\035\002\000\002\035\003\000\002\036" + + "\003\000\002\036\005\000\002\030\003\000\002\030\005" + + "\000\002\126\003\000\002\126\003\000\002\126\003\000" + + "\002\005\004\000\002\005\005\000\002\005\005\000\002" + + "\005\005\000\002\005\005\000\002\005\005\000\002\005" + + "\005\000\002\063\003\000\002\063\005\000\002\064\003" + + "\000\002\064\005\000\002\025\003\000\002\025\005\000" + + "\002\026\003\000\002\026\005\000\002\040\003\000\002" + + "\040\003\000\002\042\003\000\002\042\007\000\002\044" + + "\007\000\002\044\005\000\002\042\007\000\002\044\005" + + "\000\002\041\003\000\002\041\003\000\002\043\003\000" + + "\002\043\007\000\002\045\007\000\002\045\005\000\002" + + "\002\003\000\002\002\005\000\002\003\003\000\002\003" + + "\005\000\002\124\003\000\002\124\005\000\002\124\005" + + "\000\002\124\005\000\002\124\005\000\002\125\003\000" + + "\002\125\005\000\002\125\005\000\002\125\005\000\002" + + "\125\005\000\002\057\003\000\002\057\004\000\002\057" + + "\004\000\002\057\004\000\002\057\004\000\002\057\004" + + "\000\002\057\004\000\002\057\004\000\002\057\004\000" + + "\002\057\004\000\002\057\004\000\002\057\004\000\002" + + "\057\004\000\002\057\004\000\002\057\004\000\002\060" + + "\003\000\002\060\004\000\002\060\004\000\002\060\004" + + "\000\002\060\004\000\002\060\004\000\002\060\004\000" + + "\002\060\004\000\002\010\005\000\002\010\005\000\002" + "\010\005\000\002\010\005\000\002\010\005\000\002\010" + - "\005\000\002\010\004\000\002\010\004\000\002\010\004" + - "\000\002\010\004\000\002\010\004\000\002\010\004\000" + - "\002\010\004\000\002\010\003\000\002\011\005\000\002" + - "\011\005\000\002\011\005\000\002\011\005\000\002\011" + - "\005\000\002\011\005\000\002\011\005\000\002\011\005" + + "\005\000\002\010\005\000\002\010\005\000\002\010\005" + + "\000\002\010\005\000\002\010\005\000\002\010\005\000" + + "\002\010\004\000\002\010\004\000\002\010\004\000\002" + + "\010\004\000\002\010\004\000\002\010\004\000\002\010" + + "\004\000\002\010\003\000\002\011\005\000\002\011\005" + "\000\002\011\005\000\002\011\005\000\002\011\005\000" + - "\002\011\005\000\002\011\004\000\002\011\004\000\002" + - "\011\004\000\002\011\004\000\002\011\004\000\002\011" + - "\004\000\002\011\004\000\002\011\003\000\002\113\003" + - "\000\002\113\005\000\002\113\005\000\002\113\005\000" + - "\002\114\003\000\002\114\005\000\002\114\005\000\002" + - "\114\005\000\002\117\003\000\002\117\005\000\002\117" + - "\005\000\002\117\005\000\002\117\005\000\002\120\003" + - "\000\002\120\005\000\002\120\005\000\002\120\005\000" + - "\002\120\005\000\002\115\003\000\002\115\005\000\002" + - "\115\005\000\002\115\005\000\002\116\003\000\002\116" + - "\005\000\002\116\005\000\002\116\005\000\002\061\003" + - "\000\002\061\004\000\002\061\004\000\002\061\004\000" + - "\002\061\004\000\002\061\004\000\002\061\004\000\002" + - "\062\003\000\002\062\004\000\002\062\004\000\002\062" + - "\004\000\002\065\003\000\002\065\005\000\002\066\003" + - "\000\002\066\005\000\002\046\003\000\002\046\005\000" + - "\002\047\003\000\002\047\005\000\002\072\003\000\002" + - "\072\003\000\002\072\003\000\002\072\003\000\002\072" + - "\003\000\002\072\003\000\002\072\003\000\002\072\003" + + "\002\011\005\000\002\011\005\000\002\011\005\000\002" + + "\011\005\000\002\011\005\000\002\011\005\000\002\011" + + "\005\000\002\011\004\000\002\011\004\000\002\011\004" + + "\000\002\011\004\000\002\011\004\000\002\011\004\000" + + "\002\011\004\000\002\011\003\000\002\113\003\000\002" + + "\113\005\000\002\113\005\000\002\113\005\000\002\114" + + "\003\000\002\114\005\000\002\114\005\000\002\114\005" + + "\000\002\117\003\000\002\117\005\000\002\117\005\000" + + "\002\117\005\000\002\117\005\000\002\120\003\000\002" + + "\120\005\000\002\120\005\000\002\120\005\000\002\120" + + "\005\000\002\115\003\000\002\115\005\000\002\115\005" + + "\000\002\115\005\000\002\116\003\000\002\116\005\000" + + "\002\116\005\000\002\116\005\000\002\061\003\000\002" + + "\061\004\000\002\061\004\000\002\061\004\000\002\061" + + "\004\000\002\061\004\000\002\061\004\000\002\062\003" + + "\000\002\062\004\000\002\062\004\000\002\062\004\000" + + "\002\065\003\000\002\065\005\000\002\066\003\000\002" + + "\066\005\000\002\046\003\000\002\046\005\000\002\047" + + "\003\000\002\047\005\000\002\072\003\000\002\072\003" + "\000\002\072\003\000\002\072\003\000\002\072\003\000" + "\002\072\003\000\002\072\003\000\002\072\003\000\002" + - "\072\003\000\002\072\003\000\002\073\003\000\002\073" + - "\005\000\002\074\003\000\002\074\005\000\002\021\003" + - "\000\002\021\005\000\002\022\003\000\002\022\005\000" + - "\002\070\003\000\002\070\005\000\002\071\003\000\002" + - "\071\005\000\002\006\003\000\002\007\003\000\002\007" + - "\006\000\002\007\006\000\002\007\006\000\002\007\006" + - "\000\002\007\006\000\002\023\003\000\002\023\005\000" + - "\002\024\003\000\002\024\005\000\002\024\005\000\002" + - "\024\005\000\002\024\005\000\002\024\005\000\002\121" + - "\004\000\002\121\004\000\002\121\004\000\002\121\004" + - "\000\002\121\004\000\002\121\004\000\002\122\003\000" + - "\002\122\004\000\002\122\004\000\002\122\004\000\002" + + "\072\003\000\002\072\003\000\002\072\003\000\002\072" + + "\003\000\002\072\003\000\002\072\003\000\002\072\003" + + "\000\002\072\003\000\002\073\003\000\002\073\005\000" + + "\002\074\003\000\002\074\005\000\002\021\003\000\002" + + "\021\005\000\002\022\003\000\002\022\005\000\002\070" + + "\003\000\002\070\005\000\002\071\003\000\002\071\005" + + "\000\002\006\003\000\002\007\003\000\002\007\006\000" + + "\002\007\006\000\002\007\006\000\002\007\006\000\002" + + "\007\006\000\002\023\003\000\002\023\005\000\002\024" + + "\003\000\002\024\005\000\002\024\005\000\002\024\005" + + "\000\002\024\005\000\002\024\005\000\002\121\004\000" + + "\002\121\004\000\002\121\004\000\002\121\004\000\002" + + "\121\004\000\002\121\004\000\002\122\003\000\002\122" + + "\004\000\002\122\004\000\002\122\004\000\002\121\004" + + "\000\002\121\004\000\002\122\004\000\002\004\003\000" + + "\002\004\003\000\002\004\003\000\002\004\003\000\002" + "\004\003\000\002\004\003\000\002\004\003\000\002\004" + - "\003\000\002\004\003\000\002\004\003\000\002\004\003" + - "\000\002\004\005\000\002\004\003\000\002\004\004\000" + - "\002\004\003\000\002\004\006\000\002\004\005" }); + "\005\000\002\004\003\000\002\004\004\000\002\004\003" + + "\000\002\004\006\000\002\004\005" }); /** Access to production table. */ + @Override public short[][] production_table() {return _production_table;} /** Parse-action table. */ protected static final short[][] _action_table = unpackFromStrings(new String[] { - "\000\u02b4\000\002\001\uffec\000\004\002\u02b6\001\002\000" + - "\032\002\001\035\026\043\010\050\017\065\016\104\006" + - "\111\021\125\027\134\012\141\024\147\013\153\030\001" + - "\uffb7\000\002\001\uffb3\000\002\001\uffef\000\014\100\242" + - "\142\053\160\046\163\044\165\u02b2\001\002\000\002\001" + - "\uffee\000\014\057\uffb6\067\uffb6\102\uffb6\126\uffb6\133\uffb6" + - "\001\uffb0\000\002\001\uffaf\000\012\100\242\142\053\160" + - "\046\163\044\001\002\000\002\001\ufff0\000\014\100\242" + - "\142\053\160\046\163\044\165\u02a1\001\002\000\002\001" + - "\uffeb\000\002\001\ufff1\000\010\142\053\160\046\163\044" + - "\001\002\000\016\035\026\104\006\125\027\134\u0294\147" + - "\013\153\030\001\002\000\010\142\053\160\046\163\044" + - "\001\002\000\002\001\uffea\000\004\075\u0252\001\uffed\000" + - "\002\001\uffb4\000\002\001\uffb2\000\002\001\uffb1\000\014" + - "\057\032\067\036\102\033\126\035\133\034\001\002\000" + - "\010\142\053\160\046\163\044\001\002\000\010\142\053" + - "\160\046\163\044\001\002\000\020\114\045\142\041\150" + - "\047\155\040\160\046\162\043\163\044\001\002\000\010" + - "\142\053\160\046\163\044\001\002\000\020\114\045\142" + - "\041\150\047\155\040\160\046\162\043\163\044\001\002" + - "\000\010\051\u020b\101\u020d\105\u020c\001\uffa9\000\002\001" + - "\uffa7\000\004\151\u0112\001\002\000\004\151\056\001\uff9d" + - "\000\002\001\uffa8\000\002\001\uff9a\000\002\001\uffa4\000" + - "\004\151\u011e\001\002\000\002\001\uffa6\000\004\055\051" + - "\001\002\000\010\142\053\160\046\163\044\001\002\000" + - "\010\051\060\101\062\105\061\001\002\000\004\151\054" + - "\001\002\000\004\163\044\001\002\000\004\151\056\001" + - "\uff9b\000\004\163\057\001\002\000\002\001\uff99\000\116" + - "\031\120\032\144\033\150\034\151\036\124\037\174\044" + - "\102\047\210\053\223\072\220\073\116\077\165\100\125" + - "\102\215\103\204\104\153\105\127\112\152\113\212\114" + - "\045\115\134\124\113\125\154\142\200\143\177\150\047" + - "\152\161\153\205\154\162\155\040\156\176\157\121\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\002" + - "\000\022\052\072\053\063\062\065\130\064\134\074\142" + - "\053\160\046\163\044\001\uff75\000\022\052\072\053\063" + - "\062\065\130\064\134\074\142\053\160\046\163\044\001" + - "\uff75\000\010\142\053\160\046\163\044\001\002\000\010" + - "\142\053\160\046\163\044\001\002\000\010\142\053\160" + - "\046\163\044\001\002\000\004\052\u01f3\001\uff74\000\002" + - "\001\uff98\000\010\051\u01bc\052\077\060\u01ef\001\002\000" + - "\002\001\uff86\000\022\052\072\053\063\062\065\130\064" + - "\134\074\142\053\160\046\163\044\001\uff75\000\004\137" + - "\u01ea\001\002\000\012\053\075\142\053\160\046\163\044" + - "\001\002\000\010\142\053\160\046\163\044\001\002\000" + - "\010\051\101\052\077\060\100\001\002\000\010\142\053" + - "\160\046\163\044\001\002\000\116\031\120\032\144\033" + - "\150\034\151\036\124\037\174\044\102\047\210\053\u01e2" + - "\072\220\073\116\077\165\100\125\102\215\103\204\104" + - "\153\105\127\112\152\113\212\114\045\115\134\124\113" + - "\125\154\142\200\143\177\150\047\152\161\153\205\154" + - "\162\155\040\156\176\157\121\160\171\161\135\162\043" + - "\163\044\164\147\165\137\001\002\000\116\031\120\032" + - "\144\033\150\034\151\036\124\037\174\044\102\047\210" + - "\053\167\072\220\073\116\077\165\100\125\102\215\103" + - "\204\104\153\105\127\112\152\113\212\114\045\115\134" + - "\124\113\125\154\142\200\143\177\150\047\152\161\153" + - "\205\154\162\155\040\156\176\157\121\160\171\161\135" + - "\162\043\163\044\164\147\165\137\001\002\000\010\142" + - "\053\160\046\163\044\001\002\000\002\001\uff53\000\002" + - "\001\uff55\000\002\001\uff61\000\006\041\u01d7\075\u01d6\001" + - "\uff47\000\002\001\uff4f\000\044\004\350\005\335\006\351" + - "\007\343\010\344\011\353\012\346\013\340\014\354\015" + - "\342\016\337\017\345\020\336\021\347\022\341\023\355" + - "\054\u01d2\001\ufed3\000\002\001\ufed5\000\002\001\ufefc\000" + - "\020\053\063\062\065\130\064\134\074\142\053\160\046" + - "\163\044\001\002\000\002\001\uff00\000\004\132\u01ce\001" + - "\ufef1\000\002\001\ufeae\000\002\001\ufef8\000\002\001\ufeac" + - "\000\102\031\120\032\144\033\150\034\151\037\174\044" + - "\102\047\210\053\223\072\220\073\116\077\165\100\125" + - "\101\312\102\215\103\204\105\127\112\152\114\045\124" + - "\113\142\041\150\047\152\161\154\162\155\040\156\176" + - "\157\121\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\002\000\002\001\uff41\000\002\001\uff43\000\062" + - "\031\120\032\144\033\150\034\151\044\102\047\210\053" + - "\223\072\220\073\116\077\165\100\125\105\127\114\045" + - "\142\041\150\047\154\162\155\040\157\121\160\171\161" + - "\135\162\043\163\044\164\147\165\137\001\002\000\126" + - "\031\120\032\144\033\150\034\151\036\124\037\174\044" + - "\102\047\210\053\u01a6\062\u01a2\072\220\073\116\077\165" + - "\100\125\102\215\103\204\104\153\105\127\112\152\113" + - "\212\114\045\115\134\124\113\125\154\130\u01a3\134\u01a9" + - "\136\246\142\200\143\177\150\047\152\161\153\205\154" + - "\162\155\040\156\176\157\121\160\171\161\135\162\043" + - "\163\044\164\147\165\137\001\002\000\002\001\uff8e\000" + - "\116\031\120\032\144\033\150\034\151\036\124\037\174" + - "\044\102\047\210\053\223\072\220\073\116\077\165\100" + - "\125\102\215\103\204\104\153\105\127\112\152\113\212" + - "\114\045\115\134\124\113\125\154\142\200\143\177\150" + - "\047\152\161\153\205\154\162\155\040\156\176\157\121" + - "\160\171\161\135\162\043\163\044\164\147\165\137\001" + - "\002\000\004\135\u019e\001\ufecf\000\002\001\ufed1\000\006" + - "\055\u019c\101\301\001\ufecb\000\002\001\ufecd\000\116\031" + - "\120\032\144\033\150\034\151\036\124\037\174\044\102" + - "\047\210\053\223\072\220\073\116\077\165\100\125\102" + - "\215\103\204\104\153\105\127\112\152\113\212\114\045" + - "\115\134\124\113\125\154\142\200\143\177\150\047\152" + - "\161\153\205\154\162\155\040\156\176\157\121\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\002\000" + - "\066\031\120\032\144\033\150\037\174\044\102\047\210" + - "\073\116\100\125\102\215\103\204\105\127\112\152\114" + - "\045\124\113\142\041\150\047\152\161\154\162\155\040" + - "\156\176\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\002\000\002\001\ufea8\000\002\001\ufeaf\000\010" + - "\144\375\145\373\146\374\001\uff13\000\002\001\uff27\000" + - "\032\060\u017e\070\u017c\071\u0177\076\u0176\106\u017f\107\u0178" + - "\116\u0175\117\u017a\120\u0179\121\u0174\122\u017d\123\u017b\001" + - "\uff3c\000\002\001\uff3f\000\002\001\ufeab\000\004\127\u0170" + - "\001\uff62\000\002\001\uff63\000\002\001\ufeb0\000\002\001" + - "\ufeaa\000\004\101\u016d\001\002\000\020\053\063\062\065" + - "\130\064\134\074\142\053\160\046\163\044\001\002\000" + - "\062\031\120\032\144\033\150\034\151\044\102\047\210" + - "\053\223\072\220\073\116\077\165\100\125\105\127\114" + - "\045\142\041\150\047\154\162\155\040\157\121\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\002\000" + - "\062\031\120\032\144\033\150\034\151\044\102\047\210" + - "\053\223\072\220\073\116\077\165\100\125\105\127\114" + - "\045\142\041\150\047\154\162\155\040\157\121\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\002\000" + - "\004\074\u012d\001\uff57\000\002\001\uff59\000\002\001\ufee7" + - "\000\002\001\ufee9\000\020\053\063\062\065\130\064\134" + - "\074\142\053\160\046\163\044\001\002\000\066\031\120" + - "\032\144\033\150\037\174\044\102\047\210\073\116\100" + - "\125\102\215\103\204\105\127\112\152\114\045\124\113" + - "\142\041\150\047\152\161\154\162\155\040\156\176\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\002" + - "\000\002\001\ufec0\000\002\001\ufec2\000\102\031\120\032" + - "\144\033\150\034\151\037\174\044\102\047\210\053\223" + - "\072\220\073\116\077\165\100\125\101\315\102\215\103" + - "\204\105\127\112\152\114\045\124\113\142\041\150\047" + - "\152\161\154\162\155\040\156\176\157\121\160\171\161" + - "\135\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\ufeb4\000\120\031\120\032\144\033\150\034\151\036" + - "\124\037\174\044\102\047\210\053\223\072\220\073\116" + - "\077\165\100\125\101\225\102\215\103\204\104\153\105" + - "\127\112\152\113\212\114\045\115\134\124\113\125\154" + - "\142\200\143\177\150\047\152\161\153\205\154\162\155" + - "\040\156\176\157\121\160\171\161\135\162\043\163\044" + - "\164\147\165\137\001\002\000\010\026\u0120\027\u0122\030" + - "\u0121\001\uff05\000\004\151\u011e\001\ufead\000\002\001\uff0a" + - "\000\004\040\u011c\001\ufeeb\000\020\053\063\062\065\130" + - "\064\134\074\142\053\160\046\163\044\001\002\000\002" + - "\001\ufeed\000\020\053\063\062\065\130\064\134\074\142" + - "\053\160\046\163\044\001\002\000\062\031\120\032\144" + - "\033\150\034\151\044\102\047\210\053\223\072\220\073" + - "\116\077\165\100\125\105\127\114\045\142\041\150\047" + - "\154\162\155\040\157\121\160\171\161\135\162\043\163" + - "\044\164\147\165\137\001\002\000\064\031\120\032\144" + - "\033\150\034\151\044\102\047\210\053\223\072\220\073" + - "\116\077\165\100\125\105\127\114\045\142\041\150\047" + - "\151\u0112\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\uffa9" + - "\000\002\001\ufec8\000\002\001\ufec9\000\020\053\063\062" + - "\065\130\064\134\074\142\053\160\046\163\044\001\002" + - "\000\062\031\120\032\144\033\150\034\151\044\102\047" + - "\210\053\223\072\220\073\116\077\165\100\125\105\127" + - "\114\045\142\041\150\047\154\162\155\040\157\121\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\002" + - "\000\002\001\uff49\000\002\001\uff51\000\066\031\120\032" + - "\144\033\150\037\174\044\102\047\210\073\116\100\125" + - "\102\215\103\204\105\127\112\152\114\045\124\113\142" + - "\041\150\047\152\161\154\162\155\040\156\176\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\002\000" + - "\002\001\ufea6\000\062\031\120\032\144\033\150\034\151" + - "\044\102\047\210\053\223\072\220\073\116\077\165\100" + - "\125\105\127\114\045\142\041\150\047\154\162\155\040" + - "\157\121\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\002\000\012\024\257\025\255\110\256\131\254" + - "\001\uff0e\000\002\001\uff12\000\010\142\053\160\046\163" + - "\044\001\002\000\002\001\uff48\000\002\001\uff50\000\100" + - "\031\120\032\144\033\150\034\151\037\174\044\102\047" + - "\210\053\223\072\220\073\116\077\165\100\125\102\215" + - "\103\204\105\127\112\152\114\045\124\113\142\041\150" + - "\047\152\161\154\162\155\040\156\176\157\121\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\002\000" + - "\002\001\ufef0\000\002\001\ufef4\000\004\101\225\001\002" + - "\000\002\001\ufef7\000\116\031\120\032\144\033\150\034" + - "\151\036\124\037\174\044\102\047\210\053\223\072\220" + - "\073\116\077\165\100\125\102\215\103\204\104\153\105" + - "\127\112\152\113\212\114\045\115\134\124\113\125\154" + - "\142\200\143\177\150\047\152\161\153\205\154\162\155" + - "\040\156\176\157\121\160\171\161\135\162\043\163\044" + - "\164\147\165\137\001\uff67\000\002\001\uff65\000\004\137" + - "\233\001\002\000\004\052\231\001\uff66\000\116\031\120" + - "\032\144\033\150\034\151\036\124\037\174\044\102\047" + - "\210\053\223\072\220\073\116\077\165\100\125\102\215" + - "\103\204\104\153\105\127\112\152\113\212\114\045\115" + - "\134\124\113\125\154\142\200\143\177\150\047\152\161" + - "\153\205\154\162\155\040\156\176\157\121\160\171\161" + - "\135\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\uff64\000\002\001\ufec6\000\004\060\236\001\002\000" + - "\002\001\uff60\000\116\031\120\032\144\033\150\034\151" + - "\036\124\037\174\044\102\047\210\053\223\072\220\073" + - "\116\077\165\100\125\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\142" + - "\200\143\177\150\047\152\161\153\205\154\162\155\040" + - "\156\176\157\121\160\171\161\135\162\043\163\044\164" + - "\147\165\137\001\002\000\010\045\243\052\240\100\242" + - "\001\002\000\010\142\053\160\046\163\044\001\002\000" + - "\002\001\uff71\000\120\031\120\032\144\033\150\034\151" + - "\036\124\037\174\044\102\047\210\053\223\072\220\073" + - "\116\077\165\100\125\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\136" + - "\246\142\200\143\177\150\047\152\161\153\205\154\162" + - "\155\040\156\176\157\121\160\171\161\135\162\043\163" + - "\044\164\147\165\137\001\002\000\116\031\120\032\144" + - "\033\150\034\151\036\124\037\174\044\102\047\210\053" + - "\223\072\220\073\116\077\165\100\125\102\215\103\204" + - "\104\153\105\127\112\152\113\212\114\045\115\134\124" + - "\113\125\154\142\200\143\177\150\047\152\161\153\205" + - "\154\162\155\040\156\176\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\uff68" + - "\000\002\001\uff69\000\002\001\uff6c\000\002\001\uff6b\000" + - "\120\031\120\032\144\033\150\034\151\036\124\037\174" + - "\044\102\047\210\053\223\072\220\073\116\077\165\100" + - "\125\102\215\103\204\104\153\105\127\112\152\113\212" + - "\114\045\115\134\124\113\125\154\136\251\142\200\143" + - "\177\150\047\152\161\153\205\154\162\155\040\156\176" + - "\157\121\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\002\000\002\001\uff6d\000\002\001\uff6a\000\002" + - "\001\uff70\000\100\031\120\032\144\033\150\034\151\037" + - "\174\044\102\047\267\053\223\072\261\073\116\077\262" + - "\100\125\102\215\103\204\105\127\112\152\114\045\124" + - "\113\142\041\150\047\152\161\154\264\155\040\156\176" + - "\157\272\160\171\161\263\162\043\163\044\164\147\165" + - "\137\001\002\000\100\031\120\032\144\033\150\034\151" + - "\037\174\044\102\047\267\053\223\072\261\073\116\077" + - "\262\100\125\102\215\103\204\105\127\112\152\114\045" + - "\124\113\142\041\150\047\152\161\154\264\155\040\156" + - "\176\157\272\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\100\031\120\032\144\033\150\034" + - "\151\037\174\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\102\215\103\204\105\127\112\152\114" + - "\045\124\113\142\041\150\047\152\161\154\264\155\040" + - "\156\176\157\272\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\100\031\120\032\144\033\150" + - "\034\151\037\174\044\102\047\267\053\223\072\261\073" + - "\116\077\262\100\125\102\215\103\204\105\127\112\152" + - "\114\045\124\113\142\041\150\047\152\161\154\264\155" + - "\040\156\176\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\004\040\332\001\ufeeb\000" + - "\062\031\120\032\144\033\150\034\151\044\102\047\267" + - "\053\223\072\261\073\116\077\262\100\125\105\127\114" + - "\045\142\041\150\047\154\264\155\040\157\272\160\171" + - "\161\263\162\043\163\044\164\147\165\137\001\002\000" + - "\064\031\120\032\144\033\150\034\151\044\102\047\267" + - "\053\223\072\261\073\116\077\262\100\125\101\315\105" + - "\127\114\045\142\041\150\047\154\264\155\040\157\272" + - "\160\171\161\263\162\043\163\044\164\147\165\137\001" + - "\002\000\050\031\120\032\144\033\150\044\102\047\267" + - "\073\116\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\050\031\120\032\144\033\150\044" + - "\102\047\267\073\116\100\125\105\127\114\045\142\041" + - "\150\047\154\264\155\040\160\171\161\263\162\043\163" + - "\044\164\147\165\137\001\002\000\044\004\350\005\335" + - "\006\351\007\343\010\344\011\353\012\346\013\340\014" + - "\354\015\342\016\337\017\345\020\336\021\347\022\341" + - "\023\355\054\334\001\ufed3\000\004\132\330\001\ufef1\000" + - "\050\031\120\032\144\033\150\044\102\047\267\073\116" + - "\100\125\105\127\114\045\142\041\150\047\154\264\155" + - "\040\160\171\161\263\162\043\163\044\164\147\165\137" + - "\001\002\000\010\026\321\027\323\030\322\001\uff02\000" + - "\006\055\302\101\301\001\ufecb\000\064\031\120\032\144" + - "\033\150\034\151\044\102\047\267\053\223\072\261\073" + - "\116\077\262\100\125\101\312\105\127\114\045\142\041" + - "\150\047\154\264\155\040\157\272\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\004\135\275" + - "\001\ufecf\000\002\001\uff07\000\060\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\073\116\077\276" + - "\100\125\105\127\114\045\142\041\150\047\154\264\155" + - "\040\157\277\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\004\101\315\001\002\000\004\101" + - "\312\001\002\000\006\055\302\101\301\001\ufeca\000\116" + - "\031\120\032\144\033\150\034\151\036\124\037\174\044" + - "\102\047\210\053\223\072\220\073\116\077\165\100\125" + - "\102\215\103\204\104\153\105\127\112\152\113\212\114" + - "\045\115\134\124\113\125\154\142\200\143\177\150\047" + - "\152\161\153\205\154\162\155\040\156\176\157\121\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\uff67" + - "\000\060\031\120\032\144\033\150\034\303\044\102\047" + - "\267\053\305\073\116\077\304\100\125\105\127\114\045" + - "\142\041\150\047\154\264\155\040\157\306\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\ufebd\000\002\001\ufebc\000\002\001\ufebe\000\002\001" + - "\ufebb\000\002\001\ufebf\000\004\137\311\001\002\000\002" + - "\001\ufec7\000\116\031\120\032\144\033\150\034\151\036" + - "\124\037\174\044\102\047\210\053\223\072\220\073\116" + - "\077\165\100\125\102\215\103\204\104\153\105\127\112" + - "\152\113\212\114\045\115\134\124\113\125\154\142\200" + - "\143\177\150\047\152\161\153\205\154\162\155\040\156" + - "\176\157\121\160\171\161\135\162\043\163\044\164\147" + - "\165\137\001\uff67\000\004\137\314\001\002\000\002\001" + - "\ufec3\000\116\031\120\032\144\033\150\034\151\036\124" + - "\037\174\044\102\047\210\053\223\072\220\073\116\077" + - "\165\100\125\102\215\103\204\104\153\105\127\112\152" + - "\113\212\114\045\115\134\124\113\125\154\142\200\143" + - "\177\150\047\152\161\153\205\154\162\155\040\156\176" + - "\157\121\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\uff67\000\004\137\317\001\002\000\002\001\ufec4" + - "\000\002\001\ufeef\000\062\031\120\032\144\033\150\034" + - "\151\044\102\047\267\053\223\072\261\073\116\077\262" + - "\100\125\105\127\114\045\142\041\150\047\154\264\155" + - "\040\157\272\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\062\031\120\032\144\033\150\034" + - "\151\044\102\047\267\053\223\072\261\073\116\077\262" + - "\100\125\105\127\114\045\142\041\150\047\154\264\155" + - "\040\157\272\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\062\031\120\032\144\033\150\034" + - "\151\044\102\047\267\053\223\072\261\073\116\077\262" + - "\100\125\105\127\114\045\142\041\150\047\154\264\155" + - "\040\157\272\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\002\001\ufefa\000\002\001\ufef9\000" + - "\002\001\ufefb\000\002\001\ufeb1\000\060\031\120\032\144" + - "\033\150\034\151\044\102\047\267\053\223\073\116\077" + - "\276\100\125\105\127\114\045\142\041\150\047\154\264" + - "\155\040\157\277\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\004\040\332\001\ufeea\000\060" + - "\031\120\032\144\033\150\034\151\044\102\047\267\053" + - "\223\073\116\077\276\100\125\105\127\114\045\142\041" + - "\150\047\154\264\155\040\157\277\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\ufee6" + - "\000\060\031\120\032\144\033\150\034\151\044\102\047" + - "\267\053\223\073\116\077\276\100\125\105\127\114\045" + - "\142\041\150\047\154\264\155\040\157\277\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\ufee4\000\002\001\ufed9\000\002\001\ufedb\000\002\001" + - "\ufede\000\002\001\ufed7\000\002\001\ufedc\000\002\001\ufee2" + - "\000\002\001\ufee1\000\002\001\ufeda\000\002\001\ufedf\000" + - "\002\001\ufed8\000\002\001\ufee5\000\002\001\ufee3\000\060" + - "\031\120\032\144\033\150\034\151\044\102\047\267\053" + - "\223\073\116\077\276\100\125\105\127\114\045\142\041" + - "\150\047\154\264\155\040\157\277\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\ufee0" + - "\000\002\001\ufedd\000\002\001\ufed6\000\002\001\ufed2\000" + - "\004\135\275\001\ufece\000\002\001\ufeb2\000\002\001\ufeb3" + - "\000\002\001\ufeee\000\010\026\321\027\323\030\322\001" + - "\uff03\000\002\001\uff08\000\010\026\321\027\323\030\322" + - "\001\uff01\000\002\001\uff06\000\010\026\321\027\323\030" + - "\322\001\uff04\000\002\001\uff09\000\010\144\375\145\373" + - "\146\374\001\uff19\000\002\001\uff2d\000\100\031\120\032" + - "\144\033\150\034\151\037\174\044\102\047\267\053\223" + - "\072\261\073\116\077\262\100\125\102\215\103\204\105" + - "\127\112\152\114\045\124\113\142\041\150\047\152\161" + - "\154\264\155\040\156\176\157\272\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\100\031\120" + - "\032\144\033\150\034\151\037\174\044\102\047\267\053" + - "\223\072\261\073\116\077\262\100\125\102\215\103\204" + - "\105\127\112\152\114\045\124\113\142\041\150\047\152" + - "\161\154\264\155\040\156\176\157\272\160\171\161\263" + - "\162\043\163\044\164\147\165\137\001\002\000\100\031" + - "\120\032\144\033\150\034\151\037\174\044\102\047\267" + - "\053\223\072\261\073\116\077\262\100\125\102\215\103" + - "\204\105\127\112\152\114\045\124\113\142\041\150\047" + - "\152\161\154\264\155\040\156\176\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\010" + - "\026\321\027\323\030\322\001\uff05\000\012\024\u0104\025" + - "\u0102\110\u0103\131\u0101\001\uff0d\000\002\001\uff11\000\062" + - "\031\120\032\144\033\150\034\151\044\102\047\267\053" + - "\223\072\261\073\116\077\262\100\125\105\127\114\045" + - "\142\041\150\047\154\264\155\040\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\062" + - "\031\120\032\144\033\150\034\151\044\102\047\267\053" + - "\223\072\261\073\116\077\262\100\125\105\127\114\045" + - "\142\041\150\047\154\264\155\040\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\062" + - "\031\120\032\144\033\150\034\151\044\102\047\267\053" + - "\223\072\261\073\116\077\262\100\125\105\127\114\045" + - "\142\041\150\047\154\264\155\040\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\062" + - "\031\120\032\144\033\150\034\151\044\102\047\267\053" + - "\223\072\261\073\116\077\262\100\125\105\127\114\045" + - "\142\041\150\047\154\264\155\040\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\012" + - "\024\u0104\025\u0102\110\u0103\131\u0101\001\uff0b\000\002\001" + - "\uff0f\000\012\024\u0104\025\u0102\110\u0103\131\u0101\001\uff0c" + - "\000\002\001\uff10\000\002\001\ufeb8\000\002\001\ufeb5\000" + - "\010\144\375\145\373\146\374\001\uff18\000\002\001\uff2c" + - "\000\002\001\uff76\000\010\045\243\052\u010f\100\242\001" + - "\002\000\020\053\063\062\065\130\064\134\074\142\053" + - "\160\046\163\044\001\002\000\002\001\uff5c\000\002\001" + - "\uff77\000\006\150\u0115\163\044\001\002\000\010\144\375" + - "\145\373\146\374\001\uff14\000\002\001\uff28\000\002\001" + - "\uffa5\000\010\144\375\145\373\146\374\001\uff15\000\002" + - "\001\uff29\000\010\045\243\052\u010f\100\242\001\002\000" + - "\002\001\uff5a\000\010\045\243\052\u010f\100\242\001\002" + - "\000\002\001\uff5f\000\076\031\120\032\144\033\150\034" + - "\151\037\174\044\102\047\267\053\223\073\116\077\276" + - "\100\125\102\215\103\204\105\127\112\152\114\045\124" + - "\113\142\041\150\047\152\161\154\264\155\040\156\176" + - "\157\277\160\171\161\263\162\043\163\044\164\147\165" + - "\137\001\002\000\002\001\ufee8\000\004\163\044\001\002" + - "\000\004\151\056\001\uff9c\000\100\031\120\032\144\033" + - "\150\034\151\037\174\044\102\047\267\053\223\072\261" + - "\073\116\077\262\100\125\102\215\103\204\105\127\112" + - "\152\114\045\124\113\142\041\150\047\152\161\154\264" + - "\155\040\156\176\157\272\160\171\161\263\162\043\163" + - "\044\164\147\165\137\001\002\000\100\031\120\032\144" + - "\033\150\034\151\037\174\044\102\047\267\053\223\072" + - "\261\073\116\077\262\100\125\102\215\103\204\105\127" + - "\112\152\114\045\124\113\142\041\150\047\152\161\154" + - "\264\155\040\156\176\157\272\160\171\161\263\162\043" + - "\163\044\164\147\165\137\001\002\000\100\031\120\032" + - "\144\033\150\034\151\037\174\044\102\047\267\053\223" + - "\072\261\073\116\077\262\100\125\102\215\103\204\105" + - "\127\112\152\114\045\124\113\142\041\150\047\152\161" + - "\154\264\155\040\156\176\157\272\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\ufefe" + - "\000\002\001\ufefd\000\002\001\ufeff\000\002\001\uff88\000" + - "\002\001\ufef2\000\002\001\ufef5\000\002\001\ufeb9\000\002" + - "\001\ufeb6\000\010\045\243\052\u010f\100\242\001\002\000" + - "\002\001\uff5d\000\116\031\120\032\144\033\150\034\151" + - "\036\u0139\037\174\044\102\047\267\053\223\072\261\073" + - "\116\077\262\100\125\102\215\103\204\104\u0138\105\127" + - "\112\152\113\u0137\114\045\115\u0130\124\113\125\u0136\142" + - "\u012e\143\u013b\150\047\152\161\153\u012f\154\264\155\040" + - "\156\176\157\272\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\064\031\120\032\144\033\150" + - "\034\151\044\102\047\267\053\223\072\261\073\116\077" + - "\262\100\125\105\127\114\045\142\041\150\047\151\u0112" + - "\154\264\155\040\157\272\160\171\161\263\162\043\163" + - "\044\164\147\165\137\001\002\000\062\031\120\032\144" + - "\033\150\034\151\044\102\047\267\053\223\072\261\073" + - "\116\077\262\100\125\105\127\114\045\142\041\150\047" + - "\154\264\155\040\157\272\160\171\161\263\162\043\163" + - "\044\164\147\165\137\001\002\000\100\031\120\032\144" + - "\033\150\034\151\036\u0139\044\102\047\267\053\223\072" + - "\261\073\116\077\262\100\125\104\u0138\105\127\113\u0137" + - "\114\045\115\u0130\125\u0136\142\u012e\143\u013b\150\047\153" + - "\u012f\154\264\155\040\157\272\160\171\161\263\162\043" + - "\163\044\164\147\165\137\001\002\000\010\144\u013f\145" + - "\u013d\146\u013e\001\uff13\000\032\060\u0156\070\u0154\071\u014f" + - "\076\u014d\106\u0157\107\u0150\116\u014e\117\u0152\120\u0151\121" + - "\u014c\122\u0155\123\u0153\001\uff3c\000\006\041\u0145\075\u0144" + - "\001\uff47\000\002\001\uff52\000\012\024\u0104\025\u0102\110" + - "\u0103\131\u0101\001\uff0e\000\062\031\120\032\144\033\150" + - "\034\151\044\102\047\267\053\223\072\261\073\116\077" + - "\262\100\125\105\127\114\045\142\041\150\047\154\264" + - "\155\040\157\272\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\062\031\120\032\144\033\150" + - "\034\151\044\102\047\267\053\223\072\261\073\116\077" + - "\262\100\125\105\127\114\045\142\041\150\047\154\264" + - "\155\040\157\272\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\062\031\120\032\144\033\150" + - "\034\151\044\102\047\267\053\223\072\261\073\116\077" + - "\262\100\125\105\127\114\045\142\041\150\047\154\264" + - "\155\040\157\272\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\062\031\120\032\144\033\150" + - "\034\151\044\102\047\267\053\223\072\261\073\116\077" + - "\262\100\125\105\127\114\045\142\041\150\047\154\264" + - "\155\040\157\272\160\171\161\263\162\043\163\044\164" + - "\147\165\137\001\002\000\002\001\uff54\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\267\053\223\072" + - "\261\073\116\077\262\100\125\105\127\114\045\142\041" + - "\150\047\154\264\155\040\157\272\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\010\144\u013f" + - "\145\u013d\146\u013e\001\uff15\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\010\144\u013f\145\u013d\146" + - "\u013e\001\uff1a\000\010\144\u013f\145\u013d\146\u013e\001\uff17" + - "\000\010\144\u013f\145\u013d\146\u013e\001\uff19\000\010\144" + - "\u013f\145\u013d\146\u013e\001\uff16\000\100\031\120\032\144" + - "\033\150\034\151\036\u0139\044\102\047\267\053\223\072" + - "\261\073\116\077\262\100\125\104\u0138\105\127\113\u0137" + - "\114\045\115\u0130\125\u0136\142\u012e\143\u013b\150\047\153" + - "\u012f\154\264\155\040\157\272\160\171\161\263\162\043" + - "\163\044\164\147\165\137\001\002\000\100\031\120\032" + - "\144\033\150\034\151\036\u0139\044\102\047\267\053\223" + - "\072\261\073\116\077\262\100\125\104\u0138\105\127\113" + - "\u0137\114\045\115\u0130\125\u0136\142\u012e\143\u013b\150\047" + - "\153\u012f\154\264\155\040\157\272\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\uff40" + - "\000\002\001\uff44\000\004\056\u0149\001\uff49\000\100\031" + - "\120\032\144\033\150\034\151\036\u0139\044\102\047\267" + - "\053\223\072\261\073\116\077\262\100\125\104\u0138\105" + - "\127\113\u0137\114\045\115\u0130\125\u0136\142\u012e\143\u013b" + - "\150\047\153\u012f\154\264\155\040\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\uff45\000\002\001\uff46\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\062\031\120\032\144\033" + - "\150\034\151\044\102\047\267\053\223\072\261\073\116" + - "\077\262\100\125\105\127\114\045\142\041\150\047\154" + - "\264\155\040\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\010\144\u013f\145\u013d\146" + - "\u013e\001\uff24\000\010\144\u013f\145\u013d\146\u013e\001\uff25" + - "\000\010\144\u013f\145\u013d\146\u013e\001\uff1e\000\010\144" + - "\u013f\145\u013d\146\u013e\001\uff23\000\010\144\u013f\145\u013d" + - "\146\u013e\001\uff1c\000\010\144\u013f\145\u013d\146\u013e\001" + - "\uff1d\000\010\144\u013f\145\u013d\146\u013e\001\uff1b\000\010" + - "\144\u013f\145\u013d\146\u013e\001\uff22\000\010\144\u013f\145" + - "\u013d\146\u013e\001\uff21\000\010\144\u013f\145\u013d\146\u013e" + - "\001\uff1f\000\010\144\u013f\145\u013d\146\u013e\001\uff26\000" + - "\010\144\u013f\145\u013d\146\u013e\001\uff20\000\002\001\uff3b" + - "\000\010\144\u013f\145\u013d\146\u013e\001\uff18\000\010\144" + - "\u013f\145\u013d\146\u013e\001\uff14\000\010\144\375\145\373" + - "\146\374\001\uff16\000\002\001\uff2a\000\010\144\375\145" + - "\373\146\374\001\uff17\000\002\001\uff2b\000\010\045\243" + - "\052\u010f\100\242\001\002\000\002\001\uff5e\000\116\031" + - "\120\032\144\033\150\034\151\036\124\037\174\044\102" + - "\047\210\053\223\072\220\073\116\077\165\100\125\102" + - "\215\103\204\104\153\105\127\112\152\113\212\114\045" + - "\115\134\124\113\125\154\142\200\143\177\150\047\152" + - "\161\153\205\154\162\155\040\156\176\157\121\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\uff67\000" + - "\004\137\u016f\001\002\000\002\001\ufec5\000\116\031\120" + - "\032\144\033\150\034\151\036\u0139\037\174\044\102\047" + - "\267\053\223\072\261\073\116\077\262\100\125\102\215" + - "\103\204\104\u0138\105\127\112\152\113\u0137\114\045\115" + - "\u0130\124\113\125\u0136\142\u012e\143\u013b\150\047\152\161" + - "\153\u012f\154\264\155\040\156\176\157\272\160\171\161" + - "\263\162\043\163\044\164\147\165\137\001\002\000\004" + - "\074\u0173\001\uff56\000\002\001\uff58\000\100\031\120\032" + - "\144\033\150\034\151\036\u0139\044\102\047\267\053\223" + - "\072\261\073\116\077\262\100\125\104\u0138\105\127\113" + - "\u0137\114\045\115\u0130\125\u0136\142\u012e\143\u013b\150\047" + - "\153\u012f\154\264\155\040\157\272\160\171\161\263\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\062\031\120" + - "\032\144\033\150\034\151\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\105\127\114\045\142\041" + - "\150\047\154\162\155\040\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\010\144\375" + - "\145\373\146\374\001\uff24\000\002\001\uff38\000\010\144" + - "\375\145\373\146\374\001\uff25\000\002\001\uff39\000\010" + - "\144\375\145\373\146\374\001\uff1e\000\002\001\uff32\000" + - "\010\144\375\145\373\146\374\001\uff23\000\002\001\uff37" + - "\000\010\144\375\145\373\146\374\001\uff1c\000\002\001" + - "\uff30\000\010\144\375\145\373\146\374\001\uff1d\000\002" + - "\001\uff31\000\010\144\375\145\373\146\374\001\uff1b\000" + - "\002\001\uff2f\000\010\144\375\145\373\146\374\001\uff22" + - "\000\002\001\uff36\000\010\144\375\145\373\146\374\001" + - "\uff21\000\002\001\uff35\000\010\144\375\145\373\146\374" + - "\001\uff26\000\002\001\uff3a\000\010\144\375\145\373\146" + - "\374\001\uff1f\000\002\001\uff33\000\010\144\375\145\373" + - "\146\374\001\uff20\000\002\001\uff34\000\002\001\ufeba\000" + - "\002\001\ufeb7\000\002\001\uff3e\000\002\001\uff3d\000\076" + - "\031\120\032\144\033\150\034\303\037\174\044\102\047" + - "\267\053\305\073\116\077\304\100\125\102\215\103\204" + - "\105\127\112\152\114\045\124\113\142\041\150\047\152" + - "\161\154\264\155\040\156\176\157\306\160\171\161\263" + - "\162\043\163\044\164\147\165\137\001\002\000\002\001" + - "\ufec1\000\076\031\120\032\144\033\150\034\151\037\174" + - "\044\102\047\267\053\223\073\116\077\276\100\125\102" + - "\215\103\204\105\127\112\152\114\045\124\113\142\041" + - "\150\047\152\161\154\264\155\040\156\176\157\277\160" + - "\171\161\263\162\043\163\044\164\147\165\137\001\002" + - "\000\002\001\ufecc\000\004\140\u01a1\001\002\000\002\001" + - "\ufea9\000\010\142\053\160\046\163\044\001\002\000\010" + - "\142\053\160\046\163\044\001\002\000\006\051\u01bc\052" + - "\077\001\002\000\012\045\243\052\u01b6\100\242\136\u01b8" + - "\001\002\000\012\101\225\142\053\160\046\163\044\001" + - "\002\000\002\001\uff78\000\006\051\uff98\052\uff98\001\uffa9" + - "\000\012\053\u01aa\142\053\160\046\163\044\001\002\000" + - "\010\142\053\160\046\163\044\001\002\000\006\051\101" + - "\052\077\001\002\000\006\051\u01ad\052\077\001\002\000" + - "\116\031\120\032\144\033\150\034\151\036\124\037\174" + - "\044\102\047\210\053\u01af\072\220\073\116\077\165\100" + - "\125\102\215\103\204\104\153\105\127\112\152\113\212" + - "\114\045\115\134\124\113\125\154\142\200\143\177\150" + - "\047\152\161\153\205\154\162\155\040\156\176\157\121" + - "\160\171\161\135\162\043\163\044\164\147\165\137\001" + - "\002\000\002\001\uff8f\000\120\031\120\032\144\033\150" + - "\034\151\036\124\037\174\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\101\225\102\215\103\204" + - "\104\153\105\127\112\152\113\212\114\045\115\134\124" + - "\113\125\154\142\200\143\177\150\047\152\161\153\205" + - "\154\162\155\040\156\176\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\uff89" + - "\000\006\051\u01b2\052\077\001\002\000\116\031\120\032" + - "\144\033\150\034\151\036\124\037\174\044\102\047\210" + - "\053\u01b4\072\220\073\116\077\165\100\125\102\215\103" + - "\204\104\153\105\127\112\152\113\212\114\045\115\134" + - "\124\113\125\154\142\200\143\177\150\047\152\161\153" + - "\205\154\162\155\040\156\176\157\121\160\171\161\135" + - "\162\043\163\044\164\147\165\137\001\002\000\002\001" + - "\uff90\000\120\031\120\032\144\033\150\034\151\036\124" + - "\037\174\044\102\047\210\053\223\072\220\073\116\077" + - "\165\100\125\101\225\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\142" + - "\200\143\177\150\047\152\161\153\205\154\162\155\040" + - "\156\176\157\121\160\171\161\135\162\043\163\044\164" + - "\147\165\137\001\002\000\002\001\uff8a\000\020\053\u01ba" + - "\062\u01a2\130\u01a3\134\u01a9\142\053\160\046\163\044\001" + - "\002\000\004\136\u01b9\001\002\000\002\001\ufea4\000\002" + - "\001\ufea5\000\010\142\053\160\046\163\044\001\002\000" + - "\002\001\uff79\000\116\031\120\032\144\033\150\034\151" + - "\036\124\037\174\044\102\047\210\053\u01be\072\220\073" + - "\116\077\165\100\125\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\142" + - "\200\143\177\150\047\152\161\153\205\154\162\155\040" + - "\156\176\157\121\160\171\161\135\162\043\163\044\164" + - "\147\165\137\001\002\000\002\001\uff8d\000\120\031\120" + - "\032\144\033\150\034\151\036\124\037\174\044\102\047" + - "\210\053\223\072\220\073\116\077\165\100\125\101\225" + - "\102\215\103\204\104\153\105\127\112\152\113\212\114" + - "\045\115\134\124\113\125\154\142\200\143\177\150\047" + - "\152\161\153\205\154\162\155\040\156\176\157\121\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\002" + - "\000\002\001\uff87\000\006\051\u01c1\052\077\001\002\000" + - "\116\031\120\032\144\033\150\034\151\036\124\037\174" + - "\044\102\047\210\053\u01c3\072\220\073\116\077\165\100" + - "\125\102\215\103\204\104\153\105\127\112\152\113\212" + - "\114\045\115\134\124\113\125\154\142\200\143\177\150" + - "\047\152\161\153\205\154\162\155\040\156\176\157\121" + - "\160\171\161\135\162\043\163\044\164\147\165\137\001" + - "\002\000\002\001\uff92\000\120\031\120\032\144\033\150" + - "\034\151\036\124\037\174\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\101\225\102\215\103\204" + - "\104\153\105\127\112\152\113\212\114\045\115\134\124" + - "\113\125\154\142\200\143\177\150\047\152\161\153\205" + - "\154\162\155\040\156\176\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\uff8c" + - "\000\006\051\u01c6\052\077\001\002\000\116\031\120\032" + - "\144\033\150\034\151\036\124\037\174\044\102\047\210" + - "\053\u01c8\072\220\073\116\077\165\100\125\102\215\103" + - "\204\104\153\105\127\112\152\113\212\114\045\115\134" + - "\124\113\125\154\142\200\143\177\150\047\152\161\153" + - "\205\154\162\155\040\156\176\157\121\160\171\161\135" + - "\162\043\163\044\164\147\165\137\001\002\000\002\001" + - "\uff91\000\120\031\120\032\144\033\150\034\151\036\124" + - "\037\174\044\102\047\210\053\223\072\220\073\116\077" + - "\165\100\125\101\225\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\142" + - "\200\143\177\150\047\152\161\153\205\154\162\155\040" + - "\156\176\157\121\160\171\161\135\162\043\163\044\164" + - "\147\165\137\001\002\000\002\001\uff8b\000\010\144\375" + - "\145\373\146\374\001\uff1a\000\002\001\uff2e\000\002\001" + - "\ufef3\000\002\001\ufef6\000\076\031\120\032\144\033\150" + - "\034\151\037\174\044\102\047\267\053\223\073\116\077" + - "\276\100\125\102\215\103\204\105\127\112\152\114\045" + - "\124\113\142\041\150\047\152\161\154\264\155\040\156" + - "\176\157\277\160\171\161\263\162\043\163\044\164\147" + - "\165\137\001\002\000\002\001\ufeec\000\010\045\243\052" + - "\u010f\100\242\001\002\000\002\001\uff5b\000\076\031\120" + - "\032\144\033\150\034\151\037\174\044\102\047\267\053" + - "\223\073\116\077\276\100\125\102\215\103\204\105\127" + - "\112\152\114\045\124\113\142\041\150\047\152\161\154" + - "\264\155\040\156\176\157\277\160\171\161\263\162\043" + - "\163\044\164\147\165\137\001\002\000\076\031\120\032" + - "\144\033\150\034\151\037\174\044\102\047\267\053\223" + - "\073\116\077\276\100\125\102\215\103\204\105\127\112" + - "\152\114\045\124\113\142\041\150\047\152\161\154\264" + - "\155\040\156\176\157\277\160\171\161\263\162\043\163" + - "\044\164\147\165\137\001\002\000\002\001\ufed4\000\002" + - "\001\ufed0\000\116\031\120\032\144\033\150\034\151\036" + - "\124\037\174\044\102\047\210\053\223\072\220\073\116" + - "\077\165\100\125\102\215\103\204\104\153\105\127\112" + - "\152\113\212\114\045\115\134\124\113\125\154\142\200" + - "\143\177\150\047\152\161\153\205\154\162\155\040\156" + - "\176\157\121\160\171\161\135\162\043\163\044\164\147" + - "\165\137\001\002\000\116\031\120\032\144\033\150\034" + - "\151\036\u0139\037\174\044\102\047\267\053\223\072\261" + - "\073\116\077\262\100\125\102\215\103\204\104\u0138\105" + - "\127\112\152\113\u0137\114\045\115\u0130\124\113\125\u0136" + - "\142\u012e\143\u013b\150\047\152\161\153\u012f\154\264\155" + - "\040\156\176\157\272\160\171\161\263\162\043\163\044" + - "\164\147\165\137\001\002\000\002\001\uff42\000\002\001" + - "\uff4c\000\002\001\uff4a\000\004\056\u01dc\001\uff49\000\116" + - "\031\120\032\144\033\150\034\151\036\124\037\174\044" + - "\102\047\210\053\223\072\220\073\116\077\165\100\125" + - "\102\215\103\204\104\153\105\127\112\152\113\212\114" + - "\045\115\134\124\113\125\154\142\200\143\177\150\047" + - "\152\161\153\205\154\162\155\040\156\176\157\121\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\002" + - "\000\002\001\uff4b\000\002\001\uff4e\000\002\001\uff4d\000" + - "\002\001\ufea7\000\002\001\uff81\000\120\031\120\032\144" + - "\033\150\034\151\036\124\037\174\044\102\047\210\053" + - "\223\072\220\073\116\077\165\100\125\101\225\102\215" + - "\103\204\104\153\105\127\112\152\113\212\114\045\115" + - "\134\124\113\125\154\142\200\143\177\150\047\152\161" + - "\153\205\154\162\155\040\156\176\157\121\160\171\161" + - "\135\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\uff7b\000\002\001\uff97\000\010\051\u01ad\052\077\060" + - "\u01e6\001\002\000\116\031\120\032\144\033\150\034\151" + - "\036\124\037\174\044\102\047\210\053\u01e8\072\220\073" + - "\116\077\165\100\125\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\142" + - "\200\143\177\150\047\152\161\153\205\154\162\155\040" + - "\156\176\157\121\160\171\161\135\162\043\163\044\164" + - "\147\165\137\001\002\000\002\001\uff82\000\120\031\120" + - "\032\144\033\150\034\151\036\124\037\174\044\102\047" + - "\210\053\223\072\220\073\116\077\165\100\125\101\225" + - "\102\215\103\204\104\153\105\127\112\152\113\212\114" + - "\045\115\134\124\113\125\154\142\200\143\177\150\047" + - "\152\161\153\205\154\162\155\040\156\176\157\121\160" + - "\171\161\135\162\043\163\044\164\147\165\137\001\002" + - "\000\002\001\uff7c\000\004\051\u01eb\001\002\000\116\031" + - "\120\032\144\033\150\034\151\036\124\037\174\044\102" + - "\047\210\053\223\072\220\073\116\077\165\100\125\102" + - "\215\103\204\104\153\105\127\112\152\113\212\114\045" + - "\115\134\124\113\125\154\142\200\143\177\150\047\152" + - "\161\153\205\154\162\155\040\156\176\157\121\160\171" + - "\161\135\162\043\163\044\164\147\165\137\001\002\000" + - "\004\100\242\001\002\000\002\001\uffbf\000\002\001\uff72" + - "\000\116\031\120\032\144\033\150\034\151\036\124\037" + - "\174\044\102\047\210\053\u01f1\072\220\073\116\077\165" + - "\100\125\102\215\103\204\104\153\105\127\112\152\113" + - "\212\114\045\115\134\124\113\125\154\142\200\143\177" + - "\150\047\152\161\153\205\154\162\155\040\156\176\157" + - "\121\160\171\161\135\162\043\163\044\164\147\165\137" + - "\001\002\000\002\001\uff80\000\120\031\120\032\144\033" + - "\150\034\151\036\124\037\174\044\102\047\210\053\223" + - "\072\220\073\116\077\165\100\125\101\225\102\215\103" + - "\204\104\153\105\127\112\152\113\212\114\045\115\134" + - "\124\113\125\154\142\200\143\177\150\047\152\161\153" + - "\205\154\162\155\040\156\176\157\121\160\171\161\135" + - "\162\043\163\044\164\147\165\137\001\002\000\002\001" + - "\uff7a\000\022\052\072\053\063\062\065\130\064\134\074" + - "\142\053\160\046\163\044\001\uff75\000\002\001\uff73\000" + - "\010\051\u01c6\052\077\060\u01f6\001\002\000\116\031\120" + - "\032\144\033\150\034\151\036\124\037\174\044\102\047" + - "\210\053\u01f8\072\220\073\116\077\165\100\125\102\215" + - "\103\204\104\153\105\127\112\152\113\212\114\045\115" + - "\134\124\113\125\154\142\200\143\177\150\047\152\161" + - "\153\205\154\162\155\040\156\176\157\121\160\171\161" + - "\135\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\uff84\000\120\031\120\032\144\033\150\034\151\036" + - "\124\037\174\044\102\047\210\053\223\072\220\073\116" + - "\077\165\100\125\101\225\102\215\103\204\104\153\105" + - "\127\112\152\113\212\114\045\115\134\124\113\125\154" + - "\142\200\143\177\150\047\152\161\153\205\154\162\155" + - "\040\156\176\157\121\160\171\161\135\162\043\163\044" + - "\164\147\165\137\001\002\000\002\001\uff7e\000\010\051" + - "\u01c1\052\077\060\u01fb\001\002\000\116\031\120\032\144" + - "\033\150\034\151\036\124\037\174\044\102\047\210\053" + - "\u01fd\072\220\073\116\077\165\100\125\102\215\103\204" + - "\104\153\105\127\112\152\113\212\114\045\115\134\124" + - "\113\125\154\142\200\143\177\150\047\152\161\153\205" + - "\154\162\155\040\156\176\157\121\160\171\161\135\162" + - "\043\163\044\164\147\165\137\001\002\000\002\001\uff85" + - "\000\120\031\120\032\144\033\150\034\151\036\124\037" + - "\174\044\102\047\210\053\223\072\220\073\116\077\165" + - "\100\125\101\225\102\215\103\204\104\153\105\127\112" + - "\152\113\212\114\045\115\134\124\113\125\154\142\200" + - "\143\177\150\047\152\161\153\205\154\162\155\040\156" + - "\176\157\121\160\171\161\135\162\043\163\044\164\147" + - "\165\137\001\002\000\002\001\uff7f\000\010\051\u01b2\052" + - "\077\060\u0200\001\002\000\116\031\120\032\144\033\150" + - "\034\151\036\124\037\174\044\102\047\210\053\u0202\072" + - "\220\073\116\077\165\100\125\102\215\103\204\104\153" + - "\105\127\112\152\113\212\114\045\115\134\124\113\125" + - "\154\142\200\143\177\150\047\152\161\153\205\154\162" + - "\155\040\156\176\157\121\160\171\161\135\162\043\163" + - "\044\164\147\165\137\001\002\000\002\001\uff83\000\120" + - "\031\120\032\144\033\150\034\151\036\124\037\174\044" + - "\102\047\210\053\223\072\220\073\116\077\165\100\125" + - "\101\225\102\215\103\204\104\153\105\127\112\152\113" + - "\212\114\045\115\134\124\113\125\154\142\200\143\177" + - "\150\047\152\161\153\205\154\162\155\040\156\176\157" + - "\121\160\171\161\135\162\043\163\044\164\147\165\137" + - "\001\002\000\002\001\uff7d\000\004\140\u0205\001\002\000" + - "\004\051\u0206\001\002\000\116\031\120\032\144\033\150" + - "\034\151\036\124\037\174\044\102\047\210\053\223\072" + - "\220\073\116\077\165\100\125\102\215\103\204\104\153" + - "\105\127\112\152\113\212\114\045\115\134\124\113\125" + - "\154\142\200\143\177\150\047\152\161\153\205\154\162" + - "\155\040\156\176\157\121\160\171\161\135\162\043\163" + - "\044\164\147\165\137\001\002\000\004\100\242\001\002" + - "\000\002\001\uffc0\000\004\100\242\001\002\000\002\001" + - "\uffbe\000\116\031\120\032\144\033\150\034\151\036\124" + - "\037\174\044\102\047\210\053\223\072\220\073\116\077" + - "\165\100\125\102\215\103\204\104\153\105\127\112\152" + - "\113\212\114\045\115\134\124\113\125\154\142\200\143" + - "\177\150\047\152\161\153\205\154\162\155\040\156\176" + - "\157\121\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\002\000\022\052\072\053\063\062\065\130\064" + - "\134\074\142\053\160\046\163\044\001\uff75\000\022\052" + - "\072\053\063\062\065\130\064\134\074\142\053\160\046" + - "\163\044\001\uff75\000\004\137\u020f\001\002\000\004\051" + - "\u0210\001\002\000\116\031\120\032\144\033\150\034\151" + - "\036\124\037\174\044\102\047\210\053\223\072\220\073" + - "\116\077\165\100\125\102\215\103\204\104\153\105\127" + - "\112\152\113\212\114\045\115\134\124\113\125\154\142" + - "\200\143\177\150\047\152\161\153\205\154\162\155\040" + - "\156\176\157\121\160\171\161\135\162\043\163\044\164" + - "\147\165\137\001\002\000\004\100\242\001\002\000\002" + - "\001\uffc2\000\004\140\u0214\001\002\000\004\051\u0215\001" + - "\002\000\116\031\120\032\144\033\150\034\151\036\124" + - "\037\174\044\102\047\210\053\223\072\220\073\116\077" + - "\165\100\125\102\215\103\204\104\153\105\127\112\152" + - "\113\212\114\045\115\134\124\113\125\154\142\200\143" + - "\177\150\047\152\161\153\205\154\162\155\040\156\176" + - "\157\121\160\171\161\135\162\043\163\044\164\147\165" + - "\137\001\002\000\004\100\242\001\002\000\002\001\uffc3" + - "\000\004\100\242\001\002\000\002\001\uffc1\000\006\042" + - "\u021b\101\u021c\001\ufffd\000\010\142\053\160\046\163\044" + - "\001\002\000\020\114\045\142\041\150\047\155\040\160" + - "\046\162\043\163\044\001\uffa3\000\004\137\u0222\001\002" + - "\000\004\052\u0220\001\uffa2\000\002\001\uffa1\000\020\114" + - "\045\142\041\150\047\155\040\160\046\162\043\163\044" + - "\001\002\000\002\001\uffa0\000\004\042\u0223\001\ufffb\000" + - "\010\142\053\160\046\163\044\001\002\000\002\001\ufffa" + - "\000\002\001\ufffc\000\010\100\242\101\u0235\105\u0234\001" + - "\uffa9\000\004\055\u0228\001\002\000\010\142\053\160\046" + - "\163\044\001\002\000\010\100\242\101\u022c\105\u022b\001" + - "\002\000\002\001\uffb8\000\022\052\072\053\063\062\065" + - "\130\064\134\074\142\053\160\046\163\044\001\uff75\000" + - "\022\052\072\053\063\062\065\130\064\134\074\142\053" + - "\160\046\163\044\001\uff75\000\004\137\u022e\001\002\000" + - "\004\100\242\001\002\000\002\001\uffb9\000\004\140\u0231" + - "\001\002\000\004\100\242\001\002\000\002\001\uffba\000" + - "\002\001\uffbb\000\022\052\072\053\063\062\065\130\064" + - "\134\074\142\053\160\046\163\044\001\uff75\000\022\052" + - "\072\053\063\062\065\130\064\134\074\142\053\160\046" + - "\163\044\001\uff75\000\004\137\u0237\001\002\000\004\100" + - "\242\001\002\000\002\001\uffbc\000\004\140\u023a\001\002" + - "\000\004\100\242\001\002\000\002\001\uffbd\000\012\060" + - "\u023d\100\242\101\u0241\105\u0240\001\002\000\116\031\120" + - "\032\144\033\150\034\151\036\124\037\174\044\102\047" + - "\210\053\223\072\220\073\116\077\165\100\125\102\215" + - "\103\204\104\153\105\127\112\152\113\212\114\045\115" + - "\134\124\113\125\154\142\200\143\177\150\047\152\161" + - "\153\205\154\162\155\040\156\176\157\121\160\171\161" + - "\135\162\043\163\044\164\147\165\137\001\002\000\002" + - "\001\uffc6\000\002\001\uffc5\000\012\140\u0247\142\053\160" + - "\046\163\044\001\002\000\012\137\u0243\142\053\160\046" + - "\163\044\001\002\000\006\052\077\137\u0245\001\002\000" + - "\006\060\u023d\100\242\001\002\000\002\001\uffc7\000\006" + - "\060\u023d\100\242\001\002\000\002\001\uffc8\000\006\060" + - "\u023d\100\242\001\002\000\006\052\077\140\u0249\001\002" + - "\000\006\060\u023d\100\242\001\002\000\002\001\uffca\000" + - "\002\001\uffc9\000\002\001\uffc4\000\004\100\u024e\001\002" + - "\000\012\136\u0250\142\053\160\046\163\044\001\002\000" + - "\006\052\077\136\u0251\001\002\000\002\001\ufff8\000\002" + - "\001\ufff9\000\006\050\017\141\024\001\002\000\012\100" + - "\242\142\053\160\046\163\044\001\002\000\014\066\u0257" + - "\100\242\142\053\160\046\163\044\001\uffdc\000\004\066" + - "\u0257\001\uffdc\000\004\063\u0279\001\uffe1\000\006\061\u0258" + - "\164\u025b\001\002\000\004\164\u0270\001\002\000\022\077" + - "\u0269\114\u026e\142\u026c\150\u026f\155\u026b\160\046\162\u026d" + - "\163\044\001\002\000\004\052\u0266\001\uffdd\000\030\046" + - "\u025e\051\u025d\055\u025f\077\uffce\114\uffce\142\uffce\150\uffce" + - "\155\uffce\160\uffce\162\uffce\163\uffce\001\uffdf\000\002\001" + - "\uffdb\000\004\164\u0268\001\002\000\006\061\u0258\164\u0265" + - "\001\002\000\004\055\u0260\001\002\000\004\164\u0261\001" + - "\002\000\004\051\u0262\001\uffcd\000\004\164\u0263\001\002" + - "\000\002\001\uffcc\000\004\052\u0266\001\uffde\000\006\051" + - "\u025d\055\u025f\001\uffce\000\006\061\u0258\164\u0265\001\002" + - "\000\002\001\uffda\000\002\001\uffcb\000\002\001\uffd7\000" + - "\002\001\uffd9\000\002\001\uffd4\000\004\151\054\001\uffd6" + - "\000\002\001\uffd5\000\002\001\uffd3\000\002\001\uffd8\000" + - "\006\051\u0271\055\u0272\001\uffd2\000\004\164\u0277\001\002" + - "\000\004\055\u0273\001\002\000\004\164\u0274\001\002\000" + - "\004\051\u0275\001\uffd1\000\004\164\u0276\001\002\000\002" + - "\001\uffd0\000\002\001\uffcf\000\002\001\uffe6\000\004\164" + - "\u027a\001\002\000\002\001\uffe0\000\004\066\u0257\001\uffdc" + - "\000\004\066\u0257\001\uffdc\000\004\063\u0279\001\uffe1\000" + - "\002\001\uffe2\000\004\063\u0279\001\uffe1\000\002\001\uffe7" + - "\000\004\063\u0279\001\uffe1\000\002\001\uffe3\000\012\052" + - "\077\060\u0286\064\u0285\076\u0284\001\uffaa\000\020\114\045" + - "\142\041\150\047\155\040\160\046\162\043\163\044\001" + - "\002\000\020\114\045\142\041\150\047\155\040\160\046" + - "\162\043\163\044\001\002\000\020\114\045\142\041\150" + - "\047\155\040\160\046\162\043\163\044\001\002\000\004" + - "\100\u0288\001\002\000\022\052\072\053\063\062\065\130" + - "\064\134\074\142\053\160\046\163\044\001\uff75\000\004" + - "\136\u028a\001\002\000\004\100\242\001\uff6f\000\002\001" + - "\uffb5\000\002\001\uff6e\000\004\131\u028f\001\uffab\000\002" + - "\001\uff9f\000\020\114\045\142\041\150\047\155\040\160" + - "\046\162\043\163\044\001\002\000\002\001\uff9e\000\002" + - "\001\uffad\000\004\131\u028f\001\uffac\000\002\001\uffae\000" + - "\002\001\uffb0\000\004\101\u0296\001\uffff\000\012\061\u0298" + - "\142\053\160\046\163\044\001\002\000\002\001\uff96\000" + - "\010\142\053\160\046\163\044\001\002\000\006\052\u029a" + - "\137\u029b\001\002\000\012\061\u029d\142\053\160\046\163" + - "\044\001\002\000\002\001\ufffe\000\002\001\uff94\000\010" + - "\142\053\160\046\163\044\001\002\000\002\001\uff93\000" + - "\002\001\uff95\000\004\100\242\001\002\000\004\100\242" + - "\001\002\000\002\001\ufff7\000\002\001\ufff5\000\002\001" + - "\ufff6\000\014\066\u0257\100\242\142\053\160\046\163\044" + - "\001\uffdc\000\004\066\u0257\001\uffdc\000\004\063\u0279\001" + - "\uffe1\000\002\001\uffe8\000\004\066\u0257\001\uffdc\000\004" + - "\066\u0257\001\uffdc\000\004\063\u0279\001\uffe1\000\002\001" + - "\uffe4\000\004\063\u0279\001\uffe1\000\002\001\uffe9\000\004" + - "\063\u0279\001\uffe1\000\002\001\uffe5\000\004\100\242\001" + - "\002\000\004\100\242\001\002\000\002\001\ufff4\000\002" + - "\001\ufff2\000\002\001\ufff3\000\002\001\000" }); + "\000\u030b\000\002\001\uffec\000\004\002\u030d\001\002\000" + + "\034\002\001\035\026\043\010\050\017\065\016\104\006" + + "\111\021\125\027\134\012\141\023\147\013\153\030\163" + + "\032\001\uffb4\000\002\001\uffb0\000\002\001\uffef\000\014" + + "\100\257\142\055\160\050\201\046\203\u0309\001\002\000" + + "\002\001\uffee\000\014\057\uffb3\067\uffb3\102\uffb3\126\uffb3" + + "\133\uffb3\001\uffad\000\002\001\uffab\000\012\100\257\142" + + "\055\160\050\201\046\001\002\000\002\001\ufff0\000\014" + + "\100\257\142\055\160\050\201\046\203\u02f8\001\002\000" + + "\002\001\uffeb\000\002\001\ufff1\000\010\142\055\160\050" + + "\201\046\001\002\000\020\035\026\104\006\125\027\134" + + "\u02eb\147\013\153\030\163\032\001\002\000\002\001\uffea" + + "\000\010\142\055\160\050\201\046\001\002\000\004\075" + + "\u02a8\001\uffed\000\002\001\uffb1\000\002\001\uffaf\000\002" + + "\001\uffae\000\014\057\033\067\037\102\034\126\036\133" + + "\035\001\002\000\002\001\uffac\000\010\142\055\160\050" + + "\201\046\001\002\000\010\142\055\160\050\201\046\001" + + "\002\000\022\114\047\142\043\150\051\155\042\160\050" + + "\162\045\177\040\201\046\001\002\000\010\142\055\160" + + "\050\201\046\001\002\000\022\114\047\142\043\150\051" + + "\155\042\160\050\162\045\177\040\201\046\001\002\000" + + "\002\001\uffa2\000\010\051\u0261\101\u0263\105\u0262\001\uffa5" + + "\000\002\001\uffa3\000\004\151\u0129\001\002\000\004\151" + + "\060\001\uff98\000\002\001\uffa4\000\002\001\uff95\000\002" + + "\001\uff9f\000\004\151\u017e\001\002\000\002\001\uffa1\000" + + "\004\055\053\001\002\000\010\142\055\160\050\201\046" + + "\001\002\000\010\051\062\101\064\105\063\001\002\000" + + "\004\151\056\001\002\000\004\201\046\001\002\000\004" + + "\151\060\001\uff96\000\004\201\061\001\002\000\002\001" + + "\uff94\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\237\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\024\052\075\053\065\062\067\130" + + "\066\134\077\142\055\160\050\163\074\201\046\001\uff68" + + "\000\024\052\075\053\065\062\067\130\066\134\077\142" + + "\055\160\050\163\074\201\046\001\uff68\000\010\142\055" + + "\160\050\201\046\001\002\000\010\142\055\160\050\201" + + "\046\001\002\000\010\142\055\160\050\201\046\001\002" + + "\000\002\001\uff93\000\004\052\u0249\001\uff67\000\010\051" + + "\u01f7\052\102\060\u0245\001\002\000\002\001\uff79\000\014" + + "\053\u022e\134\u0230\142\055\160\050\201\046\001\002\000" + + "\024\052\075\053\065\062\067\130\066\134\077\142\055" + + "\160\050\163\074\201\046\001\uff68\000\004\137\u0229\001" + + "\002\000\012\053\100\142\055\160\050\201\046\001\002" + + "\000\010\142\055\160\050\201\046\001\002\000\010\051" + + "\104\052\102\060\103\001\002\000\010\142\055\160\050" + + "\201\046\001\002\000\134\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\u0221\072\234" + + "\073\124\077\174\100\132\102\231\103\217\104\162\105" + + "\134\112\161\113\226\114\047\115\141\124\122\125\163" + + "\142\213\143\210\150\051\152\170\153\220\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\164\131" + + "\165\202\166\143\167\150\170\224\171\112\177\040\201" + + "\046\202\156\203\145\001\002\000\134\031\126\032\153" + + "\033\157\034\160\036\130\037\205\044\105\047\223\053" + + "\176\072\234\073\124\077\174\100\132\102\231\103\217" + + "\104\162\105\134\112\161\113\226\114\047\115\141\124" + + "\122\125\163\142\213\143\210\150\051\152\170\153\220" + + "\154\171\155\042\156\207\157\127\160\200\161\142\162" + + "\045\164\131\165\202\166\143\167\150\170\224\171\112" + + "\177\040\201\046\202\156\203\145\001\002\000\010\142" + + "\055\160\050\201\046\001\002\000\002\001\uff29\000\002" + + "\001\uff2e\000\002\001\uff42\000\002\001\uff44\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\004\200\241\001\uff50\000\006\041\u0214\075\u0213\001" + + "\uff36\000\002\001\uff3e\000\044\004\372\005\357\006\373" + + "\007\365\010\366\011\375\012\370\013\362\014\376\015" + + "\364\016\361\017\367\020\360\021\371\022\363\023\377" + + "\054\u020f\001\ufea6\000\002\001\ufea8\000\002\001\ufecf\000" + + "\002\001\ufed3\000\022\053\065\062\067\130\066\134\077" + + "\142\055\160\050\163\074\201\046\001\002\000\004\132" + + "\u020b\001\ufec4\000\002\001\ufe7e\000\002\001\ufecb\000\002" + + "\001\ufe7c\000\104\031\126\032\153\033\157\034\160\037" + + "\205\044\105\047\223\053\237\072\234\073\124\077\174" + + "\100\132\101\334\102\231\103\217\105\134\112\161\114" + + "\047\124\122\142\043\150\051\152\170\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\177\040\201" + + "\046\202\156\203\145\001\002\000\102\031\126\032\153" + + "\033\157\034\160\037\205\044\105\047\223\053\237\072" + + "\234\073\124\077\174\100\132\102\231\103\217\105\134" + + "\112\161\114\047\124\122\142\043\150\051\152\170\154" + + "\171\155\042\156\207\157\127\160\200\161\142\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\146\031\126\032\153\033\157\034\160\036\130\037" + + "\205\044\105\047\223\053\u01e1\062\u01dd\072\234\073\124" + + "\077\174\100\132\102\231\103\217\104\162\105\134\112" + + "\161\113\226\114\047\115\141\124\122\125\163\130\u01de" + + "\134\u01e4\136\265\142\213\143\210\150\051\152\170\153" + + "\220\154\171\155\042\156\207\157\127\160\200\161\142" + + "\162\045\163\074\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff89\000\134\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\104\162\105" + + "\134\112\161\113\226\114\047\115\141\124\122\125\163" + + "\142\213\143\210\150\051\152\170\153\220\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\164\131" + + "\165\202\166\143\167\150\170\224\171\112\177\040\201" + + "\046\202\156\203\145\001\002\000\004\135\u01d9\001\ufea2" + + "\000\002\001\ufea4\000\006\055\u01d7\101\322\001\ufe9e\000" + + "\002\001\ufea0\000\134\031\126\032\153\033\157\034\160" + + "\036\130\037\205\044\105\047\223\053\237\072\234\073" + + "\124\077\174\100\132\102\231\103\217\104\162\105\134" + + "\112\161\113\226\114\047\115\141\124\122\125\163\142" + + "\213\143\210\150\051\152\170\153\220\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\164\131\165" + + "\202\166\143\167\150\170\224\171\112\177\040\201\046" + + "\202\156\203\145\001\002\000\070\031\126\032\153\033" + + "\157\037\205\044\105\047\223\073\124\100\132\102\231" + + "\103\217\105\134\112\161\114\047\124\122\142\043\150" + + "\051\152\170\154\171\155\042\156\207\160\200\161\142" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\134\031\126\032\153\033\157\034\160\036\130\037\205" + + "\044\105\047\223\053\237\072\234\073\124\077\174\100" + + "\132\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\142\213\143\210\150" + + "\051\152\170\153\220\154\171\155\042\156\207\157\127" + + "\160\200\161\142\162\045\164\131\165\202\166\143\167" + + "\150\170\224\171\112\177\040\201\046\202\156\203\145" + + "\001\002\000\002\001\ufe78\000\002\001\ufe7f\000\010\144" + + "\u010f\145\u010e\146\u0110\001\ufee6\000\002\001\ufefa\000\134" + + "\031\126\032\153\033\157\034\160\036\130\037\205\044" + + "\105\047\223\053\237\072\234\073\124\077\174\100\132" + + "\102\231\103\217\104\162\105\134\112\161\113\226\114" + + "\047\115\141\124\122\125\163\142\213\143\210\150\051" + + "\152\170\153\220\154\171\155\042\156\207\157\127\160" + + "\200\161\142\162\045\164\131\165\202\166\143\167\150" + + "\170\224\171\112\177\040\201\046\202\156\203\145\001" + + "\002\000\032\060\u01b5\070\u01b3\071\u01ac\076\u01ae\106\u01b6" + + "\107\u01af\116\u01ad\117\u01b2\120\u01b0\121\u01ab\122\u01b4\123" + + "\u01b1\001\uff15\000\002\001\uff24\000\002\001\ufe7b\000\004" + + "\127\u01a7\001\uff51\000\002\001\uff52\000\002\001\ufe80\000" + + "\002\001\ufe7a\000\004\101\u01a4\001\002\000\022\053\065" + + "\062\067\130\066\134\077\142\055\160\050\163\074\201" + + "\046\001\002\000\102\031\126\032\153\033\157\034\160" + + "\037\205\044\105\047\223\053\237\072\234\073\124\077" + + "\174\100\132\102\231\103\217\105\134\112\161\114\047" + + "\124\122\142\043\150\051\152\170\154\171\155\042\156" + + "\207\157\127\160\200\161\142\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\102\031\126\032\153\033" + + "\157\034\160\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\105\134\112" + + "\161\114\047\124\122\142\043\150\051\152\170\154\171" + + "\155\042\156\207\157\127\160\200\161\142\162\045\177" + + "\040\201\046\202\156\203\145\001\002\000\004\074\u018d" + + "\001\uff46\000\002\001\uff48\000\002\001\ufeba\000\002\001" + + "\ufebc\000\022\053\065\062\067\130\066\134\077\142\055" + + "\160\050\163\074\201\046\001\002\000\070\031\126\032" + + "\153\033\157\037\205\044\105\047\223\073\124\100\132" + + "\102\231\103\217\105\134\112\161\114\047\124\122\142" + + "\043\150\051\152\170\154\171\155\042\156\207\160\200" + + "\161\142\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\004\200\331\001\ufe93\000\004\200\u0121\001\ufe95" + + "\000\104\031\126\032\153\033\157\034\160\037\205\044" + + "\105\047\223\053\237\072\234\073\124\077\174\100\132" + + "\101\337\102\231\103\217\105\134\112\161\114\047\124" + + "\122\142\043\150\051\152\170\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\002\001\ufe87\000\136\031\126" + + "\032\153\033\157\034\160\036\130\037\205\044\105\047" + + "\223\053\237\072\234\073\124\077\174\100\132\101\242" + + "\102\231\103\217\104\162\105\134\112\161\113\226\114" + + "\047\115\141\124\122\125\163\142\213\143\210\150\051" + + "\152\170\153\220\154\171\155\042\156\207\157\127\160" + + "\200\161\142\162\045\164\131\165\202\166\143\167\150" + + "\170\224\171\112\177\040\201\046\202\156\203\145\001" + + "\002\000\010\026\u0180\027\u0182\030\u0181\001\ufed8\000\004" + + "\151\u017e\001\ufe7d\000\002\001\ufedd\000\134\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\102\231\103" + + "\217\104\162\105\134\112\161\113\226\114\047\115\141" + + "\124\122\125\163\142\213\143\210\150\051\152\170\153" + + "\220\154\171\155\042\156\207\157\127\160\200\161\142" + + "\162\045\164\131\165\202\166\143\167\150\170\224\171" + + "\112\177\040\201\046\202\156\203\145\001\002\000\004" + + "\176\u017a\001\uff54\000\004\040\u0178\001\ufebe\000\022\053" + + "\065\062\067\130\066\134\077\142\055\160\050\163\074" + + "\201\046\001\002\000\002\001\ufec0\000\022\053\065\062" + + "\067\130\066\134\077\142\055\160\050\163\074\201\046" + + "\001\002\000\102\031\126\032\153\033\157\034\160\037" + + "\205\044\105\047\223\053\237\072\234\073\124\077\174" + + "\100\132\102\231\103\217\105\134\112\161\114\047\124" + + "\122\142\043\150\051\152\170\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\012\172\u012f\173\u012e\174\u0130" + + "\175\u012d\001\uff30\000\002\001\uff32\000\104\031\126\032" + + "\153\033\157\034\160\037\205\044\105\047\223\053\237" + + "\072\234\073\124\077\174\100\132\102\231\103\217\105" + + "\134\112\161\114\047\124\122\142\043\150\051\151\u0129" + + "\152\170\154\171\155\042\156\207\157\127\160\200\161" + + "\142\162\045\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uffa5\000\002\001\ufe9b\000\002\001\ufe9c\000" + + "\022\053\065\062\067\130\066\134\077\142\055\160\050" + + "\163\074\201\046\001\002\000\102\031\126\032\153\033" + + "\157\034\160\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\105\134\112" + + "\161\114\047\124\122\142\043\150\051\152\170\154\171" + + "\155\042\156\207\157\127\160\200\161\142\162\045\177" + + "\040\201\046\202\156\203\145\001\002\000\002\001\uff38" + + "\000\002\001\uff40\000\070\031\126\032\153\033\157\037" + + "\205\044\105\047\223\073\124\100\132\102\231\103\217" + + "\105\134\112\161\114\047\124\122\142\043\150\051\152" + + "\170\154\171\155\042\156\207\160\200\161\142\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\ufe76\000\102\031\126\032\153\033\157\034" + + "\160\037\205\044\105\047\223\053\237\072\234\073\124" + + "\077\174\100\132\102\231\103\217\105\134\112\161\114" + + "\047\124\122\142\043\150\051\152\170\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\177\040\201" + + "\046\202\156\203\145\001\002\000\012\024\300\025\275" + + "\110\277\131\276\001\ufee1\000\002\001\ufee5\000\010\142" + + "\055\160\050\201\046\001\002\000\002\001\uff37\000\002" + + "\001\uff3f\000\102\031\126\032\153\033\157\034\160\037" + + "\205\044\105\047\223\053\237\072\234\073\124\077\174" + + "\100\132\102\231\103\217\105\134\112\161\114\047\124" + + "\122\142\043\150\051\152\170\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\002\001\ufec3\000\002\001\ufec7" + + "\000\004\101\242\001\002\000\004\200\241\001\ufeca\000" + + "\002\001\ufe83\000\134\031\126\032\153\033\157\034\160" + + "\036\130\037\205\044\105\047\223\053\237\072\234\073" + + "\124\077\174\100\132\102\231\103\217\104\162\105\134" + + "\112\161\113\226\114\047\115\141\124\122\125\163\142" + + "\213\143\210\150\051\152\170\153\220\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\164\131\165" + + "\202\166\143\167\150\170\224\171\112\177\040\201\046" + + "\202\156\203\145\001\uff58\000\002\001\uff56\000\004\137" + + "\250\001\002\000\004\052\246\001\uff57\000\134\031\126" + + "\032\153\033\157\034\160\036\130\037\205\044\105\047" + + "\223\053\237\072\234\073\124\077\174\100\132\102\231" + + "\103\217\104\162\105\134\112\161\113\226\114\047\115" + + "\141\124\122\125\163\142\213\143\210\150\051\152\170" + + "\153\220\154\171\155\042\156\207\157\127\160\200\161" + + "\142\162\045\164\131\165\202\166\143\167\150\170\224" + + "\171\112\177\040\201\046\202\156\203\145\001\002\000" + + "\002\001\uff55\000\002\001\ufe99\000\004\060\253\001\002" + + "\000\002\001\uff4f\000\134\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\104\162\105" + + "\134\112\161\113\226\114\047\115\141\124\122\125\163" + + "\142\213\143\210\150\051\152\170\153\220\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\164\131" + + "\165\202\166\143\167\150\170\224\171\112\177\040\201" + + "\046\202\156\203\145\001\002\000\010\045\260\052\255" + + "\100\257\001\002\000\010\142\055\160\050\201\046\001" + + "\002\000\002\001\uff64\000\136\031\126\032\153\033\157" + + "\034\160\036\130\037\205\044\105\047\223\053\237\072" + + "\234\073\124\077\174\100\132\102\231\103\217\104\162" + + "\105\134\112\161\113\226\114\047\115\141\124\122\125" + + "\163\136\265\142\213\143\210\150\051\152\170\153\220" + + "\154\171\155\042\156\207\157\127\160\200\161\142\162" + + "\045\164\131\165\202\166\143\167\150\170\224\171\112" + + "\177\040\201\046\202\156\203\145\001\002\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff5a\000\002\001\uff5b\000\134\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\102\231\103" + + "\217\104\162\105\134\112\161\113\226\114\047\115\141" + + "\124\122\125\163\142\213\143\210\150\051\152\170\153" + + "\220\154\171\155\042\156\207\157\127\160\200\161\142" + + "\162\045\164\131\165\202\166\143\167\150\170\224\171" + + "\112\177\040\201\046\202\156\203\145\001\002\000\002" + + "\001\uff59\000\002\001\uff5f\000\004\176\272\001\uff5e\000" + + "\136\031\126\032\153\033\157\034\160\036\130\037\205" + + "\044\105\047\223\053\237\072\234\073\124\077\174\100" + + "\132\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\136\270\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uff60\000\002\001\uff5d\000" + + "\134\031\126\032\153\033\157\034\160\036\130\037\205" + + "\044\105\047\223\053\237\072\234\073\124\077\174\100" + + "\132\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\142\213\143\210\150" + + "\051\152\170\153\220\154\171\155\042\156\207\157\127" + + "\160\200\161\142\162\045\164\131\165\202\166\143\167" + + "\150\170\224\171\112\177\040\201\046\202\156\203\145" + + "\001\002\000\036\047\223\104\162\113\226\115\141\125" + + "\163\153\220\154\171\161\142\164\131\165\202\166\143" + + "\167\150\170\224\171\112\001\uff5c\000\002\001\uff63\000" + + "\102\031\126\032\153\033\157\034\160\037\205\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\102" + + "\231\103\217\105\134\112\161\114\047\124\122\142\043" + + "\150\051\152\170\154\305\155\042\156\207\157\313\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\102\031\126\032\153\033\157\034\160\037" + + "\205\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\102\231\103\217\105\134\112\161\114\047\124" + + "\122\142\043\150\051\152\170\154\305\155\042\156\207" + + "\157\313\160\200\161\304\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\102\031\126\032\153\033\157" + + "\034\160\037\205\044\105\047\310\053\237\072\302\073" + + "\124\077\303\100\132\102\231\103\217\105\134\112\161" + + "\114\047\124\122\142\043\150\051\152\170\154\305\155" + + "\042\156\207\157\313\160\200\161\304\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\102\031\126\032" + + "\153\033\157\034\160\037\205\044\105\047\310\053\237" + + "\072\302\073\124\077\303\100\132\102\231\103\217\105" + + "\134\112\161\114\047\124\122\142\043\150\051\152\170" + + "\154\305\155\042\156\207\157\313\160\200\161\304\162" + + "\045\177\040\201\046\202\156\203\145\001\002\000\004" + + "\040\354\001\ufebe\000\064\031\126\032\153\033\157\034" + + "\160\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\105\134\114\047\142\043\150\051\154\305\155" + + "\042\157\313\160\200\161\304\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\066\031\126\032\153\033" + + "\157\034\160\044\105\047\310\053\237\072\302\073\124" + + "\077\303\100\132\101\337\105\134\114\047\142\043\150" + + "\051\154\305\155\042\157\313\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\052\031" + + "\126\032\153\033\157\044\105\047\310\073\124\100\132" + + "\105\134\114\047\142\043\150\051\154\305\155\042\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\052\031\126\032\153\033\157\044\105\047" + + "\310\073\124\100\132\105\134\114\047\142\043\150\051" + + "\154\305\155\042\160\200\161\304\162\045\177\040\201" + + "\046\202\156\203\145\001\002\000\044\004\372\005\357" + + "\006\373\007\365\010\366\011\375\012\370\013\362\014" + + "\376\015\364\016\361\017\367\020\360\021\371\022\363" + + "\023\377\054\356\001\ufea6\000\004\132\352\001\ufec4\000" + + "\052\031\126\032\153\033\157\044\105\047\310\073\124" + + "\100\132\105\134\114\047\142\043\150\051\154\305\155" + + "\042\160\200\161\304\162\045\177\040\201\046\202\156" + + "\203\145\001\002\000\010\026\343\027\344\030\345\001" + + "\ufed5\000\006\055\323\101\322\001\ufe9e\000\066\031\126" + + "\032\153\033\157\034\160\044\105\047\310\053\237\072" + + "\302\073\124\077\303\100\132\101\334\105\134\114\047" + + "\142\043\150\051\154\305\155\042\157\313\160\200\161" + + "\304\162\045\177\040\201\046\202\156\203\145\001\002" + + "\000\004\135\316\001\ufea2\000\002\001\ufeda\000\062\031" + + "\126\032\153\033\157\034\160\044\105\047\310\053\237" + + "\073\124\077\317\100\132\105\134\114\047\142\043\150" + + "\051\154\305\155\042\157\320\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\004\101" + + "\337\001\002\000\004\101\334\001\002\000\006\055\323" + + "\101\322\001\ufe9d\000\134\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\104\162\105" + + "\134\112\161\113\226\114\047\115\141\124\122\125\163" + + "\142\213\143\210\150\051\152\170\153\220\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\164\131" + + "\165\202\166\143\167\150\170\224\171\112\177\040\201" + + "\046\202\156\203\145\001\uff58\000\062\031\126\032\153" + + "\033\157\034\324\044\105\047\310\053\326\073\124\077" + + "\325\100\132\105\134\114\047\142\043\150\051\154\305" + + "\155\042\157\327\160\200\161\304\162\045\177\040\201" + + "\046\202\156\203\145\001\002\000\002\001\ufe90\000\002" + + "\001\ufe8f\000\002\001\ufe91\000\002\001\ufe8e\000\004\200" + + "\331\001\ufe92\000\002\001\ufe81\000\004\137\333\001\002" + + "\000\002\001\ufe9a\000\134\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\104\162\105" + + "\134\112\161\113\226\114\047\115\141\124\122\125\163" + + "\142\213\143\210\150\051\152\170\153\220\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\164\131" + + "\165\202\166\143\167\150\170\224\171\112\177\040\201" + + "\046\202\156\203\145\001\uff58\000\004\137\336\001\002" + + "\000\002\001\ufe96\000\134\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\104\162\105" + + "\134\112\161\113\226\114\047\115\141\124\122\125\163" + + "\142\213\143\210\150\051\152\170\153\220\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\164\131" + + "\165\202\166\143\167\150\170\224\171\112\177\040\201" + + "\046\202\156\203\145\001\uff58\000\004\137\341\001\002" + + "\000\002\001\ufe97\000\002\001\ufec2\000\064\031\126\032" + + "\153\033\157\034\160\044\105\047\310\053\237\072\302" + + "\073\124\077\303\100\132\105\134\114\047\142\043\150" + + "\051\154\305\155\042\157\313\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\064\031" + + "\126\032\153\033\157\034\160\044\105\047\310\053\237" + + "\072\302\073\124\077\303\100\132\105\134\114\047\142" + + "\043\150\051\154\305\155\042\157\313\160\200\161\304" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\064\031\126\032\153\033\157\034\160\044\105\047\310" + + "\053\237\072\302\073\124\077\303\100\132\105\134\114" + + "\047\142\043\150\051\154\305\155\042\157\313\160\200" + + "\161\304\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\002\001\ufecc\000\002\001\ufecd\000\002\001\ufece" + + "\000\002\001\ufe84\000\062\031\126\032\153\033\157\034" + + "\160\044\105\047\310\053\237\073\124\077\317\100\132" + + "\105\134\114\047\142\043\150\051\154\305\155\042\157" + + "\320\160\200\161\304\162\045\177\040\201\046\202\156" + + "\203\145\001\002\000\004\040\354\001\ufebd\000\062\031" + + "\126\032\153\033\157\034\160\044\105\047\310\053\237" + + "\073\124\077\317\100\132\105\134\114\047\142\043\150" + + "\051\154\305\155\042\157\320\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\002\001" + + "\ufeb9\000\062\031\126\032\153\033\157\034\160\044\105" + + "\047\310\053\237\073\124\077\317\100\132\105\134\114" + + "\047\142\043\150\051\154\305\155\042\157\320\160\200" + + "\161\304\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\002\001\ufeb7\000\002\001\ufeac\000\002\001\ufeae" + + "\000\002\001\ufeb1\000\002\001\ufeaa\000\002\001\ufeaf\000" + + "\002\001\ufeb5\000\002\001\ufeb4\000\002\001\ufead\000\002" + + "\001\ufeb2\000\002\001\ufeab\000\002\001\ufeb8\000\002\001" + + "\ufeb6\000\062\031\126\032\153\033\157\034\160\044\105" + + "\047\310\053\237\073\124\077\317\100\132\105\134\114" + + "\047\142\043\150\051\154\305\155\042\157\320\160\200" + + "\161\304\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\002\001\ufeb3\000\002\001\ufeb0\000\002\001\ufea9" + + "\000\002\001\ufea5\000\004\135\316\001\ufea1\000\002\001" + + "\ufe85\000\002\001\ufe86\000\002\001\ufec1\000\010\026\343" + + "\027\344\030\345\001\ufed6\000\002\001\ufedb\000\010\026" + + "\343\027\344\030\345\001\ufed7\000\002\001\ufedc\000\010" + + "\026\343\027\344\030\345\001\ufed4\000\002\001\ufed9\000" + + "\010\144\u010f\145\u010e\146\u0110\001\ufeec\000\002\001\uff00" + + "\000\004\200\241\001\002\000\102\031\126\032\153\033" + + "\157\034\160\037\205\044\105\047\310\053\237\072\302" + + "\073\124\077\303\100\132\102\231\103\217\105\134\112" + + "\161\114\047\124\122\142\043\150\051\152\170\154\305" + + "\155\042\156\207\157\313\160\200\161\304\162\045\177" + + "\040\201\046\202\156\203\145\001\002\000\102\031\126" + + "\032\153\033\157\034\160\037\205\044\105\047\310\053" + + "\237\072\302\073\124\077\303\100\132\102\231\103\217" + + "\105\134\112\161\114\047\124\122\142\043\150\051\152" + + "\170\154\305\155\042\156\207\157\313\160\200\161\304" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\102\031\126\032\153\033\157\034\160\037\205\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\102" + + "\231\103\217\105\134\112\161\114\047\124\122\142\043" + + "\150\051\152\170\154\305\155\042\156\207\157\313\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\010\026\343\027\344\030\345\001\ufed8\000" + + "\012\024\u0117\025\u0115\110\u0116\131\u0114\001\ufede\000\002" + + "\001\ufee2\000\064\031\126\032\153\033\157\034\160\044" + + "\105\047\310\053\237\072\302\073\124\077\303\100\132" + + "\105\134\114\047\142\043\150\051\154\305\155\042\157" + + "\313\160\200\161\304\162\045\177\040\201\046\202\156" + + "\203\145\001\002\000\064\031\126\032\153\033\157\034" + + "\160\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\105\134\114\047\142\043\150\051\154\305\155" + + "\042\157\313\160\200\161\304\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\064\031\126\032\153\033" + + "\157\034\160\044\105\047\310\053\237\072\302\073\124" + + "\077\303\100\132\105\134\114\047\142\043\150\051\154" + + "\305\155\042\157\313\160\200\161\304\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\064\031\126\032" + + "\153\033\157\034\160\044\105\047\310\053\237\072\302" + + "\073\124\077\303\100\132\105\134\114\047\142\043\150" + + "\051\154\305\155\042\157\313\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\012\024" + + "\u0117\025\u0115\110\u0116\131\u0114\001\ufee0\000\002\001\ufee4" + + "\000\012\024\u0117\025\u0115\110\u0116\131\u0114\001\ufedf\000" + + "\002\001\ufee3\000\002\001\uff10\000\002\001\uff1a\000\004" + + "\200\241\001\uff1b\000\002\001\ufe8b\000\002\001\ufe88\000" + + "\002\001\ufe82\000\010\144\u010f\145\u010e\146\u0110\001\ufeeb" + + "\000\002\001\ufeff\000\002\001\uff69\000\010\045\260\052" + + "\u0126\100\257\001\002\000\022\053\065\062\067\130\066" + + "\134\077\142\055\160\050\163\074\201\046\001\002\000" + + "\002\001\uff4b\000\002\001\uff6a\000\006\150\u012c\201\046" + + "\001\002\000\010\144\u010f\145\u010e\146\u0110\001\ufee7\000" + + "\002\001\ufefb\000\002\001\uffa0\000\134\031\126\032\153" + + "\033\157\034\160\036\u013f\037\205\044\105\047\310\053" + + "\237\072\302\073\124\077\303\100\132\102\231\103\217" + + "\104\u0140\105\134\112\161\113\u013b\114\047\115\u0134\124" + + "\122\125\u013a\142\u0131\143\u0142\150\051\152\170\153\u0132" + + "\154\305\155\042\156\207\157\313\160\200\161\304\162" + + "\045\164\u0143\165\u013c\166\u013e\167\u013d\170\u0138\171\u0133" + + "\177\040\201\046\202\156\203\145\001\002\000\134\031" + + "\126\032\153\033\157\034\160\036\u013f\037\205\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\102" + + "\231\103\217\104\u0140\105\134\112\161\113\u013b\114\047" + + "\115\u0134\124\122\125\u013a\142\u0131\143\u0142\150\051\152" + + "\170\153\u0132\154\305\155\042\156\207\157\313\160\200" + + "\161\304\162\045\164\u0143\165\u013c\166\u013e\167\u013d\170" + + "\u0138\171\u0133\177\040\201\046\202\156\203\145\001\002" + + "\000\134\031\126\032\153\033\157\034\160\036\u013f\037" + + "\205\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\102\231\103\217\104\u0140\105\134\112\161\113" + + "\u013b\114\047\115\u0134\124\122\125\u013a\142\u0131\143\u0142" + + "\150\051\152\170\153\u0132\154\305\155\042\156\207\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\134\031\126\032\153\033\157\034\160" + + "\036\u013f\037\205\044\105\047\310\053\237\072\302\073" + + "\124\077\303\100\132\102\231\103\217\104\u0140\105\134" + + "\112\161\113\u013b\114\047\115\u0134\124\122\125\u013a\142" + + "\u0131\143\u0142\150\051\152\170\153\u0132\154\305\155\042" + + "\156\207\157\313\160\200\161\304\162\045\164\u0143\165" + + "\u013c\166\u013e\167\u013d\170\u0138\171\u0133\177\040\201\046" + + "\202\156\203\145\001\002\000\066\031\126\032\153\033" + + "\157\034\160\044\105\047\310\053\237\072\302\073\124" + + "\077\303\100\132\105\134\114\047\142\043\150\051\151" + + "\u0129\154\305\155\042\157\313\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\064\031" + + "\126\032\153\033\157\034\160\044\105\047\310\053\237" + + "\072\302\073\124\077\303\100\132\105\134\114\047\142" + + "\043\150\051\154\305\155\042\157\313\160\200\161\304" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\116\031\126\032\153\033\157\034\160\036\u013f\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\104" + + "\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a\142\u0131" + + "\143\u0142\150\051\153\u0132\154\305\155\042\157\313\160" + + "\200\161\304\162\045\164\u0143\165\u013c\166\u013e\167\u013d" + + "\170\u0138\171\u0133\177\040\201\046\202\156\203\145\001" + + "\002\000\116\031\126\032\153\033\157\034\160\036\u013f" + + "\044\105\047\310\053\237\072\302\073\124\077\303\100" + + "\132\104\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a" + + "\142\u0131\143\u0142\150\051\153\u0132\154\305\155\042\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\002\001\uff27\000\010\144\u0147\145\u0146" + + "\146\u0148\001\ufee6\000\032\060\u015a\070\u0158\071\u0153\076" + + "\u0152\106\u015b\107\u0154\116\u0151\117\u0156\120\u0155\121\u0150" + + "\122\u0159\123\u0157\001\uff15\000\116\031\126\032\153\033" + + "\157\034\160\036\u013f\044\105\047\310\053\237\072\302" + + "\073\124\077\303\100\132\104\u0140\105\134\113\u013b\114" + + "\047\115\u0134\125\u013a\142\u0131\143\u0142\150\051\153\u0132" + + "\154\305\155\042\157\313\160\200\161\304\162\045\164" + + "\u0143\165\u013c\166\u013e\167\u013d\170\u0138\171\u0133\177\040" + + "\201\046\202\156\203\145\001\002\000\012\024\u0117\025" + + "\u0115\110\u0116\131\u0114\001\ufee1\000\064\031\126\032\153" + + "\033\157\034\160\044\105\047\310\053\237\072\302\073" + + "\124\077\303\100\132\105\134\114\047\142\043\150\051" + + "\154\305\155\042\157\313\160\200\161\304\162\045\177" + + "\040\201\046\202\156\203\145\001\002\000\064\031\126" + + "\032\153\033\157\034\160\044\105\047\310\053\237\072" + + "\302\073\124\077\303\100\132\105\134\114\047\142\043" + + "\150\051\154\305\155\042\157\313\160\200\161\304\162" + + "\045\177\040\201\046\202\156\203\145\001\002\000\116" + + "\031\126\032\153\033\157\034\160\036\u013f\044\105\047" + + "\310\053\237\072\302\073\124\077\303\100\132\104\u0140" + + "\105\134\113\u013b\114\047\115\u0134\125\u013a\142\u0131\143" + + "\u0142\150\051\153\u0132\154\305\155\042\157\313\160\200" + + "\161\304\162\045\164\u0143\165\u013c\166\u013e\167\u013d\170" + + "\u0138\171\u0133\177\040\201\046\202\156\203\145\001\002" + + "\000\116\031\126\032\153\033\157\034\160\036\u013f\044" + + "\105\047\310\053\237\072\302\073\124\077\303\100\132" + + "\104\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a\142" + + "\u0131\143\u0142\150\051\153\u0132\154\305\155\042\157\313" + + "\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e\167" + + "\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203\145" + + "\001\002\000\116\031\126\032\153\033\157\034\160\036" + + "\u013f\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\104\u0140\105\134\113\u013b\114\047\115\u0134\125" + + "\u013a\142\u0131\143\u0142\150\051\153\u0132\154\305\155\042" + + "\157\313\160\200\161\304\162\045\164\u0143\165\u013c\166" + + "\u013e\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156" + + "\203\145\001\002\000\064\031\126\032\153\033\157\034" + + "\160\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\105\134\114\047\142\043\150\051\154\305\155" + + "\042\157\313\160\200\161\304\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\064\031\126\032\153\033" + + "\157\034\160\044\105\047\310\053\237\072\302\073\124" + + "\077\303\100\132\105\134\114\047\142\043\150\051\154" + + "\305\155\042\157\313\160\200\161\304\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\002\001\uff2c\000" + + "\064\031\126\032\153\033\157\034\160\044\105\047\310" + + "\053\237\072\302\073\124\077\303\100\132\105\134\114" + + "\047\142\043\150\051\154\305\155\042\157\313\160\200" + + "\161\304\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\116\031\126\032\153\033\157\034\160\036\u013f" + + "\044\105\047\310\053\237\072\302\073\124\077\303\100" + + "\132\104\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a" + + "\142\u0131\143\u0142\150\051\153\u0132\154\305\155\042\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\002\001\uff13\000\010\144\u0147\145\u0146" + + "\146\u0148\001\ufee8\000\064\031\126\032\153\033\157\034" + + "\160\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\105\134\114\047\142\043\150\051\154\305\155" + + "\042\157\313\160\200\161\304\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\064\031\126\032\153\033" + + "\157\034\160\044\105\047\310\053\237\072\302\073\124" + + "\077\303\100\132\105\134\114\047\142\043\150\051\154" + + "\305\155\042\157\313\160\200\161\304\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\064\031\126\032" + + "\153\033\157\034\160\044\105\047\310\053\237\072\302" + + "\073\124\077\303\100\132\105\134\114\047\142\043\150" + + "\051\154\305\155\042\157\313\160\200\161\304\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\010\144" + + "\u0147\145\u0146\146\u0148\001\ufeea\000\010\144\u0147\145\u0146" + + "\146\u0148\001\ufeed\000\002\001\uff11\000\002\001\uff0f\000" + + "\002\001\uff12\000\010\144\u0147\145\u0146\146\u0148\001\ufeec" + + "\000\010\144\u0147\145\u0146\146\u0148\001\ufee9\000\064\031" + + "\126\032\153\033\157\034\160\044\105\047\310\053\237" + + "\072\302\073\124\077\303\100\132\105\134\114\047\142" + + "\043\150\051\154\305\155\042\157\313\160\200\161\304" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\064\031\126\032\153\033\157\034\160\044\105\047\310" + + "\053\237\072\302\073\124\077\303\100\132\105\134\114" + + "\047\142\043\150\051\154\305\155\042\157\313\160\200" + + "\161\304\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\064\031\126\032\153\033\157\034\160\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\105" + + "\134\114\047\142\043\150\051\154\305\155\042\157\313" + + "\160\200\161\304\162\045\177\040\201\046\202\156\203" + + "\145\001\002\000\064\031\126\032\153\033\157\034\160" + + "\044\105\047\310\053\237\072\302\073\124\077\303\100" + + "\132\105\134\114\047\142\043\150\051\154\305\155\042" + + "\157\313\160\200\161\304\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\064\031\126\032\153\033\157" + + "\034\160\044\105\047\310\053\237\072\302\073\124\077" + + "\303\100\132\105\134\114\047\142\043\150\051\154\305" + + "\155\042\157\313\160\200\161\304\162\045\177\040\201" + + "\046\202\156\203\145\001\002\000\064\031\126\032\153" + + "\033\157\034\160\044\105\047\310\053\237\072\302\073" + + "\124\077\303\100\132\105\134\114\047\142\043\150\051" + + "\154\305\155\042\157\313\160\200\161\304\162\045\177" + + "\040\201\046\202\156\203\145\001\002\000\064\031\126" + + "\032\153\033\157\034\160\044\105\047\310\053\237\072" + + "\302\073\124\077\303\100\132\105\134\114\047\142\043" + + "\150\051\154\305\155\042\157\313\160\200\161\304\162" + + "\045\177\040\201\046\202\156\203\145\001\002\000\064" + + "\031\126\032\153\033\157\034\160\044\105\047\310\053" + + "\237\072\302\073\124\077\303\100\132\105\134\114\047" + + "\142\043\150\051\154\305\155\042\157\313\160\200\161" + + "\304\162\045\177\040\201\046\202\156\203\145\001\002" + + "\000\064\031\126\032\153\033\157\034\160\044\105\047" + + "\310\053\237\072\302\073\124\077\303\100\132\105\134" + + "\114\047\142\043\150\051\154\305\155\042\157\313\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\064\031\126\032\153\033\157\034\160\044" + + "\105\047\310\053\237\072\302\073\124\077\303\100\132" + + "\105\134\114\047\142\043\150\051\154\305\155\042\157" + + "\313\160\200\161\304\162\045\177\040\201\046\202\156" + + "\203\145\001\002\000\064\031\126\032\153\033\157\034" + + "\160\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\105\134\114\047\142\043\150\051\154\305\155" + + "\042\157\313\160\200\161\304\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\064\031\126\032\153\033" + + "\157\034\160\044\105\047\310\053\237\072\302\073\124" + + "\077\303\100\132\105\134\114\047\142\043\150\051\154" + + "\305\155\042\157\313\160\200\161\304\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\010\144\u0147\145" + + "\u0146\146\u0148\001\ufef7\000\010\144\u0147\145\u0146\146\u0148" + + "\001\ufef8\000\010\144\u0147\145\u0146\146\u0148\001\ufef1\000" + + "\010\144\u0147\145\u0146\146\u0148\001\ufef6\000\010\144\u0147" + + "\145\u0146\146\u0148\001\ufeef\000\010\144\u0147\145\u0146\146" + + "\u0148\001\ufef0\000\010\144\u0147\145\u0146\146\u0148\001\ufeee" + + "\000\010\144\u0147\145\u0146\146\u0148\001\ufef5\000\010\144" + + "\u0147\145\u0146\146\u0148\001\ufef4\000\010\144\u0147\145\u0146" + + "\146\u0148\001\ufef9\000\010\144\u0147\145\u0146\146\u0148\001" + + "\ufef2\000\010\144\u0147\145\u0146\146\u0148\001\ufef3\000\002" + + "\001\uff14\000\002\001\uff0e\000\010\144\u0147\145\u0146\146" + + "\u0148\001\ufeeb\000\010\144\u0147\145\u0146\146\u0148\001\ufee7" + + "\000\002\001\uff26\000\002\001\uff2a\000\002\001\uff28\000" + + "\002\001\uff2d\000\002\001\uff25\000\002\001\uff2b\000\010" + + "\144\u010f\145\u010e\146\u0110\001\ufee8\000\002\001\ufefc\000" + + "\010\045\260\052\u0126\100\257\001\002\000\002\001\uff49" + + "\000\010\045\260\052\u0126\100\257\001\002\000\002\001" + + "\uff4e\000\100\031\126\032\153\033\157\034\160\037\205" + + "\044\105\047\310\053\237\073\124\077\317\100\132\102" + + "\231\103\217\105\134\112\161\114\047\124\122\142\043" + + "\150\051\152\170\154\305\155\042\156\207\157\320\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\002\001\ufebb\000\134\031\126\032\153\033" + + "\157\034\160\036\130\037\205\044\105\047\223\053\237" + + "\072\234\073\124\077\174\100\132\102\231\103\217\104" + + "\162\105\134\112\161\113\226\114\047\115\141\124\122" + + "\125\163\142\213\143\210\150\051\152\170\153\220\154" + + "\171\155\042\156\207\157\127\160\200\161\142\162\045" + + "\164\131\165\202\166\143\167\150\170\224\171\112\177" + + "\040\201\046\202\156\203\145\001\002\000\002\001\uff53" + + "\000\002\001\uff1e\000\004\200\241\001\uff1f\000\004\201" + + "\046\001\002\000\004\151\060\001\uff97\000\102\031\126" + + "\032\153\033\157\034\160\037\205\044\105\047\310\053" + + "\237\072\302\073\124\077\303\100\132\102\231\103\217" + + "\105\134\112\161\114\047\124\122\142\043\150\051\152" + + "\170\154\305\155\042\156\207\157\313\160\200\161\304" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\102\031\126\032\153\033\157\034\160\037\205\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\102" + + "\231\103\217\105\134\112\161\114\047\124\122\142\043" + + "\150\051\152\170\154\305\155\042\156\207\157\313\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\102\031\126\032\153\033\157\034\160\037" + + "\205\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\102\231\103\217\105\134\112\161\114\047\124" + + "\122\142\043\150\051\152\170\154\305\155\042\156\207" + + "\157\313\160\200\161\304\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\002\001\ufed1\000\002\001\ufed0" + + "\000\002\001\ufed2\000\002\001\uff7f\000\002\001\ufec5\000" + + "\004\200\241\001\ufec8\000\002\001\ufe8c\000\002\001\ufe89" + + "\000\010\045\260\052\u0126\100\257\001\002\000\002\001" + + "\uff4c\000\134\031\126\032\153\033\157\034\160\036\u013f" + + "\037\205\044\105\047\310\053\237\072\302\073\124\077" + + "\303\100\132\102\231\103\217\104\u0140\105\134\112\161" + + "\113\u013b\114\047\115\u0134\124\122\125\u013a\142\u0131\143" + + "\u0142\150\051\152\170\153\u0132\154\305\155\042\156\207" + + "\157\313\160\200\161\304\162\045\164\u0143\165\u013c\166" + + "\u013e\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156" + + "\203\145\001\002\000\006\041\u0197\075\u0196\001\uff36\000" + + "\002\001\uff41\000\012\172\u0195\173\u0193\174\u0194\175\u0192" + + "\001\uff30\000\002\001\uff43\000\116\031\126\032\153\033" + + "\157\034\160\036\u013f\044\105\047\310\053\237\072\302" + + "\073\124\077\303\100\132\104\u0140\105\134\113\u013b\114" + + "\047\115\u0134\125\u013a\142\u0131\143\u0142\150\051\153\u0132" + + "\154\305\155\042\157\313\160\200\161\304\162\045\164" + + "\u0143\165\u013c\166\u013e\167\u013d\170\u0138\171\u0133\177\040" + + "\201\046\202\156\203\145\001\002\000\116\031\126\032" + + "\153\033\157\034\160\036\u013f\044\105\047\310\053\237" + + "\072\302\073\124\077\303\100\132\104\u0140\105\134\113" + + "\u013b\114\047\115\u0134\125\u013a\142\u0131\143\u0142\150\051" + + "\153\u0132\154\305\155\042\157\313\160\200\161\304\162" + + "\045\164\u0143\165\u013c\166\u013e\167\u013d\170\u0138\171\u0133" + + "\177\040\201\046\202\156\203\145\001\002\000\116\031" + + "\126\032\153\033\157\034\160\036\u013f\044\105\047\310" + + "\053\237\072\302\073\124\077\303\100\132\104\u0140\105" + + "\134\113\u013b\114\047\115\u0134\125\u013a\142\u0131\143\u0142" + + "\150\051\153\u0132\154\305\155\042\157\313\160\200\161" + + "\304\162\045\164\u0143\165\u013c\166\u013e\167\u013d\170\u0138" + + "\171\u0133\177\040\201\046\202\156\203\145\001\002\000" + + "\116\031\126\032\153\033\157\034\160\036\u013f\044\105" + + "\047\310\053\237\072\302\073\124\077\303\100\132\104" + + "\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a\142\u0131" + + "\143\u0142\150\051\153\u0132\154\305\155\042\157\313\160" + + "\200\161\304\162\045\164\u0143\165\u013c\166\u013e\167\u013d" + + "\170\u0138\171\u0133\177\040\201\046\202\156\203\145\001" + + "\002\000\116\031\126\032\153\033\157\034\160\036\u013f" + + "\044\105\047\310\053\237\072\302\073\124\077\303\100" + + "\132\104\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a" + + "\142\u0131\143\u0142\150\051\153\u0132\154\305\155\042\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\116\031\126\032\153\033\157\034\160" + + "\036\u013f\044\105\047\310\053\237\072\302\073\124\077" + + "\303\100\132\104\u0140\105\134\113\u013b\114\047\115\u0134" + + "\125\u013a\142\u0131\143\u0142\150\051\153\u0132\154\305\155" + + "\042\157\313\160\200\161\304\162\045\164\u0143\165\u013c" + + "\166\u013e\167\u013d\170\u0138\171\u0133\177\040\201\046\202" + + "\156\203\145\001\002\000\012\172\u0195\173\u0193\174\u0194" + + "\175\u0192\001\uff2f\000\002\001\uff33\000\004\056\u019b\001" + + "\uff38\000\116\031\126\032\153\033\157\034\160\036\u013f" + + "\044\105\047\310\053\237\072\302\073\124\077\303\100" + + "\132\104\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a" + + "\142\u0131\143\u0142\150\051\153\u0132\154\305\155\042\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\002\001\uff34\000\002\001\uff35\000\010" + + "\144\u010f\145\u010e\146\u0110\001\ufee9\000\002\001\ufefd\000" + + "\010\144\u010f\145\u010e\146\u0110\001\ufeea\000\002\001\ufefe" + + "\000\010\045\260\052\u0126\100\257\001\002\000\002\001" + + "\uff4d\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\237\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\uff58\000\004\137\u01a6\001\002\000\002\001" + + "\ufe98\000\134\031\126\032\153\033\157\034\160\036\u013f" + + "\037\205\044\105\047\310\053\237\072\302\073\124\077" + + "\303\100\132\102\231\103\217\104\u0140\105\134\112\161" + + "\113\u013b\114\047\115\u0134\124\122\125\u013a\142\u0131\143" + + "\u0142\150\051\152\170\153\u0132\154\305\155\042\156\207" + + "\157\313\160\200\161\304\162\045\164\u0143\165\u013c\166" + + "\u013e\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156" + + "\203\145\001\002\000\004\074\u01aa\001\uff45\000\002\001" + + "\uff47\000\116\031\126\032\153\033\157\034\160\036\u013f" + + "\044\105\047\310\053\237\072\302\073\124\077\303\100" + + "\132\104\u0140\105\134\113\u013b\114\047\115\u0134\125\u013a" + + "\142\u0131\143\u0142\150\051\153\u0132\154\305\155\042\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\102\031\126\032\153\033\157\034\160" + + "\037\205\044\105\047\223\053\237\072\234\073\124\077" + + "\174\100\132\102\231\103\217\105\134\112\161\114\047" + + "\124\122\142\043\150\051\152\170\154\171\155\042\156" + + "\207\157\127\160\200\161\142\162\045\177\040\201\046" + + "\202\156\203\145\001\002\000\102\031\126\032\153\033" + + "\157\034\160\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\102\231\103\217\105\134\112" + + "\161\114\047\124\122\142\043\150\051\152\170\154\171" + + "\155\042\156\207\157\127\160\200\161\142\162\045\177" + + "\040\201\046\202\156\203\145\001\002\000\102\031\126" + + "\032\153\033\157\034\160\037\205\044\105\047\223\053" + + "\237\072\234\073\124\077\174\100\132\102\231\103\217" + + "\105\134\112\161\114\047\124\122\142\043\150\051\152" + + "\170\154\171\155\042\156\207\157\127\160\200\161\142" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\102\031\126\032\153\033\157\034\160\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\105\134\112\161\114\047\124\122\142\043" + + "\150\051\152\170\154\171\155\042\156\207\157\127\160" + + "\200\161\142\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\102\031\126\032\153\033\157\034\160\037" + + "\205\044\105\047\223\053\237\072\234\073\124\077\174" + + "\100\132\102\231\103\217\105\134\112\161\114\047\124" + + "\122\142\043\150\051\152\170\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\177\040\201\046\202" + + "\156\203\145\001\002\000\102\031\126\032\153\033\157" + + "\034\160\037\205\044\105\047\223\053\237\072\234\073" + + "\124\077\174\100\132\102\231\103\217\105\134\112\161" + + "\114\047\124\122\142\043\150\051\152\170\154\171\155" + + "\042\156\207\157\127\160\200\161\142\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\102\031\126\032" + + "\153\033\157\034\160\037\205\044\105\047\223\053\237" + + "\072\234\073\124\077\174\100\132\102\231\103\217\105" + + "\134\112\161\114\047\124\122\142\043\150\051\152\170" + + "\154\171\155\042\156\207\157\127\160\200\161\142\162" + + "\045\177\040\201\046\202\156\203\145\001\002\000\102" + + "\031\126\032\153\033\157\034\160\037\205\044\105\047" + + "\223\053\237\072\234\073\124\077\174\100\132\102\231" + + "\103\217\105\134\112\161\114\047\124\122\142\043\150" + + "\051\152\170\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\102\031\126\032\153\033\157\034\160\037\205" + + "\044\105\047\223\053\237\072\234\073\124\077\174\100" + + "\132\102\231\103\217\105\134\112\161\114\047\124\122" + + "\142\043\150\051\152\170\154\171\155\042\156\207\157" + + "\127\160\200\161\142\162\045\177\040\201\046\202\156" + + "\203\145\001\002\000\102\031\126\032\153\033\157\034" + + "\160\037\205\044\105\047\223\053\237\072\234\073\124" + + "\077\174\100\132\102\231\103\217\105\134\112\161\114" + + "\047\124\122\142\043\150\051\152\170\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\177\040\201" + + "\046\202\156\203\145\001\002\000\102\031\126\032\153" + + "\033\157\034\160\037\205\044\105\047\223\053\237\072" + + "\234\073\124\077\174\100\132\102\231\103\217\105\134" + + "\112\161\114\047\124\122\142\043\150\051\152\170\154" + + "\171\155\042\156\207\157\127\160\200\161\142\162\045" + + "\177\040\201\046\202\156\203\145\001\002\000\102\031" + + "\126\032\153\033\157\034\160\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\102\231\103" + + "\217\105\134\112\161\114\047\124\122\142\043\150\051" + + "\152\170\154\171\155\042\156\207\157\127\160\200\161" + + "\142\162\045\177\040\201\046\202\156\203\145\001\002" + + "\000\010\144\u010f\145\u010e\146\u0110\001\ufef7\000\002\001" + + "\uff0b\000\010\144\u010f\145\u010e\146\u0110\001\ufef8\000\002" + + "\001\uff0c\000\010\144\u010f\145\u010e\146\u0110\001\ufef1\000" + + "\002\001\uff05\000\010\144\u010f\145\u010e\146\u0110\001\ufef6" + + "\000\002\001\uff0a\000\010\144\u010f\145\u010e\146\u0110\001" + + "\ufef0\000\002\001\uff04\000\010\144\u010f\145\u010e\146\u0110" + + "\001\ufeef\000\002\001\uff03\000\010\144\u010f\145\u010e\146" + + "\u0110\001\ufeee\000\002\001\uff02\000\010\144\u010f\145\u010e" + + "\146\u0110\001\ufef5\000\002\001\uff09\000\010\144\u010f\145" + + "\u010e\146\u0110\001\ufef9\000\002\001\uff0d\000\010\144\u010f" + + "\145\u010e\146\u0110\001\ufef2\000\002\001\uff06\000\010\144" + + "\u010f\145\u010e\146\u0110\001\ufef4\000\002\001\uff08\000\010" + + "\144\u010f\145\u010e\146\u0110\001\ufef3\000\002\001\uff07\000" + + "\002\001\uff18\000\004\200\241\001\uff19\000\002\001\uff1c" + + "\000\004\200\241\001\uff1d\000\002\001\ufe8d\000\002\001" + + "\ufe8a\000\002\001\uff22\000\004\200\241\001\uff23\000\100" + + "\031\126\032\153\033\157\034\324\037\205\044\105\047" + + "\310\053\326\073\124\077\325\100\132\102\231\103\217" + + "\105\134\112\161\114\047\124\122\142\043\150\051\152" + + "\170\154\305\155\042\156\207\157\327\160\200\161\304" + + "\162\045\177\040\201\046\202\156\203\145\001\002\000" + + "\002\001\ufe94\000\100\031\126\032\153\033\157\034\160" + + "\037\205\044\105\047\310\053\237\073\124\077\317\100" + + "\132\102\231\103\217\105\134\112\161\114\047\124\122" + + "\142\043\150\051\152\170\154\305\155\042\156\207\157" + + "\320\160\200\161\304\162\045\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\ufe9f\000\004\140\u01dc\001" + + "\002\000\002\001\ufe79\000\010\142\055\160\050\201\046" + + "\001\002\000\010\142\055\160\050\201\046\001\002\000" + + "\006\051\u01f7\052\102\001\002\000\012\045\260\052\u01f1" + + "\100\257\136\u01f3\001\002\000\012\101\242\142\055\160" + + "\050\201\046\001\002\000\002\001\uff6b\000\006\051\uff93" + + "\052\uff93\001\uffa5\000\012\053\u01e5\142\055\160\050\201" + + "\046\001\002\000\010\142\055\160\050\201\046\001\002" + + "\000\006\051\104\052\102\001\002\000\006\051\u01e8\052" + + "\102\001\002\000\134\031\126\032\153\033\157\034\160" + + "\036\130\037\205\044\105\047\223\053\u01ea\072\234\073" + + "\124\077\174\100\132\102\231\103\217\104\162\105\134" + + "\112\161\113\226\114\047\115\141\124\122\125\163\142" + + "\213\143\210\150\051\152\170\153\220\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\164\131\165" + + "\202\166\143\167\150\170\224\171\112\177\040\201\046" + + "\202\156\203\145\001\002\000\002\001\uff8a\000\136\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\101" + + "\242\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\142\213\143\210\150" + + "\051\152\170\153\220\154\171\155\042\156\207\157\127" + + "\160\200\161\142\162\045\164\131\165\202\166\143\167" + + "\150\170\224\171\112\177\040\201\046\202\156\203\145" + + "\001\002\000\002\001\uff80\000\006\051\u01ed\052\102\001" + + "\002\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\u01ef\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uff8b\000\136\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\101\242\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff81\000\022\053\u01f5\062\u01dd\130\u01de\134" + + "\u01e4\142\055\160\050\163\074\201\046\001\002\000\004" + + "\136\u01f4\001\002\000\002\001\ufe74\000\002\001\ufe75\000" + + "\010\142\055\160\050\201\046\001\002\000\002\001\uff6c" + + "\000\134\031\126\032\153\033\157\034\160\036\130\037" + + "\205\044\105\047\223\053\u01f9\072\234\073\124\077\174" + + "\100\132\102\231\103\217\104\162\105\134\112\161\113" + + "\226\114\047\115\141\124\122\125\163\142\213\143\210" + + "\150\051\152\170\153\220\154\171\155\042\156\207\157" + + "\127\160\200\161\142\162\045\164\131\165\202\166\143" + + "\167\150\170\224\171\112\177\040\201\046\202\156\203" + + "\145\001\002\000\002\001\uff88\000\136\031\126\032\153" + + "\033\157\034\160\036\130\037\205\044\105\047\223\053" + + "\237\072\234\073\124\077\174\100\132\101\242\102\231" + + "\103\217\104\162\105\134\112\161\113\226\114\047\115" + + "\141\124\122\125\163\142\213\143\210\150\051\152\170" + + "\153\220\154\171\155\042\156\207\157\127\160\200\161" + + "\142\162\045\164\131\165\202\166\143\167\150\170\224" + + "\171\112\177\040\201\046\202\156\203\145\001\002\000" + + "\002\001\uff7e\000\006\051\u01fc\052\102\001\002\000\134" + + "\031\126\032\153\033\157\034\160\036\130\037\205\044" + + "\105\047\223\053\u01fe\072\234\073\124\077\174\100\132" + + "\102\231\103\217\104\162\105\134\112\161\113\226\114" + + "\047\115\141\124\122\125\163\142\213\143\210\150\051" + + "\152\170\153\220\154\171\155\042\156\207\157\127\160" + + "\200\161\142\162\045\164\131\165\202\166\143\167\150" + + "\170\224\171\112\177\040\201\046\202\156\203\145\001" + + "\002\000\002\001\uff8d\000\136\031\126\032\153\033\157" + + "\034\160\036\130\037\205\044\105\047\223\053\237\072" + + "\234\073\124\077\174\100\132\101\242\102\231\103\217" + + "\104\162\105\134\112\161\113\226\114\047\115\141\124" + + "\122\125\163\142\213\143\210\150\051\152\170\153\220" + + "\154\171\155\042\156\207\157\127\160\200\161\142\162" + + "\045\164\131\165\202\166\143\167\150\170\224\171\112" + + "\177\040\201\046\202\156\203\145\001\002\000\002\001" + + "\uff83\000\006\051\u0201\052\102\001\002\000\134\031\126" + + "\032\153\033\157\034\160\036\130\037\205\044\105\047" + + "\223\053\u0203\072\234\073\124\077\174\100\132\102\231" + + "\103\217\104\162\105\134\112\161\113\226\114\047\115" + + "\141\124\122\125\163\142\213\143\210\150\051\152\170" + + "\153\220\154\171\155\042\156\207\157\127\160\200\161" + + "\142\162\045\164\131\165\202\166\143\167\150\170\224" + + "\171\112\177\040\201\046\202\156\203\145\001\002\000" + + "\002\001\uff8c\000\136\031\126\032\153\033\157\034\160" + + "\036\130\037\205\044\105\047\223\053\237\072\234\073" + + "\124\077\174\100\132\101\242\102\231\103\217\104\162" + + "\105\134\112\161\113\226\114\047\115\141\124\122\125" + + "\163\142\213\143\210\150\051\152\170\153\220\154\171" + + "\155\042\156\207\157\127\160\200\161\142\162\045\164" + + "\131\165\202\166\143\167\150\170\224\171\112\177\040" + + "\201\046\202\156\203\145\001\002\000\002\001\uff82\000" + + "\002\001\uff20\000\004\200\241\001\uff21\000\010\144\u010f" + + "\145\u010e\146\u0110\001\ufeed\000\002\001\uff01\000\002\001" + + "\ufec6\000\004\200\241\001\ufec9\000\100\031\126\032\153" + + "\033\157\034\160\037\205\044\105\047\310\053\237\073" + + "\124\077\317\100\132\102\231\103\217\105\134\112\161" + + "\114\047\124\122\142\043\150\051\152\170\154\305\155" + + "\042\156\207\157\320\160\200\161\304\162\045\177\040" + + "\201\046\202\156\203\145\001\002\000\002\001\ufebf\000" + + "\010\045\260\052\u0126\100\257\001\002\000\002\001\uff4a" + + "\000\100\031\126\032\153\033\157\034\160\037\205\044" + + "\105\047\310\053\237\073\124\077\317\100\132\102\231" + + "\103\217\105\134\112\161\114\047\124\122\142\043\150" + + "\051\152\170\154\305\155\042\156\207\157\320\160\200" + + "\161\304\162\045\177\040\201\046\202\156\203\145\001" + + "\002\000\100\031\126\032\153\033\157\034\160\037\205" + + "\044\105\047\310\053\237\073\124\077\317\100\132\102" + + "\231\103\217\105\134\112\161\114\047\124\122\142\043" + + "\150\051\152\170\154\305\155\042\156\207\157\320\160" + + "\200\161\304\162\045\177\040\201\046\202\156\203\145" + + "\001\002\000\002\001\ufea7\000\002\001\ufea3\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\134\031\126\032\153\033\157\034\160\036\u013f\037" + + "\205\044\105\047\310\053\237\072\302\073\124\077\303" + + "\100\132\102\231\103\217\104\u0140\105\134\112\161\113" + + "\u013b\114\047\115\u0134\124\122\125\u013a\142\u0131\143\u0142" + + "\150\051\152\170\153\u0132\154\305\155\042\156\207\157" + + "\313\160\200\161\304\162\045\164\u0143\165\u013c\166\u013e" + + "\167\u013d\170\u0138\171\u0133\177\040\201\046\202\156\203" + + "\145\001\002\000\002\001\uff31\000\002\001\uff3b\000\004" + + "\200\241\001\uff39\000\004\056\u0219\001\uff38\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\004\200\241\001\uff3a\000\002\001\uff3d\000\002\001" + + "\uff3c\000\002\001\uff16\000\004\200\241\001\uff17\000\002" + + "\001\ufe77\000\002\001\uff74\000\136\031\126\032\153\033" + + "\157\034\160\036\130\037\205\044\105\047\223\053\237" + + "\072\234\073\124\077\174\100\132\101\242\102\231\103" + + "\217\104\162\105\134\112\161\113\226\114\047\115\141" + + "\124\122\125\163\142\213\143\210\150\051\152\170\153" + + "\220\154\171\155\042\156\207\157\127\160\200\161\142" + + "\162\045\164\131\165\202\166\143\167\150\170\224\171" + + "\112\177\040\201\046\202\156\203\145\001\002\000\002" + + "\001\uff6e\000\002\001\uff92\000\010\051\u01e8\052\102\060" + + "\u0225\001\002\000\134\031\126\032\153\033\157\034\160" + + "\036\130\037\205\044\105\047\223\053\u0227\072\234\073" + + "\124\077\174\100\132\102\231\103\217\104\162\105\134" + + "\112\161\113\226\114\047\115\141\124\122\125\163\142" + + "\213\143\210\150\051\152\170\153\220\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\164\131\165" + + "\202\166\143\167\150\170\224\171\112\177\040\201\046" + + "\202\156\203\145\001\002\000\002\001\uff75\000\136\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\237\072\234\073\124\077\174\100\132\101" + + "\242\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\142\213\143\210\150" + + "\051\152\170\153\220\154\171\155\042\156\207\157\127" + + "\160\200\161\142\162\045\164\131\165\202\166\143\167" + + "\150\170\224\171\112\177\040\201\046\202\156\203\145" + + "\001\002\000\002\001\uff6f\000\004\051\u022a\001\002\000" + + "\134\031\126\032\153\033\157\034\160\036\130\037\205" + + "\044\105\047\223\053\237\072\234\073\124\077\174\100" + + "\132\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\142\213\143\210\150" + + "\051\152\170\153\220\154\171\155\042\156\207\157\127" + + "\160\200\161\142\162\045\164\131\165\202\166\143\167" + + "\150\170\224\171\112\177\040\201\046\202\156\203\145" + + "\001\002\000\004\100\257\001\002\000\002\001\uffbc\000" + + "\002\001\uff65\000\010\142\055\160\050\201\046\001\002" + + "\000\006\051\u023c\052\102\001\002\000\012\053\u0231\142" + + "\055\160\050\201\046\001\002\000\010\142\055\160\050" + + "\201\046\001\002\000\006\051\u0233\052\102\001\002\000" + + "\134\031\126\032\153\033\157\034\160\036\130\037\205" + + "\044\105\047\223\053\u0235\072\234\073\124\077\174\100" + + "\132\102\231\103\217\104\162\105\134\112\161\113\226" + + "\114\047\115\141\124\122\125\163\142\213\143\210\150" + + "\051\152\170\153\220\154\171\155\042\156\207\157\127" + + "\160\200\161\142\162\045\164\131\165\202\166\143\167" + + "\150\170\224\171\112\177\040\201\046\202\156\203\145" + + "\001\002\000\002\001\uff85\000\136\031\126\032\153\033" + + "\157\034\160\036\130\037\205\044\105\047\223\053\237" + + "\072\234\073\124\077\174\100\132\101\242\102\231\103" + + "\217\104\162\105\134\112\161\113\226\114\047\115\141" + + "\124\122\125\163\142\213\143\210\150\051\152\170\153" + + "\220\154\171\155\042\156\207\157\127\160\200\161\142" + + "\162\045\164\131\165\202\166\143\167\150\170\224\171" + + "\112\177\040\201\046\202\156\203\145\001\002\000\002" + + "\001\uff7b\000\006\051\u0238\052\102\001\002\000\134\031" + + "\126\032\153\033\157\034\160\036\130\037\205\044\105" + + "\047\223\053\u023a\072\234\073\124\077\174\100\132\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff86\000\136\031\126\032\153\033\157\034" + + "\160\036\130\037\205\044\105\047\223\053\237\072\234" + + "\073\124\077\174\100\132\101\242\102\231\103\217\104" + + "\162\105\134\112\161\113\226\114\047\115\141\124\122" + + "\125\163\142\213\143\210\150\051\152\170\153\220\154" + + "\171\155\042\156\207\157\127\160\200\161\142\162\045" + + "\164\131\165\202\166\143\167\150\170\224\171\112\177" + + "\040\201\046\202\156\203\145\001\002\000\002\001\uff7c" + + "\000\134\031\126\032\153\033\157\034\160\036\130\037" + + "\205\044\105\047\223\053\u023e\072\234\073\124\077\174" + + "\100\132\102\231\103\217\104\162\105\134\112\161\113" + + "\226\114\047\115\141\124\122\125\163\142\213\143\210" + + "\150\051\152\170\153\220\154\171\155\042\156\207\157" + + "\127\160\200\161\142\162\045\164\131\165\202\166\143" + + "\167\150\170\224\171\112\177\040\201\046\202\156\203" + + "\145\001\002\000\002\001\uff84\000\136\031\126\032\153" + + "\033\157\034\160\036\130\037\205\044\105\047\223\053" + + "\237\072\234\073\124\077\174\100\132\101\242\102\231" + + "\103\217\104\162\105\134\112\161\113\226\114\047\115" + + "\141\124\122\125\163\142\213\143\210\150\051\152\170" + + "\153\220\154\171\155\042\156\207\157\127\160\200\161" + + "\142\162\045\164\131\165\202\166\143\167\150\170\224" + + "\171\112\177\040\201\046\202\156\203\145\001\002\000" + + "\002\001\uff7a\000\006\051\u0241\052\102\001\002\000\134" + + "\031\126\032\153\033\157\034\160\036\130\037\205\044" + + "\105\047\223\053\u0243\072\234\073\124\077\174\100\132" + + "\102\231\103\217\104\162\105\134\112\161\113\226\114" + + "\047\115\141\124\122\125\163\142\213\143\210\150\051" + + "\152\170\153\220\154\171\155\042\156\207\157\127\160" + + "\200\161\142\162\045\164\131\165\202\166\143\167\150" + + "\170\224\171\112\177\040\201\046\202\156\203\145\001" + + "\002\000\002\001\uff87\000\136\031\126\032\153\033\157" + + "\034\160\036\130\037\205\044\105\047\223\053\237\072" + + "\234\073\124\077\174\100\132\101\242\102\231\103\217" + + "\104\162\105\134\112\161\113\226\114\047\115\141\124" + + "\122\125\163\142\213\143\210\150\051\152\170\153\220" + + "\154\171\155\042\156\207\157\127\160\200\161\142\162" + + "\045\164\131\165\202\166\143\167\150\170\224\171\112" + + "\177\040\201\046\202\156\203\145\001\002\000\002\001" + + "\uff7d\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\u0247\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uff73\000\136\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\101\242\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff6d\000\024\052\075\053\065\062\067\130" + + "\066\134\077\142\055\160\050\163\074\201\046\001\uff68" + + "\000\002\001\uff66\000\010\051\u0201\052\102\060\u024c\001" + + "\002\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\u024e\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uff77\000\136\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\101\242\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff71\000\010\051\u01fc\052\102\060\u0251\001" + + "\002\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\u0253\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uff78\000\136\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\101\242\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff72\000\010\051\u01ed\052\102\060\u0256\001" + + "\002\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\u0258\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uff76\000\136\031\126\032" + + "\153\033\157\034\160\036\130\037\205\044\105\047\223" + + "\053\237\072\234\073\124\077\174\100\132\101\242\102" + + "\231\103\217\104\162\105\134\112\161\113\226\114\047" + + "\115\141\124\122\125\163\142\213\143\210\150\051\152" + + "\170\153\220\154\171\155\042\156\207\157\127\160\200" + + "\161\142\162\045\164\131\165\202\166\143\167\150\170" + + "\224\171\112\177\040\201\046\202\156\203\145\001\002" + + "\000\002\001\uff70\000\004\140\u025b\001\002\000\004\051" + + "\u025c\001\002\000\134\031\126\032\153\033\157\034\160" + + "\036\130\037\205\044\105\047\223\053\237\072\234\073" + + "\124\077\174\100\132\102\231\103\217\104\162\105\134" + + "\112\161\113\226\114\047\115\141\124\122\125\163\142" + + "\213\143\210\150\051\152\170\153\220\154\171\155\042" + + "\156\207\157\127\160\200\161\142\162\045\164\131\165" + + "\202\166\143\167\150\170\224\171\112\177\040\201\046" + + "\202\156\203\145\001\002\000\004\100\257\001\002\000" + + "\002\001\uffbd\000\004\100\257\001\002\000\002\001\uffbb" + + "\000\134\031\126\032\153\033\157\034\160\036\130\037" + + "\205\044\105\047\223\053\237\072\234\073\124\077\174" + + "\100\132\102\231\103\217\104\162\105\134\112\161\113" + + "\226\114\047\115\141\124\122\125\163\142\213\143\210" + + "\150\051\152\170\153\220\154\171\155\042\156\207\157" + + "\127\160\200\161\142\162\045\164\131\165\202\166\143" + + "\167\150\170\224\171\112\177\040\201\046\202\156\203" + + "\145\001\002\000\024\052\075\053\065\062\067\130\066" + + "\134\077\142\055\160\050\163\074\201\046\001\uff68\000" + + "\024\052\075\053\065\062\067\130\066\134\077\142\055" + + "\160\050\163\074\201\046\001\uff68\000\004\137\u0265\001" + + "\002\000\004\051\u0266\001\002\000\134\031\126\032\153" + + "\033\157\034\160\036\130\037\205\044\105\047\223\053" + + "\237\072\234\073\124\077\174\100\132\102\231\103\217" + + "\104\162\105\134\112\161\113\226\114\047\115\141\124" + + "\122\125\163\142\213\143\210\150\051\152\170\153\220" + + "\154\171\155\042\156\207\157\127\160\200\161\142\162" + + "\045\164\131\165\202\166\143\167\150\170\224\171\112" + + "\177\040\201\046\202\156\203\145\001\002\000\004\100" + + "\257\001\002\000\002\001\uffbf\000\004\140\u026a\001\002" + + "\000\004\051\u026b\001\002\000\134\031\126\032\153\033" + + "\157\034\160\036\130\037\205\044\105\047\223\053\237" + + "\072\234\073\124\077\174\100\132\102\231\103\217\104" + + "\162\105\134\112\161\113\226\114\047\115\141\124\122" + + "\125\163\142\213\143\210\150\051\152\170\153\220\154" + + "\171\155\042\156\207\157\127\160\200\161\142\162\045" + + "\164\131\165\202\166\143\167\150\170\224\171\112\177" + + "\040\201\046\202\156\203\145\001\002\000\004\100\257" + + "\001\002\000\002\001\uffc0\000\004\100\257\001\002\000" + + "\002\001\uffbe\000\006\042\u0271\101\u0272\001\ufffd\000\010" + + "\142\055\160\050\201\046\001\002\000\022\114\047\142" + + "\043\150\051\155\042\160\050\162\045\177\040\201\046" + + "\001\uff9e\000\004\137\u0278\001\002\000\004\052\u0276\001" + + "\uff9d\000\002\001\uff9c\000\022\114\047\142\043\150\051" + + "\155\042\160\050\162\045\177\040\201\046\001\002\000" + + "\002\001\uff9b\000\004\042\u0279\001\ufffb\000\010\142\055" + + "\160\050\201\046\001\002\000\002\001\ufffa\000\002\001" + + "\ufffc\000\010\100\257\101\u028b\105\u028a\001\uffa5\000\004" + + "\055\u027e\001\002\000\010\142\055\160\050\201\046\001" + + "\002\000\010\100\257\101\u0282\105\u0281\001\002\000\002" + + "\001\uffb5\000\024\052\075\053\065\062\067\130\066\134" + + "\077\142\055\160\050\163\074\201\046\001\uff68\000\024" + + "\052\075\053\065\062\067\130\066\134\077\142\055\160" + + "\050\163\074\201\046\001\uff68\000\004\137\u0284\001\002" + + "\000\004\100\257\001\002\000\002\001\uffb6\000\004\140" + + "\u0287\001\002\000\004\100\257\001\002\000\002\001\uffb7" + + "\000\002\001\uffb8\000\024\052\075\053\065\062\067\130" + + "\066\134\077\142\055\160\050\163\074\201\046\001\uff68" + + "\000\024\052\075\053\065\062\067\130\066\134\077\142" + + "\055\160\050\163\074\201\046\001\uff68\000\004\137\u028d" + + "\001\002\000\004\100\257\001\002\000\002\001\uffb9\000" + + "\004\140\u0290\001\002\000\004\100\257\001\002\000\002" + + "\001\uffba\000\012\060\u0293\100\257\101\u0297\105\u0296\001" + + "\002\000\134\031\126\032\153\033\157\034\160\036\130" + + "\037\205\044\105\047\223\053\237\072\234\073\124\077" + + "\174\100\132\102\231\103\217\104\162\105\134\112\161" + + "\113\226\114\047\115\141\124\122\125\163\142\213\143" + + "\210\150\051\152\170\153\220\154\171\155\042\156\207" + + "\157\127\160\200\161\142\162\045\164\131\165\202\166" + + "\143\167\150\170\224\171\112\177\040\201\046\202\156" + + "\203\145\001\002\000\002\001\uffc3\000\002\001\uffc2\000" + + "\012\140\u029d\142\055\160\050\201\046\001\002\000\012" + + "\137\u0299\142\055\160\050\201\046\001\002\000\006\052" + + "\102\137\u029b\001\002\000\006\060\u0293\100\257\001\002" + + "\000\002\001\uffc4\000\006\060\u0293\100\257\001\002\000" + + "\002\001\uffc5\000\006\060\u0293\100\257\001\002\000\006" + + "\052\102\140\u029f\001\002\000\006\060\u0293\100\257\001" + + "\002\000\002\001\uffc7\000\002\001\uffc6\000\002\001\uffc1" + + "\000\004\100\u02a4\001\002\000\012\136\u02a6\142\055\160" + + "\050\201\046\001\002\000\006\052\102\136\u02a7\001\002" + + "\000\002\001\ufff8\000\002\001\ufff9\000\006\050\017\141" + + "\023\001\002\000\012\100\257\142\055\160\050\201\046" + + "\001\002\000\014\066\u02ad\100\257\142\055\160\050\201" + + "\046\001\uffdc\000\004\066\u02ad\001\uffdc\000\004\063\u02d0" + + "\001\uffe1\000\006\061\u02ae\202\u02b1\001\002\000\004\202" + + "\u02c7\001\002\000\024\077\u02bf\114\u02c5\142\u02c3\150\u02c6" + + "\155\u02c2\160\050\162\u02c4\177\u02c0\201\046\001\002\000" + + "\004\052\u02bc\001\uffdd\000\032\046\u02b4\051\u02b3\055\u02b5" + + "\077\uffcc\114\uffcc\142\uffcc\150\uffcc\155\uffcc\160\uffcc\162" + + "\uffcc\177\uffcc\201\uffcc\001\uffdf\000\002\001\uffdb\000\004" + + "\202\u02be\001\002\000\006\061\u02ae\202\u02bb\001\002\000" + + "\004\055\u02b6\001\002\000\004\202\u02b7\001\uffca\000\004" + + "\051\u02b8\001\uffcb\000\004\202\u02b9\001\002\000\002\001" + + "\uffc9\000\004\052\u02bc\001\uffde\000\006\051\u02b3\055\u02b5" + + "\001\uffcc\000\006\061\u02ae\202\u02bb\001\002\000\002\001" + + "\uffda\000\002\001\uffc8\000\002\001\uffd7\000\002\001\uffd3" + + "\000\002\001\uffd9\000\002\001\uffd4\000\004\151\056\001" + + "\uffd6\000\002\001\uffd5\000\002\001\uffd2\000\002\001\uffd8" + + "\000\006\051\u02c8\055\u02c9\001\uffd1\000\004\202\u02ce\001" + + "\002\000\004\055\u02ca\001\002\000\004\202\u02cb\001\uffcf" + + "\000\004\051\u02cc\001\uffd0\000\004\202\u02cd\001\002\000" + + "\002\001\uffce\000\002\001\uffcd\000\002\001\uffe6\000\004" + + "\202\u02d1\001\002\000\002\001\uffe0\000\004\066\u02ad\001" + + "\uffdc\000\004\066\u02ad\001\uffdc\000\004\063\u02d0\001\uffe1" + + "\000\002\001\uffe2\000\004\063\u02d0\001\uffe1\000\002\001" + + "\uffe7\000\004\063\u02d0\001\uffe1\000\002\001\uffe3\000\012" + + "\052\102\060\u02dd\064\u02dc\076\u02db\001\uffa6\000\022\114" + + "\047\142\043\150\051\155\042\160\050\162\045\177\040" + + "\201\046\001\002\000\022\114\047\142\043\150\051\155" + + "\042\160\050\162\045\177\040\201\046\001\002\000\022" + + "\114\047\142\043\150\051\155\042\160\050\162\045\177" + + "\040\201\046\001\002\000\004\100\u02df\001\002\000\024" + + "\052\075\053\065\062\067\130\066\134\077\142\055\160" + + "\050\163\074\201\046\001\uff68\000\004\136\u02e1\001\002" + + "\000\004\100\257\001\uff62\000\002\001\uffb2\000\002\001" + + "\uff61\000\004\131\u02e6\001\uffa7\000\002\001\uff9a\000\022" + + "\114\047\142\043\150\051\155\042\160\050\162\045\177" + + "\040\201\046\001\002\000\002\001\uff99\000\002\001\uffa9" + + "\000\004\131\u02e6\001\uffa8\000\002\001\uffaa\000\002\001" + + "\uffad\000\004\101\u02ed\001\uffff\000\012\061\u02ef\142\055" + + "\160\050\201\046\001\002\000\002\001\uff91\000\010\142" + + "\055\160\050\201\046\001\002\000\006\052\u02f1\137\u02f2" + + "\001\002\000\012\061\u02f4\142\055\160\050\201\046\001" + + "\002\000\002\001\ufffe\000\002\001\uff8f\000\010\142\055" + + "\160\050\201\046\001\002\000\002\001\uff8e\000\002\001" + + "\uff90\000\004\100\257\001\002\000\004\100\257\001\002" + + "\000\002\001\ufff7\000\002\001\ufff5\000\002\001\ufff6\000" + + "\014\066\u02ad\100\257\142\055\160\050\201\046\001\uffdc" + + "\000\004\066\u02ad\001\uffdc\000\004\063\u02d0\001\uffe1\000" + + "\002\001\uffe8\000\004\066\u02ad\001\uffdc\000\004\066\u02ad" + + "\001\uffdc\000\004\063\u02d0\001\uffe1\000\002\001\uffe4\000" + + "\004\063\u02d0\001\uffe1\000\002\001\uffe9\000\004\063\u02d0" + + "\001\uffe1\000\002\001\uffe5\000\004\100\257\001\002\000" + + "\004\100\257\001\002\000\002\001\ufff4\000\002\001\ufff2" + + "\000\002\001\ufff3\000\002\001\000" }); /** Access to parse-action table. */ + @Override public short[][] action_table() {return _action_table;} /** reduce_goto table. */ protected static final short[][] _reduce_table = unpackFromStrings(new String[] { - "\000\u02b4\000\006\106\003\107\004\001\001\000\002\001" + + "\000\u030b\000\006\106\003\107\004\001\001\000\002\001" + "\001\000\024\012\024\013\013\037\014\051\010\067\006" + - "\076\017\100\021\101\022\123\030\001\001\000\002\001" + - "\001\000\002\001\001\000\010\031\u02b2\053\u02b0\054\041" + + "\076\017\100\021\101\023\123\030\001\001\000\002\001" + + "\001\000\002\001\001\000\010\031\u0309\053\u0307\054\043" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\010\031\u02a5\053\u02a4\054\041\001\001\000\002" + - "\001\001\000\010\031\u02a1\053\u029f\054\041\001\001\000" + - "\002\001\001\000\002\001\001\000\006\053\u0294\054\041" + - "\001\001\000\006\100\021\101\u0292\001\001\000\010\053" + - "\066\054\041\055\u0282\001\001\000\002\001\001\000\002" + + "\001\000\010\031\u02fc\053\u02fb\054\043\001\001\000\002" + + "\001\001\000\010\031\u02f8\053\u02f6\054\043\001\001\000" + + "\002\001\001\000\002\001\001\000\006\053\u02eb\054\043" + + "\001\001\000\006\100\021\101\u02e9\001\001\000\002\001" + + "\001\000\010\053\067\054\043\055\u02d9\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\006\053\u024c\054\041\001\001" + - "\000\006\053\u023b\054\041\001\001\000\010\053\u0225\054" + - "\041\102\u0226\001\001\000\006\053\u0219\054\041\001\001" + - "\000\010\053\036\054\041\102\047\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\006\053\u02a2" + + "\054\043\001\001\000\006\053\u0291\054\043\001\001\000" + + "\010\053\u027b\054\043\102\u027c\001\001\000\006\053\u026f" + + "\054\043\001\001\000\010\053\040\054\043\102\051\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\006" + - "\053\051\054\041\001\001\000\002\001\001\000\002\001" + - "\001\000\004\054\054\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\140\002\106\003\105\004" + - "\165\005\104\006\132\007\131\010\142\011\141\021\110" + - "\022\107\023\202\024\201\025\155\026\154\030\u0208\031" + - "\210\040\103\041\102\042\206\043\205\044\216\045\215" + - "\046\174\047\172\053\200\054\041\057\122\060\121\061" + - "\113\062\111\063\145\064\144\065\116\066\114\070\130" + - "\071\127\073\157\074\156\102\135\113\140\114\137\115" + - "\171\116\167\117\213\120\212\121\163\122\162\001\001" + - "\000\016\014\070\015\065\017\u0203\053\066\054\041\055" + - "\067\001\001\000\016\014\070\015\065\017\072\053\066" + - "\054\041\055\067\001\001\000\010\053\066\054\041\055" + - "\u01fe\001\001\000\010\053\066\054\041\055\u01f9\001\001" + - "\000\010\053\066\054\041\055\u01f4\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\016\014\070\015\065\017\u01ed\053\066\054\041\055" + - "\067\001\001\000\002\001\001\000\010\053\066\054\041" + - "\055\075\001\001\000\010\053\066\054\041\055\u01e4\001" + - "\001\000\002\001\001\000\006\053\u01e3\054\041\001\001" + - "\000\140\002\106\003\105\004\165\005\104\006\132\007" + - "\131\010\142\011\141\021\110\022\107\023\202\024\201" + - "\025\155\026\154\030\u01e0\031\210\040\103\041\102\042" + - "\206\043\205\044\216\045\215\046\174\047\172\053\200" + - "\054\041\057\122\060\121\061\113\062\111\063\145\064" + - "\144\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\140\114\137\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\125" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\006\053\u01df\054\041\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\004\072\u01d2\001\001\000\002\001\001" + - "\000\002\001\001\000\016\014\070\015\u010c\016\u01cf\053" + - "\066\054\041\055\067\001\001\000\002\001\001\000\002" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\006\053\053\054\043\001" + + "\001\000\002\001\001\000\002\001\001\000\004\054\056" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\146\002\114\003\113\004\174\005\112\006\137" + + "\007\136\010\151\011\150\021\116\022\115\023\215\024" + + "\214\025\164\026\163\030\u025e\031\224\040\110\041\107" + + "\042\221\043\220\044\232\045\231\046\205\047\203\053" + + "\213\054\043\057\106\060\105\061\120\062\117\063\154" + + "\064\153\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\146\114\145\115\200\116\176\117\227" + + "\120\226\121\172\122\171\124\211\125\210\126\202\001" + + "\001\000\016\014\072\015\070\017\u0259\053\067\054\043" + + "\055\071\001\001\000\016\014\072\015\070\017\075\053" + + "\067\054\043\055\071\001\001\000\010\053\067\054\043" + + "\055\u0254\001\001\000\010\053\067\054\043\055\u024f\001" + + "\001\000\010\053\067\054\043\055\u024a\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\062\004\165\005\u01cc\006\132\007\131\021\110" + - "\022\107\023\202\024\201\031\210\046\174\047\172\053" + - "\200\054\041\061\u01cb\062\317\065\116\066\114\070\130" + - "\071\127\073\157\074\156\102\135\121\163\122\162\001" + - "\001\000\002\001\001\000\002\001\001\000\074\004\165" + - "\006\132\007\131\021\110\022\107\023\202\024\201\031" + - "\210\046\174\047\172\053\200\054\041\061\113\062\111" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\u01ca\114\u01c9\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\150\002\106\003\105\004" + - "\165\005\104\006\132\007\131\010\142\011\141\014\u01a6" + - "\020\u01a4\021\110\022\107\023\202\024\201\025\155\026" + - "\154\030\246\031\210\033\247\040\103\041\102\042\206" + - "\043\205\044\216\045\215\046\174\047\172\053\u01a7\054" + - "\041\055\u01a3\057\122\060\121\061\113\062\111\063\145" + - "\064\144\065\116\066\114\070\130\071\127\073\157\074" + - "\156\102\135\113\140\114\137\115\171\116\167\117\213" + - "\120\212\121\163\122\162\001\001\000\002\001\001\000" + - "\140\002\106\003\105\004\165\005\104\006\132\007\131" + - "\010\142\011\141\021\110\022\107\023\202\024\201\025" + - "\155\026\154\030\u019f\031\210\040\103\041\102\042\206" + - "\043\205\044\216\045\215\046\174\047\172\053\200\054" + - "\041\057\122\060\121\061\113\062\111\063\145\064\144" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\140\114\137\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\106\004\165" + - "\005\u0199\006\132\007\131\010\142\011\141\021\110\022" + - "\107\023\202\024\201\031\210\046\174\047\172\053\200" + - "\054\041\057\u019a\060\u0163\061\113\062\111\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\140" + - "\114\137\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\022\004\165\005\u0197\031\210\053\200" + - "\054\041\102\135\121\u0198\122\360\001\001\000\002\001" + + "\001\000\010\053\067\054\043\055\u022e\001\001\000\016" + + "\014\072\015\070\017\u022c\053\067\054\043\055\071\001" + + "\001\000\002\001\001\000\010\053\067\054\043\055\100" + + "\001\001\000\010\053\067\054\043\055\u0223\001\001\000" + + "\002\001\001\000\006\053\u0222\054\043\001\001\000\146" + + "\002\114\003\113\004\174\005\112\006\137\007\136\010" + + "\151\011\150\021\116\022\115\023\215\024\214\025\164" + + "\026\163\030\u021f\031\224\040\110\041\107\042\221\043" + + "\220\044\232\045\231\046\205\047\203\053\213\054\043" + + "\057\106\060\105\061\120\062\117\063\154\064\153\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\146\114\145\115\200\116\176\117\227\120\226\121" + + "\172\122\171\124\211\125\210\126\202\001\001\000\146" + + "\002\114\003\113\004\174\005\112\006\137\007\136\010" + + "\151\011\150\021\116\022\115\023\215\024\214\025\164" + + "\026\163\030\132\031\224\040\110\041\107\042\221\043" + + "\220\044\232\045\231\046\205\047\203\053\213\054\043" + + "\057\106\060\105\061\120\062\117\063\154\064\153\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\146\114\145\115\200\116\176\117\227\120\226\121" + + "\172\122\171\124\211\125\210\126\202\001\001\000\006" + + "\053\u021e\054\043\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\106\004\174" + + "\005\u021d\006\137\007\136\010\151\011\150\021\116\022" + + "\115\023\215\024\214\031\224\046\205\047\203\053\213" + + "\054\043\057\u021c\060\u0168\061\120\062\117\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\146" + + "\114\145\115\200\116\176\117\227\120\226\121\172\122" + + "\171\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\004\072\u020f\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\016\014\072\015\u0123" + + "\016\u020c\053\067\054\043\055\071\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\062\004\174\005\u0209\006\137\007\136\021\116\022" + + "\115\023\215\024\214\031\224\046\205\047\203\053\213" + + "\054\043\061\u0208\062\341\065\124\066\122\070\135\071" + + "\134\073\166\074\165\102\143\121\172\122\171\001\001" + + "\000\076\004\174\005\u010c\006\137\007\136\021\116\022" + + "\115\023\215\024\214\031\224\046\205\047\203\053\213" + + "\054\043\061\120\062\117\065\124\066\122\070\135\071" + + "\134\073\166\074\165\102\143\113\u0207\114\u0206\115\200" + + "\116\176\117\227\120\226\121\172\122\171\001\001\000" + + "\106\004\174\005\u0205\006\137\007\136\010\151\011\150" + + "\021\116\022\115\023\215\024\214\031\224\046\205\047" + + "\203\053\213\054\043\057\u0204\060\u0143\061\120\062\117" + + "\065\124\066\122\070\135\071\134\073\166\074\165\102" + + "\143\113\146\114\145\115\200\116\176\117\227\120\226" + + "\121\172\122\171\001\001\000\156\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\014\u01e1" + + "\020\u01df\021\116\022\115\023\215\024\214\025\164\026" + + "\163\030\265\031\224\033\266\040\110\041\107\042\221" + + "\043\220\044\232\045\231\046\205\047\203\053\u01e2\054" + + "\043\055\u01de\057\106\060\105\061\120\062\117\063\154" + + "\064\153\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\146\114\145\115\200\116\176\117\227" + + "\120\226\121\172\122\171\124\211\125\210\126\202\001" + + "\001\000\002\001\001\000\146\002\114\003\113\004\174" + + "\005\112\006\137\007\136\010\151\011\150\021\116\022" + + "\115\023\215\024\214\025\164\026\163\030\u01da\031\224" + + "\040\110\041\107\042\221\043\220\044\232\045\231\046" + + "\205\047\203\053\213\054\043\057\106\060\105\061\120" + + "\062\117\063\154\064\153\065\124\066\122\070\135\071" + + "\134\073\166\074\165\102\143\113\146\114\145\115\200" + + "\116\176\117\227\120\226\121\172\122\171\124\211\125" + + "\210\126\202\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\106\004\174\005" + + "\u01d5\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\031\224\046\205\047\203\053\213\054" + + "\043\057\u01d4\060\u0167\061\120\062\117\065\124\066\122" + + "\070\135\071\134\073\166\074\165\102\143\113\146\114" + + "\145\115\200\116\176\117\227\120\226\121\172\122\171" + + "\001\001\000\022\004\174\005\u01d2\031\224\053\213\054" + + "\043\102\143\121\u01d3\122\u0102\001\001\000\106\004\174" + + "\005\u01d1\006\137\007\136\010\151\011\150\021\116\022" + + "\115\023\215\024\214\031\224\046\205\047\203\053\213" + + "\054\043\057\u01d0\060\u014a\061\120\062\117\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\146" + + "\114\145\115\200\116\176\117\227\120\226\121\172\122" + + "\171\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\106\004\174\005\u01cf\006" + + "\137\007\136\010\151\011\150\021\116\022\115\023\215" + + "\024\214\031\224\046\205\047\203\053\213\054\043\057" + + "\u01ce\060\u014b\061\120\062\117\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\016\014\070\015\u010c\016" + - "\u016a\053\066\054\041\055\067\001\001\000\074\004\165" + - "\006\132\007\131\021\110\022\107\023\202\024\201\031" + - "\210\046\174\047\172\053\200\054\041\061\113\062\111" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\u0169\114\u0168\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\074\004\165\006\132\007" + - "\131\021\110\022\107\023\202\024\201\031\210\046\174" + - "\047\172\053\200\054\041\061\113\062\111\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\u0167" + - "\114\u0166\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\016\014\070\015\u010c\016" + - "\u012a\053\066\054\041\055\067\001\001\000\022\004\165" + - "\005\u0128\031\210\053\200\054\041\102\135\121\u0129\122" + - "\357\001\001\000\002\001\001\000\002\001\001\000\062" + - "\004\165\005\u0127\006\132\007\131\021\110\022\107\023" + - "\202\024\201\031\210\046\174\047\172\053\200\054\041" + - "\061\u0126\062\361\065\116\066\114\070\130\071\127\073" + - "\157\074\156\102\135\121\163\122\162\001\001\000\002" + - "\001\001\000\140\002\106\003\105\004\165\005\104\006" + - "\132\007\131\010\142\011\141\021\110\022\107\023\202" + - "\024\201\025\155\026\154\030\u0125\031\210\040\103\041" + - "\102\042\206\043\205\044\216\045\215\046\174\047\172" + - "\053\200\054\041\057\122\060\121\061\113\062\111\063" + - "\145\064\144\065\116\066\114\070\130\071\127\073\157" + - "\074\156\102\135\113\140\114\137\115\171\116\167\117" + - "\213\120\212\121\163\122\162\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\016\014\070\015\u010c\016\u0119\053\066\054\041\055\067" + - "\001\001\000\002\001\001\000\016\014\070\015\u010c\016" + - "\u0117\053\066\054\041\055\067\001\001\000\074\004\165" + - "\006\132\007\131\021\110\022\107\023\202\024\201\031" + - "\210\046\174\047\172\053\200\054\041\061\113\062\111" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\u0116\114\u0115\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\074\004\165\006\132\007" + - "\131\021\110\022\107\023\202\024\201\031\210\046\174" + - "\047\172\053\200\054\041\061\113\062\111\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\u0113" + - "\114\u0112\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\016\014\070\015\u010c\016\u010d\053\066\054" + - "\041\055\067\001\001\000\074\004\165\006\132\007\131" + - "\021\110\022\107\023\202\024\201\031\210\046\174\047" + - "\172\053\200\054\041\061\113\062\111\065\116\066\114" + - "\070\130\071\127\073\157\074\156\102\135\113\u010b\114" + - "\u010a\115\171\116\167\117\213\120\212\121\163\122\162" + - "\001\001\000\002\001\001\000\002\001\001\000\022\004" + - "\165\005\u0108\031\210\053\200\054\041\102\135\121\u0109" + - "\122\326\001\001\000\002\001\001\000\074\004\165\006" + - "\132\007\131\021\110\022\107\023\202\024\201\031\210" + - "\046\174\047\172\053\200\054\041\061\113\062\111\065" + - "\116\066\114\070\130\071\127\073\157\074\156\102\135" + - "\113\371\114\370\115\171\116\167\117\213\120\212\121" + - "\163\122\162\001\001\000\002\001\001\000\002\001\001" + - "\000\010\050\234\053\233\054\041\001\001\000\002\001" + - "\001\000\002\001\001\000\062\004\165\005\223\006\132" + - "\007\131\021\110\022\107\023\202\024\201\031\210\046" + - "\174\047\172\053\200\054\041\061\221\062\220\065\116" + - "\066\114\070\130\071\127\073\157\074\156\102\135\121" + - "\163\122\162\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\144\002\106\003" + - "\105\004\165\005\104\006\132\007\131\010\142\011\141" + - "\021\110\022\107\023\202\024\201\025\155\026\154\030" + - "\225\031\210\035\226\036\227\040\103\041\102\042\206" + - "\043\205\044\216\045\215\046\174\047\172\053\200\054" + - "\041\057\122\060\121\061\113\062\111\063\145\064\144" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\140\114\137\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\140\002\106\003\105\004\165" + - "\005\104\006\132\007\131\010\142\011\141\021\110\022" + - "\107\023\202\024\201\025\155\026\154\030\231\031\210" + - "\040\103\041\102\042\206\043\205\044\216\045\215\046" + - "\174\047\172\053\200\054\041\057\122\060\121\061\113" + - "\062\111\063\145\064\144\065\116\066\114\070\130\071" + - "\127\073\157\074\156\102\135\113\140\114\137\115\171" + - "\116\167\117\213\120\212\121\163\122\162\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\140\002\106\003\105\004\165\005\104\006" + - "\132\007\131\010\142\011\141\021\110\022\107\023\202" + - "\024\201\025\155\026\154\030\236\031\210\040\103\041" + - "\102\042\206\043\205\044\216\045\215\046\174\047\172" + - "\053\200\054\041\057\122\060\121\061\113\062\111\063" + - "\145\064\144\065\116\066\114\070\130\071\127\073\157" + - "\074\156\102\135\113\140\114\137\115\171\116\167\117" + - "\213\120\212\121\163\122\162\001\001\000\006\031\243" + - "\034\240\001\001\000\010\050\252\053\233\054\041\001" + - "\001\000\002\001\001\000\142\002\106\003\105\004\165" + - "\005\104\006\132\007\131\010\142\011\141\021\110\022" + - "\107\023\202\024\201\025\155\026\154\030\246\031\210" + - "\033\247\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\140\002\106\003\105\004\165\005\104\006\132" + - "\007\131\010\142\011\141\021\110\022\107\023\202\024" + - "\201\025\155\026\154\030\244\031\210\040\103\041\102" + - "\042\206\043\205\044\216\045\215\046\174\047\172\053" + - "\200\054\041\057\122\060\121\061\113\062\111\063\145" + - "\064\144\065\116\066\114\070\130\071\127\073\157\074" + - "\156\102\135\113\140\114\137\115\171\116\167\117\213" + - "\120\212\121\163\122\162\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\140" + - "\002\106\003\105\004\165\005\104\006\132\007\131\010" + - "\142\011\141\021\110\022\107\023\202\024\201\025\155" + - "\026\154\030\251\031\210\040\103\041\102\042\206\043" + - "\205\044\216\045\215\046\174\047\172\053\200\054\041" + - "\057\122\060\121\061\113\062\111\063\145\064\144\065" + - "\116\066\114\070\130\071\127\073\157\074\156\102\135" + - "\113\140\114\137\115\171\116\167\117\213\120\212\121" + - "\163\122\162\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\042\004\165\005\367\007\270\022" + - "\264\024\201\031\210\047\257\053\200\054\041\062\111" + - "\066\265\071\272\074\156\102\135\116\366\122\162\001" + - "\001\000\042\004\165\005\365\007\270\022\264\024\201" + - "\031\210\047\257\053\200\054\041\062\111\066\265\071" + - "\272\074\156\102\135\116\364\122\162\001\001\000\042" + - "\004\165\005\363\007\270\022\264\024\201\031\210\047" + - "\257\053\200\054\041\062\111\066\265\071\272\074\156" + - "\102\135\116\362\122\162\001\001\000\042\004\165\005" + - "\273\007\270\022\264\024\201\031\210\047\257\053\200" + - "\054\041\062\111\066\265\071\272\074\156\102\135\116" + - "\267\122\162\001\001\000\002\001\001\000\036\004\165" + - "\007\270\022\264\024\201\031\210\047\257\053\200\054" + - "\041\062\220\066\265\071\272\074\156\102\135\122\162" + - "\001\001\000\036\004\165\007\270\022\264\024\201\031" + - "\210\047\257\053\200\054\041\062\361\066\265\071\272" + - "\074\156\102\135\122\162\001\001\000\016\004\165\031" + - "\210\053\200\054\041\102\135\122\360\001\001\000\016" + - "\004\165\031\210\053\200\054\041\102\135\122\357\001" + - "\001\000\004\072\351\001\001\000\002\001\001\000\016" + - "\004\165\031\210\053\200\054\041\102\135\122\326\001" + - "\001\000\002\001\001\000\002\001\001\000\036\004\165" + - "\007\270\022\264\024\201\031\210\047\257\053\200\054" + - "\041\062\317\066\265\071\272\074\156\102\135\122\162" + - "\001\001\000\002\001\001\000\002\001\001\000\022\004" + - "\165\007\277\024\201\031\210\053\200\054\041\102\135" + - "\122\162\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\144\002\106\003\105\004\165\005\104" + - "\006\132\007\131\010\142\011\141\021\110\022\107\023" + - "\202\024\201\025\155\026\154\030\225\031\210\035\307" + - "\036\227\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\016\004\165\031\210\053\200\054\041\102\135" + - "\122\306\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\144\002\106\003\105\004" + - "\165\005\104\006\132\007\131\010\142\011\141\021\110" + - "\022\107\023\202\024\201\025\155\026\154\030\225\031" + - "\210\035\312\036\227\040\103\041\102\042\206\043\205" + - "\044\216\045\215\046\174\047\172\053\200\054\041\057" + - "\122\060\121\061\113\062\111\063\145\064\144\065\116" + - "\066\114\070\130\071\127\073\157\074\156\102\135\113" + - "\140\114\137\115\171\116\167\117\213\120\212\121\163" + - "\122\162\001\001\000\002\001\001\000\002\001\001\000" + - "\144\002\106\003\105\004\165\005\104\006\132\007\131" + - "\010\142\011\141\021\110\022\107\023\202\024\201\025" + - "\155\026\154\030\225\031\210\035\315\036\227\040\103" + - "\041\102\042\206\043\205\044\216\045\215\046\174\047" + - "\172\053\200\054\041\057\122\060\121\061\113\062\111" + - "\063\145\064\144\065\116\066\114\070\130\071\127\073" + - "\157\074\156\102\135\113\140\114\137\115\171\116\167" + - "\117\213\120\212\121\163\122\162\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\036\004\165" + - "\007\270\022\264\024\201\031\210\047\257\053\200\054" + - "\041\062\325\066\265\071\272\074\156\102\135\122\162" + - "\001\001\000\036\004\165\007\270\022\264\024\201\031" + - "\210\047\257\053\200\054\041\062\324\066\265\071\272" + - "\074\156\102\135\122\162\001\001\000\036\004\165\007" + - "\270\022\264\024\201\031\210\047\257\053\200\054\041" + - "\062\323\066\265\071\272\074\156\102\135\122\162\001" + + "\001\001\000\002\001\001\000\016\014\072\015\u0123\016" + + "\u01a1\053\067\054\043\055\071\001\001\000\076\004\174" + + "\005\u010c\006\137\007\136\021\116\022\115\023\215\024" + + "\214\031\224\046\205\047\203\053\213\054\043\061\120" + + "\062\117\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\u01a0\114\u019f\115\200\116\176\117\227" + + "\120\226\121\172\122\171\001\001\000\076\004\174\005" + + "\u010c\006\137\007\136\021\116\022\115\023\215\024\214" + + "\031\224\046\205\047\203\053\213\054\043\061\120\062" + + "\117\065\124\066\122\070\135\071\134\073\166\074\165" + + "\102\143\113\u019e\114\u019d\115\200\116\176\117\227\120" + + "\226\121\172\122\171\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\016\014" + + "\072\015\u0123\016\u018a\053\067\054\043\055\071\001\001" + + "\000\022\004\174\005\u0188\031\224\053\213\054\043\102" + + "\143\121\u0189\122\u0101\001\001\000\002\001\001\000\002" + + "\001\001\000\062\004\174\005\u0187\006\137\007\136\021" + + "\116\022\115\023\215\024\214\031\224\046\205\047\203" + + "\053\213\054\043\061\u0186\062\u0103\065\124\066\122\070" + + "\135\071\134\073\166\074\165\102\143\121\172\122\171" + + "\001\001\000\002\001\001\000\146\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\u0185\031" + + "\224\040\110\041\107\042\221\043\220\044\232\045\231" + + "\046\205\047\203\053\213\054\043\057\106\060\105\061" + + "\120\062\117\063\154\064\153\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\124\211" + + "\125\210\126\202\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\106\004\174\005\u017c\006\137" + + "\007\136\010\151\011\150\021\116\022\115\023\215\024" + + "\214\031\224\046\205\047\203\053\213\054\043\057\u017b" + + "\060\u014c\061\120\062\117\065\124\066\122\070\135\071" + + "\134\073\166\074\165\102\143\113\146\114\145\115\200" + + "\116\176\117\227\120\226\121\172\122\171\001\001\000" + + "\002\001\001\000\002\001\001\000\016\014\072\015\u0123" + + "\016\u0175\053\067\054\043\055\071\001\001\000\002\001" + + "\001\000\016\014\072\015\u0123\016\u0173\053\067\054\043" + + "\055\071\001\001\000\076\004\174\005\u010c\006\137\007" + + "\136\021\116\022\115\023\215\024\214\031\224\046\205" + + "\047\203\053\213\054\043\061\120\062\117\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\u0172" + + "\114\u0171\115\200\116\176\117\227\120\226\121\172\122" + + "\171\001\001\000\002\001\001\000\002\001\001\000\076" + + "\004\174\005\u010c\006\137\007\136\021\116\022\115\023" + + "\215\024\214\031\224\046\205\047\203\053\213\054\043" + + "\061\120\062\117\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\u012a\114\u0129\115\200\116\176" + + "\117\227\120\226\121\172\122\171\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\016\014\072" + + "\015\u0123\016\u0124\053\067\054\043\055\071\001\001\000" + + "\076\004\174\005\u010c\006\137\007\136\021\116\022\115" + + "\023\215\024\214\031\224\046\205\047\203\053\213\054" + + "\043\061\120\062\117\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\u0122\114\u0121\115\200\116" + + "\176\117\227\120\226\121\172\122\171\001\001\000\002" + + "\001\001\000\002\001\001\000\022\004\174\005\u011e\031" + + "\224\053\213\054\043\102\143\121\u011f\122\350\001\001" + + "\000\106\004\174\005\u011d\006\137\007\136\010\151\011" + + "\150\021\116\022\115\023\215\024\214\031\224\046\205" + + "\047\203\053\213\054\043\057\u011c\060\u011b\061\120\062" + + "\117\065\124\066\122\070\135\071\134\073\166\074\165" + + "\102\143\113\146\114\145\115\200\116\176\117\227\120" + + "\226\121\172\122\171\001\001\000\002\001\001\000\076" + + "\004\174\005\u010c\006\137\007\136\021\116\022\115\023" + + "\215\024\214\031\224\046\205\047\203\053\213\054\043" + + "\061\120\062\117\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\u010b\114\u010a\115\200\116\176" + + "\117\227\120\226\121\172\122\171\001\001\000\002\001" + + "\001\000\002\001\001\000\010\050\251\053\250\054\043" + + "\001\001\000\002\001\001\000\002\001\001\000\062\004" + + "\174\005\237\006\137\007\136\021\116\022\115\023\215" + + "\024\214\031\224\046\205\047\203\053\213\054\043\061" + + "\235\062\234\065\124\066\122\070\135\071\134\073\166" + + "\074\165\102\143\121\172\122\171\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\032\004\165\007\270\022\264\024" + - "\201\031\210\047\330\053\200\054\041\071\272\074\156" + - "\102\135\122\162\001\001\000\002\001\001\000\030\004" + - "\165\007\270\022\264\024\201\031\210\053\200\054\041" + - "\071\272\074\332\102\135\122\162\001\001\000\002\001" + - "\001\000\024\004\165\007\270\024\201\031\210\053\200" + - "\054\041\071\356\102\135\122\162\001\001\000\002\001" + + "\000\002\001\001\000\152\002\114\003\113\004\174\005" + + "\112\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\025\164\026\163\030\242\031\224\035" + + "\243\036\244\040\110\041\107\042\221\043\220\044\232" + + "\045\231\046\205\047\203\053\213\054\043\057\106\060" + + "\105\061\120\062\117\063\154\064\153\065\124\066\122" + + "\070\135\071\134\073\166\074\165\102\143\113\146\114" + + "\145\115\200\116\176\117\227\120\226\121\172\122\171" + + "\124\211\125\210\126\202\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\146\002\114\003\113" + + "\004\174\005\112\006\137\007\136\010\151\011\150\021" + + "\116\022\115\023\215\024\214\025\164\026\163\030\246" + + "\031\224\040\110\041\107\042\221\043\220\044\232\045" + + "\231\046\205\047\203\053\213\054\043\057\106\060\105" + + "\061\120\062\117\063\154\064\153\065\124\066\122\070" + + "\135\071\134\073\166\074\165\102\143\113\146\114\145" + + "\115\200\116\176\117\227\120\226\121\172\122\171\124" + + "\211\125\210\126\202\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\146\002" + + "\114\003\113\004\174\005\112\006\137\007\136\010\151" + + "\011\150\021\116\022\115\023\215\024\214\025\164\026" + + "\163\030\253\031\224\040\110\041\107\042\221\043\220" + + "\044\232\045\231\046\205\047\203\053\213\054\043\057" + + "\106\060\105\061\120\062\117\063\154\064\153\065\124" + + "\066\122\070\135\071\134\073\166\074\165\102\143\113" + + "\146\114\145\115\200\116\176\117\227\120\226\121\172" + + "\122\171\124\211\125\210\126\202\001\001\000\006\031" + + "\260\034\255\001\001\000\010\050\273\053\250\054\043" + + "\001\001\000\002\001\001\000\150\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\265\031" + + "\224\033\266\040\110\041\107\042\221\043\220\044\232" + + "\045\231\046\205\047\203\053\213\054\043\057\106\060" + + "\105\061\120\062\117\063\154\064\153\065\124\066\122" + + "\070\135\071\134\073\166\074\165\102\143\113\146\114" + + "\145\115\200\116\176\117\227\120\226\121\172\122\171" + + "\124\211\125\210\126\202\001\001\000\144\002\114\003" + + "\113\004\174\005\112\006\137\007\136\010\151\011\150" + + "\021\116\022\115\023\215\024\214\025\164\026\163\031" + + "\224\040\110\041\107\042\221\043\220\044\232\045\231" + + "\046\205\047\203\053\213\054\043\057\106\060\105\061" + + "\120\062\117\063\154\064\153\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\124\211" + + "\125\210\126\261\001\001\000\002\001\001\000\002\001" + + "\001\000\146\002\114\003\113\004\174\005\112\006\137" + + "\007\136\010\151\011\150\021\116\022\115\023\215\024" + + "\214\025\164\026\163\030\263\031\224\040\110\041\107" + + "\042\221\043\220\044\232\045\231\046\205\047\203\053" + + "\213\054\043\057\106\060\105\061\120\062\117\063\154" + + "\064\153\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\146\114\145\115\200\116\176\117\227" + + "\120\226\121\172\122\171\124\211\125\210\126\202\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\002\001\001\000\030\004" + - "\165\007\270\022\264\024\201\031\210\053\200\054\041" + - "\071\272\074\355\102\135\122\162\001\001\000\002\001" + + "\000\146\002\114\003\113\004\174\005\112\006\137\007" + + "\136\010\151\011\150\021\116\022\115\023\215\024\214" + + "\025\164\026\163\030\270\031\224\040\110\041\107\042" + + "\221\043\220\044\232\045\231\046\205\047\203\053\213" + + "\054\043\057\106\060\105\061\120\062\117\063\154\064" + + "\153\065\124\066\122\070\135\071\134\073\166\074\165" + + "\102\143\113\146\114\145\115\200\116\176\117\227\120" + + "\226\121\172\122\171\124\211\125\210\126\202\001\001" + + "\000\002\001\001\000\002\001\001\000\150\002\114\003" + + "\113\004\174\005\112\006\137\007\136\010\151\011\150" + + "\021\116\022\115\023\215\024\214\025\164\026\163\030" + + "\265\031\224\033\272\040\110\041\107\042\221\043\220" + + "\044\232\045\231\046\205\047\203\053\213\054\043\057" + + "\106\060\105\061\120\062\117\063\154\064\153\065\124" + + "\066\122\070\135\071\134\073\166\074\165\102\143\113" + + "\146\114\145\115\200\116\176\117\227\120\226\121\172" + + "\122\171\124\211\125\210\126\202\001\001\000\146\002" + + "\114\003\113\004\174\005\112\006\137\007\136\010\151" + + "\011\150\021\116\022\115\023\215\024\214\025\164\026" + + "\163\030\270\031\224\040\110\041\107\042\221\043\220" + + "\044\232\045\231\046\205\047\203\053\213\054\043\057" + + "\106\060\105\061\120\062\117\063\154\064\153\065\124" + + "\066\122\070\135\071\134\073\166\074\165\102\143\113" + + "\146\114\145\115\200\116\176\117\227\120\226\121\172" + + "\122\171\124\211\125\210\126\202\001\001\000\002\001" + + "\001\000\042\004\174\005\u0109\007\311\022\305\024\214" + + "\031\224\047\300\053\213\054\043\062\117\066\306\071" + + "\313\074\165\102\143\116\u0108\122\171\001\001\000\042" + + "\004\174\005\u0107\007\311\022\305\024\214\031\224\047" + + "\300\053\213\054\043\062\117\066\306\071\313\074\165" + + "\102\143\116\u0106\122\171\001\001\000\042\004\174\005" + + "\u0105\007\311\022\305\024\214\031\224\047\300\053\213" + + "\054\043\062\117\066\306\071\313\074\165\102\143\116" + + "\u0104\122\171\001\001\000\042\004\174\005\314\007\311" + + "\022\305\024\214\031\224\047\300\053\213\054\043\062" + + "\117\066\306\071\313\074\165\102\143\116\310\122\171" + + "\001\001\000\002\001\001\000\036\004\174\007\311\022" + + "\305\024\214\031\224\047\300\053\213\054\043\062\234" + + "\066\306\071\313\074\165\102\143\122\171\001\001\000" + + "\036\004\174\007\311\022\305\024\214\031\224\047\300" + + "\053\213\054\043\062\u0103\066\306\071\313\074\165\102" + + "\143\122\171\001\001\000\016\004\174\031\224\053\213" + + "\054\043\102\143\122\u0102\001\001\000\016\004\174\031" + + "\224\053\213\054\043\102\143\122\u0101\001\001\000\004" + + "\072\373\001\001\000\002\001\001\000\016\004\174\031" + + "\224\053\213\054\043\102\143\122\350\001\001\000\002" + + "\001\001\000\002\001\001\000\036\004\174\007\311\022" + + "\305\024\214\031\224\047\300\053\213\054\043\062\341" + + "\066\306\071\313\074\165\102\143\122\171\001\001\000" + + "\002\001\001\000\002\001\001\000\022\004\174\007\320" + + "\024\214\031\224\053\213\054\043\102\143\122\171\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\000\152\002\114\003\113\004\174\005\112\006\137\007" + + "\136\010\151\011\150\021\116\022\115\023\215\024\214" + + "\025\164\026\163\030\242\031\224\035\331\036\244\040" + + "\110\041\107\042\221\043\220\044\232\045\231\046\205" + + "\047\203\053\213\054\043\057\106\060\105\061\120\062" + + "\117\063\154\064\153\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\146\114\145\115\200\116" + + "\176\117\227\120\226\121\172\122\171\124\211\125\210" + + "\126\202\001\001\000\016\004\174\031\224\053\213\054" + + "\043\102\143\122\327\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\044\004\165" + - "\005\u0107\007\270\022\264\024\201\031\210\047\257\053" + - "\200\054\041\062\111\066\265\071\272\074\156\102\135" + - "\116\375\120\u0106\122\162\001\001\000\044\004\165\005" + - "\u0105\007\270\022\264\024\201\031\210\047\257\053\200" + - "\054\041\062\111\066\265\071\272\074\156\102\135\116" + - "\375\120\u0104\122\162\001\001\000\044\004\165\005\377" + - "\007\270\022\264\024\201\031\210\047\257\053\200\054" + - "\041\062\111\066\265\071\272\074\156\102\135\116\375" + - "\120\376\122\162\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\040\004\165\007\270\022\264" + - "\024\201\031\210\047\257\053\200\054\041\062\111\066" + - "\265\071\272\074\156\102\135\116\366\122\162\001\001" + - "\000\040\004\165\007\270\022\264\024\201\031\210\047" + - "\257\053\200\054\041\062\111\066\265\071\272\074\156" + - "\102\135\116\364\122\162\001\001\000\040\004\165\007" + - "\270\022\264\024\201\031\210\047\257\053\200\054\041" + - "\062\111\066\265\071\272\074\156\102\135\116\362\122" + - "\162\001\001\000\040\004\165\007\270\022\264\024\201" + - "\031\210\047\257\053\200\054\041\062\111\066\265\071" + - "\272\074\156\102\135\116\267\122\162\001\001\000\002" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\152\002\114\003\113\004\174\005\112\006\137\007" + + "\136\010\151\011\150\021\116\022\115\023\215\024\214" + + "\025\164\026\163\030\242\031\224\035\334\036\244\040" + + "\110\041\107\042\221\043\220\044\232\045\231\046\205" + + "\047\203\053\213\054\043\057\106\060\105\061\120\062" + + "\117\063\154\064\153\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\146\114\145\115\200\116" + + "\176\117\227\120\226\121\172\122\171\124\211\125\210" + + "\126\202\001\001\000\002\001\001\000\002\001\001\000" + + "\152\002\114\003\113\004\174\005\112\006\137\007\136" + + "\010\151\011\150\021\116\022\115\023\215\024\214\025" + + "\164\026\163\030\242\031\224\035\337\036\244\040\110" + + "\041\107\042\221\043\220\044\232\045\231\046\205\047" + + "\203\053\213\054\043\057\106\060\105\061\120\062\117" + + "\063\154\064\153\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\146\114\145\115\200\116\176" + + "\117\227\120\226\121\172\122\171\124\211\125\210\126" + + "\202\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\036\004\174\007\311\022\305\024\214\031" + + "\224\047\300\053\213\054\043\062\347\066\306\071\313" + + "\074\165\102\143\122\171\001\001\000\036\004\174\007" + + "\311\022\305\024\214\031\224\047\300\053\213\054\043" + + "\062\346\066\306\071\313\074\165\102\143\122\171\001" + + "\001\000\036\004\174\007\311\022\305\024\214\031\224" + + "\047\300\053\213\054\043\062\345\066\306\071\313\074" + + "\165\102\143\122\171\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\032\004" + + "\174\007\311\022\305\024\214\031\224\047\352\053\213" + + "\054\043\071\313\074\165\102\143\122\171\001\001\000" + + "\002\001\001\000\030\004\174\007\311\022\305\024\214" + + "\031\224\053\213\054\043\071\313\074\354\102\143\122" + + "\171\001\001\000\002\001\001\000\024\004\174\007\311" + + "\024\214\031\224\053\213\054\043\071\u0100\102\143\122" + + "\171\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\006\031\243\034" + - "\u010f\001\001\000\014\014\070\015\u0110\053\066\054\041" + - "\055\067\001\001\000\002\001\001\000\002\001\001\000" + - "\004\054\054\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\006\031\243\034\u0118\001\001\000\002\001\001\000\006" + - "\031\243\034\u011a\001\001\000\002\001\001\000\032\004" + - "\165\005\u011c\007\270\022\264\024\201\031\210\053\200" + - "\054\041\071\272\074\332\102\135\122\162\001\001\000" + - "\002\001\001\000\004\054\u011e\001\001\000\002\001\001" + - "\000\040\004\165\005\u0124\007\270\022\264\024\201\031" + - "\210\047\257\053\200\054\041\062\325\066\265\071\272" + - "\074\156\102\135\122\162\001\001\000\040\004\165\005" + - "\u0123\007\270\022\264\024\201\031\210\047\257\053\200" + - "\054\041\062\324\066\265\071\272\074\156\102\135\122" + - "\162\001\001\000\040\004\165\005\u0122\007\270\022\264" + - "\024\201\031\210\047\257\053\200\054\041\062\323\066" + - "\265\071\272\074\156\102\135\122\162\001\001\000\002" + + "\002\001\001\000\030\004\174\007\311\022\305\024\214" + + "\031\224\053\213\054\043\071\313\074\377\102\143\122" + + "\171\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\006\031\243\034\u012b\001\001\000" + - "\002\001\001\000\062\003\u0132\004\165\005\u0139\007\270" + - "\011\u0131\022\264\024\201\031\210\041\u0133\043\205\045" + - "\215\047\257\053\200\054\041\060\121\062\111\066\265" + - "\071\272\074\156\102\135\114\u0130\116\375\120\u0134\122" + - "\162\001\001\000\044\004\165\007\270\022\264\024\201" + - "\031\210\047\257\053\200\054\041\062\111\066\265\071" + - "\272\074\156\102\135\114\u0165\116\375\120\u0134\122\162" + - "\001\001\000\044\004\165\007\270\022\264\024\201\031" + - "\210\047\257\053\200\054\041\062\111\066\265\071\272" + - "\074\156\102\135\114\u0164\116\375\120\u0134\122\162\001" + - "\001\000\050\004\165\007\270\011\u0131\022\264\024\201" + - "\031\210\047\257\053\200\054\041\060\u0163\062\111\066" + - "\265\071\272\074\156\102\135\114\u0130\116\375\120\u0134" + - "\122\162\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\044" + - "\004\165\007\270\022\264\024\201\031\210\047\257\053" + - "\200\054\041\062\111\066\265\071\272\074\156\102\135" + - "\114\u0142\116\375\120\u0134\122\162\001\001\000\044\004" + - "\165\007\270\022\264\024\201\031\210\047\257\053\200" + - "\054\041\062\111\066\265\071\272\074\156\102\135\114" + - "\u0141\116\375\120\u0134\122\162\001\001\000\044\004\165" + - "\007\270\022\264\024\201\031\210\047\257\053\200\054" + - "\041\062\111\066\265\071\272\074\156\102\135\114\u0140" + - "\116\375\120\u0134\122\162\001\001\000\044\004\165\007" + - "\270\022\264\024\201\031\210\047\257\053\200\054\041" + - "\062\111\066\265\071\272\074\156\102\135\114\u013f\116" + - "\375\120\u0134\122\162\001\001\000\002\001\001\000\044" + - "\004\165\007\270\022\264\024\201\031\210\047\257\053" + - "\200\054\041\062\111\066\265\071\272\074\156\102\135" + - "\114\u013b\116\375\120\u0134\122\162\001\001\000\002\001" + - "\001\000\042\004\165\007\270\022\264\024\201\031\210" + - "\047\257\053\200\054\041\062\111\066\265\071\272\074" + - "\156\102\135\116\375\120\u0106\122\162\001\001\000\042" + - "\004\165\007\270\022\264\024\201\031\210\047\257\053" + - "\200\054\041\062\111\066\265\071\272\074\156\102\135" + - "\116\375\120\u0104\122\162\001\001\000\042\004\165\007" + - "\270\022\264\024\201\031\210\047\257\053\200\054\041" + - "\062\111\066\265\071\272\074\156\102\135\116\375\120" + - "\376\122\162\001\001\000\002\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\060\003\u0132\004" + - "\165\007\270\011\u0131\022\264\024\201\031\210\041\u0146" + - "\043\u0147\045\215\047\257\053\200\054\041\060\121\062" + - "\111\066\265\071\272\074\156\102\135\114\u0130\116\375" + - "\120\u0134\122\162\001\001\000\050\004\165\007\270\011" + - "\u0131\022\264\024\201\031\210\047\257\053\200\054\041" + - "\060\u0145\062\111\066\265\071\272\074\156\102\135\114" + - "\u0130\116\375\120\u0134\122\162\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\056\003\u0132\004" + - "\165\007\270\011\u0131\022\264\024\201\031\210\043\u014a" + - "\045\u0149\047\257\053\200\054\041\060\121\062\111\066" + - "\265\071\272\074\156\102\135\114\u0130\116\375\120\u0134" + - "\122\162\001\001\000\002\001\001\000\002\001\001\000" + - "\044\004\165\007\270\022\264\024\201\031\210\047\257" + - "\053\200\054\041\062\111\066\265\071\272\074\156\102" + - "\135\114\u0162\116\375\120\u0134\122\162\001\001\000\044" + - "\004\165\007\270\022\264\024\201\031\210\047\257\053" + - "\200\054\041\062\111\066\265\071\272\074\156\102\135" + - "\114\u0161\116\375\120\u0134\122\162\001\001\000\044\004" + - "\165\007\270\022\264\024\201\031\210\047\257\053\200" + - "\054\041\062\111\066\265\071\272\074\156\102\135\114" + - "\u0160\116\375\120\u0134\122\162\001\001\000\044\004\165" + - "\007\270\022\264\024\201\031\210\047\257\053\200\054" + - "\041\062\111\066\265\071\272\074\156\102\135\114\u015f" + - "\116\375\120\u0134\122\162\001\001\000\044\004\165\007" + - "\270\022\264\024\201\031\210\047\257\053\200\054\041" + - "\062\111\066\265\071\272\074\156\102\135\114\u015e\116" + - "\375\120\u0134\122\162\001\001\000\044\004\165\007\270" + - "\022\264\024\201\031\210\047\257\053\200\054\041\062" + - "\111\066\265\071\272\074\156\102\135\114\u015d\116\375" + - "\120\u0134\122\162\001\001\000\044\004\165\007\270\022" + - "\264\024\201\031\210\047\257\053\200\054\041\062\111" + - "\066\265\071\272\074\156\102\135\114\u015c\116\375\120" + - "\u0134\122\162\001\001\000\044\004\165\007\270\022\264" + - "\024\201\031\210\047\257\053\200\054\041\062\111\066" + - "\265\071\272\074\156\102\135\114\u015b\116\375\120\u0134" + - "\122\162\001\001\000\044\004\165\007\270\022\264\024" + - "\201\031\210\047\257\053\200\054\041\062\111\066\265" + - "\071\272\074\156\102\135\114\u015a\116\375\120\u0134\122" + - "\162\001\001\000\044\004\165\007\270\022\264\024\201" + - "\031\210\047\257\053\200\054\041\062\111\066\265\071" + - "\272\074\156\102\135\114\u0159\116\375\120\u0134\122\162" + - "\001\001\000\044\004\165\007\270\022\264\024\201\031" + - "\210\047\257\053\200\054\041\062\111\066\265\071\272" + - "\074\156\102\135\114\u0158\116\375\120\u0134\122\162\001" + - "\001\000\044\004\165\007\270\022\264\024\201\031\210" + - "\047\257\053\200\054\041\062\111\066\265\071\272\074" + - "\156\102\135\114\u0157\116\375\120\u0134\122\162\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\044\004\174\005\u011a\007" + + "\311\022\305\024\214\031\224\047\300\053\213\054\043" + + "\062\117\066\306\071\313\074\165\102\143\116\u0110\120" + + "\u0119\122\171\001\001\000\044\004\174\005\u0118\007\311" + + "\022\305\024\214\031\224\047\300\053\213\054\043\062" + + "\117\066\306\071\313\074\165\102\143\116\u0110\120\u0117" + + "\122\171\001\001\000\044\004\174\005\u0112\007\311\022" + + "\305\024\214\031\224\047\300\053\213\054\043\062\117" + + "\066\306\071\313\074\165\102\143\116\u0110\120\u0111\122" + + "\171\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\040\004\174\007\311\022\305\024\214\031" + + "\224\047\300\053\213\054\043\062\117\066\306\071\313" + + "\074\165\102\143\116\u0106\122\171\001\001\000\040\004" + + "\174\007\311\022\305\024\214\031\224\047\300\053\213" + + "\054\043\062\117\066\306\071\313\074\165\102\143\116" + + "\u0108\122\171\001\001\000\040\004\174\007\311\022\305" + + "\024\214\031\224\047\300\053\213\054\043\062\117\066" + + "\306\071\313\074\165\102\143\116\u0104\122\171\001\001" + + "\000\040\004\174\007\311\022\305\024\214\031\224\047" + + "\300\053\213\054\043\062\117\066\306\071\313\074\165" + + "\102\143\116\310\122\171\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\006\031\260\034" + + "\u0126\001\001\000\014\014\072\015\u0127\053\067\054\043" + + "\055\071\001\001\000\002\001\001\000\002\001\001\000" + + "\004\054\056\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\052\004\174\005\u0170\007\311\011" + + "\u0136\022\305\024\214\031\224\047\300\053\213\054\043" + + "\060\u016f\062\117\066\306\071\313\074\165\102\143\114" + + "\u0135\116\u0110\120\u0138\122\171\001\001\000\052\004\174" + + "\005\u016e\007\311\011\u0136\022\305\024\214\031\224\047" + + "\300\053\213\054\043\060\u016d\062\117\066\306\071\313" + + "\074\165\102\143\114\u0135\116\u0110\120\u0138\122\171\001" + + "\001\000\052\004\174\005\u016c\007\311\011\u0136\022\305" + + "\024\214\031\224\047\300\053\213\054\043\060\u016b\062" + + "\117\066\306\071\313\074\165\102\143\114\u0135\116\u0110" + + "\120\u0138\122\171\001\001\000\052\004\174\005\u0140\007" + + "\311\011\u0136\022\305\024\214\031\224\047\300\053\213" + + "\054\043\060\u0134\062\117\066\306\071\313\074\165\102" + + "\143\114\u0135\116\u0110\120\u0138\122\171\001\001\000\044" + + "\004\174\007\311\022\305\024\214\031\224\047\300\053" + + "\213\054\043\062\117\066\306\071\313\074\165\102\143" + + "\114\u016a\116\u0110\120\u0138\122\171\001\001\000\044\004" + + "\174\007\311\022\305\024\214\031\224\047\300\053\213" + + "\054\043\062\117\066\306\071\313\074\165\102\143\114" + + "\u0169\116\u0110\120\u0138\122\171\001\001\000\050\004\174" + + "\007\311\011\u0136\022\305\024\214\031\224\047\300\053" + + "\213\054\043\060\u0168\062\117\066\306\071\313\074\165" + + "\102\143\114\u0135\116\u0110\120\u0138\122\171\001\001\000" + + "\050\004\174\007\311\011\u0136\022\305\024\214\031\224" + + "\047\300\053\213\054\043\060\u0167\062\117\066\306\071" + + "\313\074\165\102\143\114\u0135\116\u0110\120\u0138\122\171" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\050\004\174\007\311\011\u0136\022\305\024\214" + + "\031\224\047\300\053\213\054\043\060\u011b\062\117\066" + + "\306\071\313\074\165\102\143\114\u0135\116\u0110\120\u0138" + + "\122\171\001\001\000\002\001\001\000\044\004\174\007" + + "\311\022\305\024\214\031\224\047\300\053\213\054\043" + + "\062\117\066\306\071\313\074\165\102\143\114\u014e\116" + + "\u0110\120\u0138\122\171\001\001\000\044\004\174\007\311" + + "\022\305\024\214\031\224\047\300\053\213\054\043\062" + + "\117\066\306\071\313\074\165\102\143\114\u014d\116\u0110" + + "\120\u0138\122\171\001\001\000\050\004\174\007\311\011" + + "\u0136\022\305\024\214\031\224\047\300\053\213\054\043" + + "\060\u014c\062\117\066\306\071\313\074\165\102\143\114" + + "\u0135\116\u0110\120\u0138\122\171\001\001\000\050\004\174" + + "\007\311\011\u0136\022\305\024\214\031\224\047\300\053" + + "\213\054\043\060\u014b\062\117\066\306\071\313\074\165" + + "\102\143\114\u0135\116\u0110\120\u0138\122\171\001\001\000" + + "\050\004\174\007\311\011\u0136\022\305\024\214\031\224" + + "\047\300\053\213\054\043\060\u014a\062\117\066\306\071" + + "\313\074\165\102\143\114\u0135\116\u0110\120\u0138\122\171" + + "\001\001\000\044\004\174\007\311\022\305\024\214\031" + + "\224\047\300\053\213\054\043\062\117\066\306\071\313" + + "\074\165\102\143\114\u0149\116\u0110\120\u0138\122\171\001" + + "\001\000\044\004\174\007\311\022\305\024\214\031\224" + + "\047\300\053\213\054\043\062\117\066\306\071\313\074" + + "\165\102\143\114\u0148\116\u0110\120\u0138\122\171\001\001" + + "\000\002\001\001\000\044\004\174\007\311\022\305\024" + + "\214\031\224\047\300\053\213\054\043\062\117\066\306" + + "\071\313\074\165\102\143\114\u0144\116\u0110\120\u0138\122" + + "\171\001\001\000\050\004\174\007\311\011\u0136\022\305" + + "\024\214\031\224\047\300\053\213\054\043\060\u0143\062" + + "\117\066\306\071\313\074\165\102\143\114\u0135\116\u0110" + + "\120\u0138\122\171\001\001\000\002\001\001\000\002\001" + + "\001\000\042\004\174\007\311\022\305\024\214\031\224" + + "\047\300\053\213\054\043\062\117\066\306\071\313\074" + + "\165\102\143\116\u0110\120\u0119\122\171\001\001\000\042" + + "\004\174\007\311\022\305\024\214\031\224\047\300\053" + + "\213\054\043\062\117\066\306\071\313\074\165\102\143" + + "\116\u0110\120\u0117\122\171\001\001\000\042\004\174\007" + + "\311\022\305\024\214\031\224\047\300\053\213\054\043" + + "\062\117\066\306\071\313\074\165\102\143\116\u0110\120" + + "\u0111\122\171\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\006" + - "\031\243\034\u016b\001\001\000\002\001\001\000\144\002" + - "\106\003\105\004\165\005\104\006\132\007\131\010\142" + - "\011\141\021\110\022\107\023\202\024\201\025\155\026" + - "\154\030\225\031\210\035\u016d\036\227\040\103\041\102" + - "\042\206\043\205\044\216\045\215\046\174\047\172\053" + - "\200\054\041\057\122\060\121\061\113\062\111\063\145" + - "\064\144\065\116\066\114\070\130\071\127\073\157\074" + - "\156\102\135\113\140\114\137\115\171\116\167\117\213" + - "\120\212\121\163\122\162\001\001\000\002\001\001\000" + - "\002\001\001\000\064\003\u0132\004\165\005\u0171\007\270" + - "\011\u0131\022\264\024\201\026\u0170\031\210\041\102\043" + - "\205\045\215\047\257\053\200\054\041\060\121\062\111" + - "\066\265\071\272\074\156\102\135\114\u0130\116\375\120" + - "\u0134\122\162\001\001\000\002\001\001\000\002\001\001" + - "\000\060\003\u0132\004\165\007\270\011\u0131\022\264\024" + - "\201\031\210\041\u0133\043\205\045\215\047\257\053\200" + - "\054\041\060\121\062\111\066\265\071\272\074\156\102" + - "\135\114\u0130\116\375\120\u0134\122\162\001\001\000\074" + - "\004\165\006\132\007\131\021\110\022\107\023\202\024" + - "\201\031\210\046\174\047\172\053\200\054\041\061\113" + - "\062\111\065\116\066\114\070\130\071\127\073\157\074" + - "\156\102\135\113\u0196\114\u0195\115\171\116\167\117\213" + - "\120\212\121\163\122\162\001\001\000\074\004\165\006" + - "\132\007\131\021\110\022\107\023\202\024\201\031\210" + - "\046\174\047\172\053\200\054\041\061\113\062\111\065" + - "\116\066\114\070\130\071\127\073\157\074\156\102\135" + - "\113\u0194\114\u0193\115\171\116\167\117\213\120\212\121" + - "\163\122\162\001\001\000\074\004\165\006\132\007\131" + - "\021\110\022\107\023\202\024\201\031\210\046\174\047" + - "\172\053\200\054\041\061\113\062\111\065\116\066\114" + - "\070\130\071\127\073\157\074\156\102\135\113\u0192\114" + - "\u0191\115\171\116\167\117\213\120\212\121\163\122\162" + - "\001\001\000\074\004\165\006\132\007\131\021\110\022" + - "\107\023\202\024\201\031\210\046\174\047\172\053\200" + - "\054\041\061\113\062\111\065\116\066\114\070\130\071" + - "\127\073\157\074\156\102\135\113\u0190\114\u018f\115\171" + - "\116\167\117\213\120\212\121\163\122\162\001\001\000" + - "\074\004\165\006\132\007\131\021\110\022\107\023\202" + - "\024\201\031\210\046\174\047\172\053\200\054\041\061" + - "\113\062\111\065\116\066\114\070\130\071\127\073\157" + - "\074\156\102\135\113\u018e\114\u018d\115\171\116\167\117" + - "\213\120\212\121\163\122\162\001\001\000\074\004\165" + - "\006\132\007\131\021\110\022\107\023\202\024\201\031" + - "\210\046\174\047\172\053\200\054\041\061\113\062\111" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\u018c\114\u018b\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\074\004\165\006\132\007" + - "\131\021\110\022\107\023\202\024\201\031\210\046\174" + - "\047\172\053\200\054\041\061\113\062\111\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\u018a" + - "\114\u0189\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\074\004\165\006\132\007\131\021\110" + - "\022\107\023\202\024\201\031\210\046\174\047\172\053" + - "\200\054\041\061\113\062\111\065\116\066\114\070\130" + - "\071\127\073\157\074\156\102\135\113\u0188\114\u0187\115" + - "\171\116\167\117\213\120\212\121\163\122\162\001\001" + - "\000\074\004\165\006\132\007\131\021\110\022\107\023" + - "\202\024\201\031\210\046\174\047\172\053\200\054\041" + - "\061\113\062\111\065\116\066\114\070\130\071\127\073" + - "\157\074\156\102\135\113\u0186\114\u0185\115\171\116\167" + - "\117\213\120\212\121\163\122\162\001\001\000\074\004" + - "\165\006\132\007\131\021\110\022\107\023\202\024\201" + - "\031\210\046\174\047\172\053\200\054\041\061\113\062" + - "\111\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\u0184\114\u0183\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\074\004\165\006\132" + - "\007\131\021\110\022\107\023\202\024\201\031\210\046" + - "\174\047\172\053\200\054\041\061\113\062\111\065\116" + - "\066\114\070\130\071\127\073\157\074\156\102\135\113" + - "\u0182\114\u0181\115\171\116\167\117\213\120\212\121\163" + - "\122\162\001\001\000\074\004\165\006\132\007\131\021" + - "\110\022\107\023\202\024\201\031\210\046\174\047\172" + - "\053\200\054\041\061\113\062\111\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\u0180\114\u017f" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + + "\002\001\001\000\002\001\001\000\044\004\174\007\311" + + "\022\305\024\214\031\224\047\300\053\213\054\043\062" + + "\117\066\306\071\313\074\165\102\143\114\u0166\116\u0110" + + "\120\u0138\122\171\001\001\000\044\004\174\007\311\022" + + "\305\024\214\031\224\047\300\053\213\054\043\062\117" + + "\066\306\071\313\074\165\102\143\114\u0165\116\u0110\120" + + "\u0138\122\171\001\001\000\044\004\174\007\311\022\305" + + "\024\214\031\224\047\300\053\213\054\043\062\117\066" + + "\306\071\313\074\165\102\143\114\u0164\116\u0110\120\u0138" + + "\122\171\001\001\000\044\004\174\007\311\022\305\024" + + "\214\031\224\047\300\053\213\054\043\062\117\066\306" + + "\071\313\074\165\102\143\114\u0163\116\u0110\120\u0138\122" + + "\171\001\001\000\044\004\174\007\311\022\305\024\214" + + "\031\224\047\300\053\213\054\043\062\117\066\306\071" + + "\313\074\165\102\143\114\u0162\116\u0110\120\u0138\122\171" + + "\001\001\000\044\004\174\007\311\022\305\024\214\031" + + "\224\047\300\053\213\054\043\062\117\066\306\071\313" + + "\074\165\102\143\114\u0161\116\u0110\120\u0138\122\171\001" + + "\001\000\044\004\174\007\311\022\305\024\214\031\224" + + "\047\300\053\213\054\043\062\117\066\306\071\313\074" + + "\165\102\143\114\u0160\116\u0110\120\u0138\122\171\001\001" + + "\000\044\004\174\007\311\022\305\024\214\031\224\047" + + "\300\053\213\054\043\062\117\066\306\071\313\074\165" + + "\102\143\114\u015f\116\u0110\120\u0138\122\171\001\001\000" + + "\044\004\174\007\311\022\305\024\214\031\224\047\300" + + "\053\213\054\043\062\117\066\306\071\313\074\165\102" + + "\143\114\u015e\116\u0110\120\u0138\122\171\001\001\000\044" + + "\004\174\007\311\022\305\024\214\031\224\047\300\053" + + "\213\054\043\062\117\066\306\071\313\074\165\102\143" + + "\114\u015d\116\u0110\120\u0138\122\171\001\001\000\044\004" + + "\174\007\311\022\305\024\214\031\224\047\300\053\213" + + "\054\043\062\117\066\306\071\313\074\165\102\143\114" + + "\u015c\116\u0110\120\u0138\122\171\001\001\000\044\004\174" + + "\007\311\022\305\024\214\031\224\047\300\053\213\054" + + "\043\062\117\066\306\071\313\074\165\102\143\114\u015b" + + "\116\u0110\120\u0138\122\171\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\006\031\260\034\u0174\001\001\000\002\001\001\000" + + "\006\031\260\034\u0176\001\001\000\002\001\001\000\032" + + "\004\174\005\u0178\007\311\022\305\024\214\031\224\053" + + "\213\054\043\071\313\074\354\102\143\122\171\001\001" + + "\000\002\001\001\000\146\002\114\003\113\004\174\005" + + "\112\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\025\164\026\163\030\u017a\031\224\040" + + "\110\041\107\042\221\043\220\044\232\045\231\046\205" + + "\047\203\053\213\054\043\057\106\060\105\061\120\062" + + "\117\063\154\064\153\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\146\114\145\115\200\116" + + "\176\117\227\120\226\121\172\122\171\124\211\125\210" + + "\126\202\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\004\054\u017e\001\001\000\002\001\001" + + "\000\040\004\174\005\u0184\007\311\022\305\024\214\031" + + "\224\047\300\053\213\054\043\062\347\066\306\071\313" + + "\074\165\102\143\122\171\001\001\000\040\004\174\005" + + "\u0183\007\311\022\305\024\214\031\224\047\300\053\213" + + "\054\043\062\345\066\306\071\313\074\165\102\143\122" + + "\171\001\001\000\040\004\174\005\u0182\007\311\022\305" + + "\024\214\031\224\047\300\053\213\054\043\062\346\066" + + "\306\071\313\074\165\102\143\122\171\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\006\031\260\034\u018b\001\001\000" + + "\002\001\001\000\064\003\u018d\004\174\005\u0190\007\311" + + "\011\u0136\022\305\024\214\031\224\041\u018e\043\220\045" + + "\231\047\300\053\213\054\043\060\105\062\117\066\306" + + "\071\313\074\165\102\143\114\u0135\116\u0110\120\u0138\122" + + "\171\125\u018f\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\050\004\174\007" + + "\311\011\u0136\022\305\024\214\031\224\047\300\053\213" + + "\054\043\060\u016f\062\117\066\306\071\313\074\165\102" + + "\143\114\u0135\116\u0110\120\u0138\122\171\001\001\000\050" + + "\004\174\007\311\011\u0136\022\305\024\214\031\224\047" + + "\300\053\213\054\043\060\u016d\062\117\066\306\071\313" + + "\074\165\102\143\114\u0135\116\u0110\120\u0138\122\171\001" + + "\001\000\050\004\174\007\311\011\u0136\022\305\024\214" + + "\031\224\047\300\053\213\054\043\060\u0134\062\117\066" + + "\306\071\313\074\165\102\143\114\u0135\116\u0110\120\u0138" + + "\122\171\001\001\000\050\004\174\007\311\011\u0136\022" + + "\305\024\214\031\224\047\300\053\213\054\043\060\u016b" + + "\062\117\066\306\071\313\074\165\102\143\114\u0135\116" + + "\u0110\120\u0138\122\171\001\001\000\062\003\u018d\004\174" + + "\007\311\011\u0136\022\305\024\214\031\224\041\u0198\043" + + "\u0199\045\231\047\300\053\213\054\043\060\105\062\117" + + "\066\306\071\313\074\165\102\143\114\u0135\116\u0110\120" + + "\u0138\122\171\125\u018f\001\001\000\052\004\174\007\311" + + "\011\u0136\022\305\024\214\031\224\047\300\053\213\054" + + "\043\060\105\062\117\066\306\071\313\074\165\102\143" + + "\114\u0135\116\u0110\120\u0138\122\171\125\u0197\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\060" + + "\003\u018d\004\174\007\311\011\u0136\022\305\024\214\031" + + "\224\043\u019c\045\u019b\047\300\053\213\054\043\060\105" + + "\062\117\066\306\071\313\074\165\102\143\114\u0135\116" + + "\u0110\120\u0138\122\171\125\u018f\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\006\031\260\034\u01a2" + + "\001\001\000\002\001\001\000\152\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\242\031" + + "\224\035\u01a4\036\244\040\110\041\107\042\221\043\220" + + "\044\232\045\231\046\205\047\203\053\213\054\043\057" + + "\106\060\105\061\120\062\117\063\154\064\153\065\124" + + "\066\122\070\135\071\134\073\166\074\165\102\143\113" + + "\146\114\145\115\200\116\176\117\227\120\226\121\172" + + "\122\171\124\211\125\210\126\202\001\001\000\002\001" + + "\001\000\002\001\001\000\066\003\u018d\004\174\005\u01a8" + + "\007\311\011\u0136\022\305\024\214\026\u01a7\031\224\041" + + "\107\043\220\045\231\047\300\053\213\054\043\060\105" + + "\062\117\066\306\071\313\074\165\102\143\114\u0135\116" + + "\u0110\120\u0138\122\171\125\u018f\001\001\000\002\001\001" + + "\000\002\001\001\000\062\003\u018d\004\174\007\311\011" + + "\u0136\022\305\024\214\031\224\041\u018e\043\220\045\231" + + "\047\300\053\213\054\043\060\105\062\117\066\306\071" + + "\313\074\165\102\143\114\u0135\116\u0110\120\u0138\122\171" + + "\125\u018f\001\001\000\076\004\174\005\u010c\006\137\007" + + "\136\021\116\022\115\023\215\024\214\031\224\046\205" + + "\047\203\053\213\054\043\061\120\062\117\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\u01cd" + + "\114\u01cc\115\200\116\176\117\227\120\226\121\172\122" + + "\171\001\001\000\076\004\174\005\u010c\006\137\007\136" + + "\021\116\022\115\023\215\024\214\031\224\046\205\047" + + "\203\053\213\054\043\061\120\062\117\065\124\066\122" + + "\070\135\071\134\073\166\074\165\102\143\113\u01cb\114" + + "\u01ca\115\200\116\176\117\227\120\226\121\172\122\171" + + "\001\001\000\076\004\174\005\u010c\006\137\007\136\021" + + "\116\022\115\023\215\024\214\031\224\046\205\047\203" + + "\053\213\054\043\061\120\062\117\065\124\066\122\070" + + "\135\071\134\073\166\074\165\102\143\113\u01c9\114\u01c8" + + "\115\200\116\176\117\227\120\226\121\172\122\171\001" + + "\001\000\076\004\174\005\u010c\006\137\007\136\021\116" + + "\022\115\023\215\024\214\031\224\046\205\047\203\053" + + "\213\054\043\061\120\062\117\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\u01c7\114\u01c6\115" + + "\200\116\176\117\227\120\226\121\172\122\171\001\001" + + "\000\076\004\174\005\u010c\006\137\007\136\021\116\022" + + "\115\023\215\024\214\031\224\046\205\047\203\053\213" + + "\054\043\061\120\062\117\065\124\066\122\070\135\071" + + "\134\073\166\074\165\102\143\113\u01c5\114\u01c4\115\200" + + "\116\176\117\227\120\226\121\172\122\171\001\001\000" + + "\076\004\174\005\u010c\006\137\007\136\021\116\022\115" + + "\023\215\024\214\031\224\046\205\047\203\053\213\054" + + "\043\061\120\062\117\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\u01c3\114\u01c2\115\200\116" + + "\176\117\227\120\226\121\172\122\171\001\001\000\076" + + "\004\174\005\u010c\006\137\007\136\021\116\022\115\023" + + "\215\024\214\031\224\046\205\047\203\053\213\054\043" + + "\061\120\062\117\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\u01c1\114\u01c0\115\200\116\176" + + "\117\227\120\226\121\172\122\171\001\001\000\076\004" + + "\174\005\u010c\006\137\007\136\021\116\022\115\023\215" + + "\024\214\031\224\046\205\047\203\053\213\054\043\061" + + "\120\062\117\065\124\066\122\070\135\071\134\073\166" + + "\074\165\102\143\113\u01bf\114\u01be\115\200\116\176\117" + + "\227\120\226\121\172\122\171\001\001\000\076\004\174" + + "\005\u010c\006\137\007\136\021\116\022\115\023\215\024" + + "\214\031\224\046\205\047\203\053\213\054\043\061\120" + + "\062\117\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\u01bd\114\u01bc\115\200\116\176\117\227" + + "\120\226\121\172\122\171\001\001\000\076\004\174\005" + + "\u010c\006\137\007\136\021\116\022\115\023\215\024\214" + + "\031\224\046\205\047\203\053\213\054\043\061\120\062" + + "\117\065\124\066\122\070\135\071\134\073\166\074\165" + + "\102\143\113\u01bb\114\u01ba\115\200\116\176\117\227\120" + + "\226\121\172\122\171\001\001\000\076\004\174\005\u010c" + + "\006\137\007\136\021\116\022\115\023\215\024\214\031" + + "\224\046\205\047\203\053\213\054\043\061\120\062\117" + + "\065\124\066\122\070\135\071\134\073\166\074\165\102" + + "\143\113\u01b9\114\u01b8\115\200\116\176\117\227\120\226" + + "\121\172\122\171\001\001\000\076\004\174\005\u010c\006" + + "\137\007\136\021\116\022\115\023\215\024\214\031\224" + + "\046\205\047\203\053\213\054\043\061\120\062\117\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\u01b7\114\u01b6\115\200\116\176\117\227\120\226\121" + + "\172\122\171\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\002\001\001\000\020\004\165" + - "\005\u019c\031\210\053\200\054\041\102\135\122\306\001" + - "\001\000\002\001\001\000\024\004\165\005\u019e\007\277" + - "\024\201\031\210\053\200\054\041\102\135\122\162\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\010\053\066\054\041\055\u01c4\001\001\000\010\053" + - "\066\054\041\055\u01bf\001\001\000\002\001\001\000\006" + - "\031\243\034\u01b6\001\001\000\010\053\066\054\041\055" + - "\u01b0\001\001\000\002\001\001\000\002\001\001\000\010" + - "\053\066\054\041\055\u01aa\001\001\000\010\053\066\054" + - "\041\055\u01ab\001\001\000\002\001\001\000\002\001\001" + - "\000\140\002\106\003\105\004\165\005\104\006\132\007" + - "\131\010\142\011\141\021\110\022\107\023\202\024\201" + - "\025\155\026\154\030\u01ad\031\210\040\103\041\102\042" + - "\206\043\205\044\216\045\215\046\174\047\172\053\200" + - "\054\041\057\122\060\121\061\113\062\111\063\145\064" + - "\144\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\140\114\137\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\002\001\001\000\140" + - "\002\106\003\105\004\165\005\104\006\132\007\131\010" + - "\142\011\141\021\110\022\107\023\202\024\201\025\155" + - "\026\154\030\u01af\031\210\040\103\041\102\042\206\043" + - "\205\044\216\045\215\046\174\047\172\053\200\054\041" + - "\057\122\060\121\061\113\062\111\063\145\064\144\065" + - "\116\066\114\070\130\071\127\073\157\074\156\102\135" + - "\113\140\114\137\115\171\116\167\117\213\120\212\121" + - "\163\122\162\001\001\000\002\001\001\000\002\001\001" + - "\000\140\002\106\003\105\004\165\005\104\006\132\007" + - "\131\010\142\011\141\021\110\022\107\023\202\024\201" + - "\025\155\026\154\030\u01b2\031\210\040\103\041\102\042" + - "\206\043\205\044\216\045\215\046\174\047\172\053\200" + - "\054\041\057\122\060\121\061\113\062\111\063\145\064" + - "\144\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\140\114\137\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\002\001\001\000\140" + - "\002\106\003\105\004\165\005\104\006\132\007\131\010" + - "\142\011\141\021\110\022\107\023\202\024\201\025\155" + - "\026\154\030\u01b4\031\210\040\103\041\102\042\206\043" + - "\205\044\216\045\215\046\174\047\172\053\200\054\041" + - "\057\122\060\121\061\113\062\111\063\145\064\144\065" + - "\116\066\114\070\130\071\127\073\157\074\156\102\135" + - "\113\140\114\137\115\171\116\167\117\213\120\212\121" + - "\163\122\162\001\001\000\002\001\001\000\012\014\u01ba" + - "\053\066\054\041\055\u01a3\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\010\053\066\054\041" + - "\055\u01b0\001\001\000\002\001\001\000\140\002\106\003" + - "\105\004\165\005\104\006\132\007\131\010\142\011\141" + - "\021\110\022\107\023\202\024\201\025\155\026\154\030" + - "\u01bc\031\210\040\103\041\102\042\206\043\205\044\216" + - "\045\215\046\174\047\172\053\200\054\041\057\122\060" + - "\121\061\113\062\111\063\145\064\144\065\116\066\114" + - "\070\130\071\127\073\157\074\156\102\135\113\140\114" + - "\137\115\171\116\167\117\213\120\212\121\163\122\162" + - "\001\001\000\002\001\001\000\140\002\106\003\105\004" + - "\165\005\104\006\132\007\131\010\142\011\141\021\110" + - "\022\107\023\202\024\201\025\155\026\154\030\u01be\031" + - "\210\040\103\041\102\042\206\043\205\044\216\045\215" + - "\046\174\047\172\053\200\054\041\057\122\060\121\061" + - "\113\062\111\063\145\064\144\065\116\066\114\070\130" + - "\071\127\073\157\074\156\102\135\113\140\114\137\115" + - "\171\116\167\117\213\120\212\121\163\122\162\001\001" + - "\000\002\001\001\000\002\001\001\000\140\002\106\003" + - "\105\004\165\005\104\006\132\007\131\010\142\011\141" + - "\021\110\022\107\023\202\024\201\025\155\026\154\030" + - "\u01c1\031\210\040\103\041\102\042\206\043\205\044\216" + - "\045\215\046\174\047\172\053\200\054\041\057\122\060" + - "\121\061\113\062\111\063\145\064\144\065\116\066\114" + - "\070\130\071\127\073\157\074\156\102\135\113\140\114" + - "\137\115\171\116\167\117\213\120\212\121\163\122\162" + - "\001\001\000\002\001\001\000\140\002\106\003\105\004" + - "\165\005\104\006\132\007\131\010\142\011\141\021\110" + - "\022\107\023\202\024\201\025\155\026\154\030\u01c3\031" + - "\210\040\103\041\102\042\206\043\205\044\216\045\215" + - "\046\174\047\172\053\200\054\041\057\122\060\121\061" + - "\113\062\111\063\145\064\144\065\116\066\114\070\130" + - "\071\127\073\157\074\156\102\135\113\140\114\137\115" + - "\171\116\167\117\213\120\212\121\163\122\162\001\001" + - "\000\002\001\001\000\002\001\001\000\140\002\106\003" + - "\105\004\165\005\104\006\132\007\131\010\142\011\141" + - "\021\110\022\107\023\202\024\201\025\155\026\154\030" + - "\u01c6\031\210\040\103\041\102\042\206\043\205\044\216" + - "\045\215\046\174\047\172\053\200\054\041\057\122\060" + - "\121\061\113\062\111\063\145\064\144\065\116\066\114" + - "\070\130\071\127\073\157\074\156\102\135\113\140\114" + - "\137\115\171\116\167\117\213\120\212\121\163\122\162" + - "\001\001\000\002\001\001\000\140\002\106\003\105\004" + - "\165\005\104\006\132\007\131\010\142\011\141\021\110" + - "\022\107\023\202\024\201\025\155\026\154\030\u01c8\031" + - "\210\040\103\041\102\042\206\043\205\044\216\045\215" + - "\046\174\047\172\053\200\054\041\057\122\060\121\061" + - "\113\062\111\063\145\064\144\065\116\066\114\070\130" + - "\071\127\073\157\074\156\102\135\113\140\114\137\115" + - "\171\116\167\117\213\120\212\121\163\122\162\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\034\004\165\005\u01ce" + - "\007\270\022\264\024\201\031\210\047\330\053\200\054" + - "\041\071\272\074\156\102\135\122\162\001\001\000\002" + - "\001\001\000\006\031\243\034\u01d0\001\001\000\002\001" + - "\001\000\026\004\165\005\u01d4\007\270\024\201\031\210" + - "\053\200\054\041\071\356\102\135\122\162\001\001\000" + - "\032\004\165\005\u01d3\007\270\022\264\024\201\031\210" + - "\053\200\054\041\071\272\074\355\102\135\122\162\001" + - "\001\000\002\001\001\000\002\001\001\000\126\002\106" + - "\003\105\004\165\005\u01d9\006\132\007\131\010\142\011" + - "\141\021\110\022\107\023\202\024\201\031\210\040\u01d8" + - "\041\u0146\042\206\043\u01da\044\216\045\215\046\174\047" + - "\172\053\200\054\041\057\122\060\121\061\113\062\111" + - "\065\116\066\114\070\130\071\127\073\157\074\156\102" + - "\135\113\140\114\137\115\171\116\167\117\213\120\212" + - "\121\163\122\162\001\001\000\052\004\165\005\u01d7\007" + - "\270\011\u0131\022\264\024\201\031\210\047\257\053\200" + - "\054\041\060\u0145\062\111\066\265\071\272\074\156\102" + - "\135\114\u0130\116\375\120\u0134\122\162\001\001\000\002" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\122\002\106\003\105\004\165\005\u01dc\006\132" + - "\007\131\010\142\011\141\021\110\022\107\023\202\024" + - "\201\031\210\042\u01dd\043\u014a\044\u01de\045\u0149\046\174" + - "\047\172\053\200\054\041\057\122\060\121\061\113\062" + - "\111\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\140\114\137\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\002\001\001\000\002" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\020\004\174\005\u01d7\031\224\053\213" + + "\054\043\102\143\122\327\001\001\000\002\001\001\000" + + "\024\004\174\005\u01d9\007\320\024\214\031\224\053\213" + + "\054\043\102\143\122\171\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\010\053\067\054\043" + + "\055\u01ff\001\001\000\010\053\067\054\043\055\u01fa\001" + + "\001\000\002\001\001\000\006\031\260\034\u01f1\001\001" + + "\000\010\053\067\054\043\055\u01eb\001\001\000\002\001" + + "\001\000\002\001\001\000\010\053\067\054\043\055\u01e5" + + "\001\001\000\010\053\067\054\043\055\u01e6\001\001\000" + + "\002\001\001\000\002\001\001\000\146\002\114\003\113" + + "\004\174\005\112\006\137\007\136\010\151\011\150\021" + + "\116\022\115\023\215\024\214\025\164\026\163\030\u01e8" + + "\031\224\040\110\041\107\042\221\043\220\044\232\045" + + "\231\046\205\047\203\053\213\054\043\057\106\060\105" + + "\061\120\062\117\063\154\064\153\065\124\066\122\070" + + "\135\071\134\073\166\074\165\102\143\113\146\114\145" + + "\115\200\116\176\117\227\120\226\121\172\122\171\124" + + "\211\125\210\126\202\001\001\000\002\001\001\000\146" + + "\002\114\003\113\004\174\005\112\006\137\007\136\010" + + "\151\011\150\021\116\022\115\023\215\024\214\025\164" + + "\026\163\030\u01ea\031\224\040\110\041\107\042\221\043" + + "\220\044\232\045\231\046\205\047\203\053\213\054\043" + + "\057\106\060\105\061\120\062\117\063\154\064\153\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\146\114\145\115\200\116\176\117\227\120\226\121" + + "\172\122\171\124\211\125\210\126\202\001\001\000\002" + + "\001\001\000\002\001\001\000\146\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\u01ed\031" + + "\224\040\110\041\107\042\221\043\220\044\232\045\231" + + "\046\205\047\203\053\213\054\043\057\106\060\105\061" + + "\120\062\117\063\154\064\153\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\124\211" + + "\125\210\126\202\001\001\000\002\001\001\000\146\002" + + "\114\003\113\004\174\005\112\006\137\007\136\010\151" + + "\011\150\021\116\022\115\023\215\024\214\025\164\026" + + "\163\030\u01ef\031\224\040\110\041\107\042\221\043\220" + + "\044\232\045\231\046\205\047\203\053\213\054\043\057" + + "\106\060\105\061\120\062\117\063\154\064\153\065\124" + + "\066\122\070\135\071\134\073\166\074\165\102\143\113" + + "\146\114\145\115\200\116\176\117\227\120\226\121\172" + + "\122\171\124\211\125\210\126\202\001\001\000\002\001" + + "\001\000\012\014\u01f5\053\067\054\043\055\u01de\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\010\053\067\054\043\055\u01eb\001\001\000\002\001\001" + + "\000\146\002\114\003\113\004\174\005\112\006\137\007" + + "\136\010\151\011\150\021\116\022\115\023\215\024\214" + + "\025\164\026\163\030\u01f7\031\224\040\110\041\107\042" + + "\221\043\220\044\232\045\231\046\205\047\203\053\213" + + "\054\043\057\106\060\105\061\120\062\117\063\154\064" + + "\153\065\124\066\122\070\135\071\134\073\166\074\165" + + "\102\143\113\146\114\145\115\200\116\176\117\227\120" + + "\226\121\172\122\171\124\211\125\210\126\202\001\001" + + "\000\002\001\001\000\146\002\114\003\113\004\174\005" + + "\112\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\025\164\026\163\030\u01f9\031\224\040" + + "\110\041\107\042\221\043\220\044\232\045\231\046\205" + + "\047\203\053\213\054\043\057\106\060\105\061\120\062" + + "\117\063\154\064\153\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\146\114\145\115\200\116" + + "\176\117\227\120\226\121\172\122\171\124\211\125\210" + + "\126\202\001\001\000\002\001\001\000\002\001\001\000" + + "\146\002\114\003\113\004\174\005\112\006\137\007\136" + + "\010\151\011\150\021\116\022\115\023\215\024\214\025" + + "\164\026\163\030\u01fc\031\224\040\110\041\107\042\221" + + "\043\220\044\232\045\231\046\205\047\203\053\213\054" + + "\043\057\106\060\105\061\120\062\117\063\154\064\153" + + "\065\124\066\122\070\135\071\134\073\166\074\165\102" + + "\143\113\146\114\145\115\200\116\176\117\227\120\226" + + "\121\172\122\171\124\211\125\210\126\202\001\001\000" + + "\002\001\001\000\146\002\114\003\113\004\174\005\112" + + "\006\137\007\136\010\151\011\150\021\116\022\115\023" + + "\215\024\214\025\164\026\163\030\u01fe\031\224\040\110" + + "\041\107\042\221\043\220\044\232\045\231\046\205\047" + + "\203\053\213\054\043\057\106\060\105\061\120\062\117" + + "\063\154\064\153\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\146\114\145\115\200\116\176" + + "\117\227\120\226\121\172\122\171\124\211\125\210\126" + + "\202\001\001\000\002\001\001\000\002\001\001\000\146" + + "\002\114\003\113\004\174\005\112\006\137\007\136\010" + + "\151\011\150\021\116\022\115\023\215\024\214\025\164" + + "\026\163\030\u0201\031\224\040\110\041\107\042\221\043" + + "\220\044\232\045\231\046\205\047\203\053\213\054\043" + + "\057\106\060\105\061\120\062\117\063\154\064\153\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\146\114\145\115\200\116\176\117\227\120\226\121" + + "\172\122\171\124\211\125\210\126\202\001\001\000\002" + + "\001\001\000\146\002\114\003\113\004\174\005\112\006" + + "\137\007\136\010\151\011\150\021\116\022\115\023\215" + + "\024\214\025\164\026\163\030\u0203\031\224\040\110\041" + + "\107\042\221\043\220\044\232\045\231\046\205\047\203" + + "\053\213\054\043\057\106\060\105\061\120\062\117\063" + + "\154\064\153\065\124\066\122\070\135\071\134\073\166" + + "\074\165\102\143\113\146\114\145\115\200\116\176\117" + + "\227\120\226\121\172\122\171\124\211\125\210\126\202" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + - "\001\000\140\002\106\003\105\004\165\005\104\006\132" + - "\007\131\010\142\011\141\021\110\022\107\023\202\024" + - "\201\025\155\026\154\030\u01e2\031\210\040\103\041\102" + - "\042\206\043\205\044\216\045\215\046\174\047\172\053" + - "\200\054\041\057\122\060\121\061\113\062\111\063\145" + - "\064\144\065\116\066\114\070\130\071\127\073\157\074" + - "\156\102\135\113\140\114\137\115\171\116\167\117\213" + - "\120\212\121\163\122\162\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\u01e6" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\002\001\001\000\140\002\106\003\105\004\165" + - "\005\104\006\132\007\131\010\142\011\141\021\110\022" + - "\107\023\202\024\201\025\155\026\154\030\u01e8\031\210" + - "\040\103\041\102\042\206\043\205\044\216\045\215\046" + - "\174\047\172\053\200\054\041\057\122\060\121\061\113" + - "\062\111\063\145\064\144\065\116\066\114\070\130\071" + - "\127\073\157\074\156\102\135\113\140\114\137\115\171" + - "\116\167\117\213\120\212\121\163\122\162\001\001\000" + - "\002\001\001\000\002\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\u01eb" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\004\031\u01ec\001\001\000\002\001\001\000\002" + - "\001\001\000\140\002\106\003\105\004\165\005\104\006" + - "\132\007\131\010\142\011\141\021\110\022\107\023\202" + - "\024\201\025\155\026\154\030\u01ef\031\210\040\103\041" + - "\102\042\206\043\205\044\216\045\215\046\174\047\172" + - "\053\200\054\041\057\122\060\121\061\113\062\111\063" + - "\145\064\144\065\116\066\114\070\130\071\127\073\157" + - "\074\156\102\135\113\140\114\137\115\171\116\167\117" + - "\213\120\212\121\163\122\162\001\001\000\002\001\001" + - "\000\140\002\106\003\105\004\165\005\104\006\132\007" + - "\131\010\142\011\141\021\110\022\107\023\202\024\201" + - "\025\155\026\154\030\u01f1\031\210\040\103\041\102\042" + - "\206\043\205\044\216\045\215\046\174\047\172\053\200" + - "\054\041\057\122\060\121\061\113\062\111\063\145\064" + - "\144\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\140\114\137\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\002\001\001\000\016" + - "\014\070\015\065\017\u01f3\053\066\054\041\055\067\001" + - "\001\000\002\001\001\000\002\001\001\000\140\002\106" + - "\003\105\004\165\005\104\006\132\007\131\010\142\011" + - "\141\021\110\022\107\023\202\024\201\025\155\026\154" + - "\030\u01f6\031\210\040\103\041\102\042\206\043\205\044" + - "\216\045\215\046\174\047\172\053\200\054\041\057\122" + - "\060\121\061\113\062\111\063\145\064\144\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\140" + - "\114\137\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\002\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\u01f8" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\002\001\001\000\002\001\001\000\140\002\106" + - "\003\105\004\165\005\104\006\132\007\131\010\142\011" + - "\141\021\110\022\107\023\202\024\201\025\155\026\154" + - "\030\u01fb\031\210\040\103\041\102\042\206\043\205\044" + - "\216\045\215\046\174\047\172\053\200\054\041\057\122" + - "\060\121\061\113\062\111\063\145\064\144\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\140" + - "\114\137\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\002\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\u01fd" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\002\001\001\000\002\001\001\000\140\002\106" + - "\003\105\004\165\005\104\006\132\007\131\010\142\011" + - "\141\021\110\022\107\023\202\024\201\025\155\026\154" + - "\030\u0200\031\210\040\103\041\102\042\206\043\205\044" + - "\216\045\215\046\174\047\172\053\200\054\041\057\122" + - "\060\121\061\113\062\111\063\145\064\144\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\140" + - "\114\137\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\002\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\u0202" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "\000\140\002\106\003\105\004\165\005\104\006\132\007" + - "\131\010\142\011\141\021\110\022\107\023\202\024\201" + - "\025\155\026\154\030\u0206\031\210\040\103\041\102\042" + - "\206\043\205\044\216\045\215\046\174\047\172\053\200" + - "\054\041\057\122\060\121\061\113\062\111\063\145\064" + - "\144\065\116\066\114\070\130\071\127\073\157\074\156" + - "\102\135\113\140\114\137\115\171\116\167\117\213\120" + - "\212\121\163\122\162\001\001\000\004\031\u0207\001\001" + - "\000\002\001\001\000\004\031\u0209\001\001\000\002\001" + - "\001\000\140\002\106\003\105\004\165\005\104\006\132" + - "\007\131\010\142\011\141\021\110\022\107\023\202\024" + - "\201\025\155\026\154\030\u0217\031\210\040\103\041\102" + - "\042\206\043\205\044\216\045\215\046\174\047\172\053" + - "\200\054\041\057\122\060\121\061\113\062\111\063\145" + - "\064\144\065\116\066\114\070\130\071\127\073\157\074" + - "\156\102\135\113\140\114\137\115\171\116\167\117\213" + - "\120\212\121\163\122\162\001\001\000\016\014\070\015" + - "\065\017\u0212\053\066\054\041\055\067\001\001\000\016" + - "\014\070\015\065\017\u020d\053\066\054\041\055\067\001" + - "\001\000\002\001\001\000\002\001\001\000\140\002\106" + - "\003\105\004\165\005\104\006\132\007\131\010\142\011" + - "\141\021\110\022\107\023\202\024\201\025\155\026\154" + - "\030\u0210\031\210\040\103\041\102\042\206\043\205\044" + - "\216\045\215\046\174\047\172\053\200\054\041\057\122" + - "\060\121\061\113\062\111\063\145\064\144\065\116\066" + - "\114\070\130\071\127\073\157\074\156\102\135\113\140" + - "\114\137\115\171\116\167\117\213\120\212\121\163\122" + - "\162\001\001\000\004\031\u0211\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\140\002\106\003" + - "\105\004\165\005\104\006\132\007\131\010\142\011\141" + - "\021\110\022\107\023\202\024\201\025\155\026\154\030" + - "\u0215\031\210\040\103\041\102\042\206\043\205\044\216" + - "\045\215\046\174\047\172\053\200\054\041\057\122\060" + - "\121\061\113\062\111\063\145\064\144\065\116\066\114" + - "\070\130\071\127\073\157\074\156\102\135\113\140\114" + - "\137\115\171\116\167\117\213\120\212\121\163\122\162" + - "\001\001\000\004\031\u0216\001\001\000\002\001\001\000" + - "\004\031\u0218\001\001\000\002\001\001\000\002\001\001" + - "\000\006\053\u0224\054\041\001\001\000\014\053\200\054" + - "\041\102\u021e\103\u021d\104\u021c\001\001\000\002\001\001" + - "\000\002\001\001\000\002\001\001\000\010\053\200\054" + - "\041\102\u0220\001\001\000\002\001\001\000\002\001\001" + - "\000\006\053\u0223\054\041\001\001\000\002\001\001\000" + - "\002\001\001\000\004\031\u0232\001\001\000\002\001\001" + - "\000\006\053\u0228\054\041\001\001\000\004\031\u0229\001" + - "\001\000\002\001\001\000\016\014\070\015\065\017\u022f" + - "\053\066\054\041\055\067\001\001\000\016\014\070\015" + - "\065\017\u022c\053\066\054\041\055\067\001\001\000\002" + - "\001\001\000\004\031\u022e\001\001\000\002\001\001\000" + - "\002\001\001\000\004\031\u0231\001\001\000\002\001\001" + - "\000\002\001\001\000\016\014\070\015\065\017\u0238\053" + - "\066\054\041\055\067\001\001\000\016\014\070\015\065" + - "\017\u0235\053\066\054\041\055\067\001\001\000\002\001" + - "\001\000\004\031\u0237\001\001\000\002\001\001\000\002" + - "\001\001\000\004\031\u023a\001\001\000\002\001\001\000" + - "\006\031\u023e\052\u023d\001\001\000\140\002\106\003\105" + - "\004\165\005\104\006\132\007\131\010\142\011\141\021" + - "\110\022\107\023\202\024\201\025\155\026\154\030\u024b" + - "\031\210\040\103\041\102\042\206\043\205\044\216\045" + - "\215\046\174\047\172\053\200\054\041\057\122\060\121" + - "\061\113\062\111\063\145\064\144\065\116\066\114\070" + - "\130\071\127\073\157\074\156\102\135\113\140\114\137" + - "\115\171\116\167\117\213\120\212\121\163\122\162\001" + - "\001\000\002\001\001\000\002\001\001\000\010\053\066" + - "\054\041\055\u0247\001\001\000\010\053\066\054\041\055" + - "\u0241\001\001\000\002\001\001\000\006\031\u023e\052\u0243" + - "\001\001\000\002\001\001\000\006\031\u023e\052\u0245\001" + - "\001\000\002\001\001\000\006\031\u023e\052\u024a\001\001" + - "\000\002\001\001\000\006\031\u023e\052\u0249\001\001\000" + + "\000\002\001\001\000\034\004\174\005\u020b\007\311\022" + + "\305\024\214\031\224\047\352\053\213\054\043\071\313" + + "\074\165\102\143\122\171\001\001\000\002\001\001\000" + + "\006\031\260\034\u020d\001\001\000\002\001\001\000\026" + + "\004\174\005\u0211\007\311\024\214\031\224\053\213\054" + + "\043\071\u0100\102\143\122\171\001\001\000\032\004\174" + + "\005\u0210\007\311\022\305\024\214\031\224\053\213\054" + + "\043\071\313\074\377\102\143\122\171\001\001\000\002" + + "\001\001\000\002\001\001\000\132\002\114\003\113\004" + + "\174\005\u0216\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\031\224\040\u0215\041\u0198\042" + + "\221\043\u0217\044\232\045\231\046\205\047\203\053\213" + + "\054\043\057\106\060\105\061\120\062\117\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\146" + + "\114\145\115\200\116\176\117\227\120\226\121\172\122" + + "\171\124\211\125\210\001\001\000\054\004\174\005\u0214" + + "\007\311\011\u0136\022\305\024\214\031\224\047\300\053" + + "\213\054\043\060\105\062\117\066\306\071\313\074\165" + + "\102\143\114\u0135\116\u0110\120\u0138\122\171\125\u0197\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\126\002\114\003\113\004\174\005" + + "\u0219\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\031\224\042\u021a\043\u019c\044\u021b\045" + + "\u019b\046\205\047\203\053\213\054\043\057\106\060\105" + + "\061\120\062\117\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\146\114\145\115\200\116\176" + + "\117\227\120\226\121\172\122\171\124\211\125\210\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\146\002\114\003\113\004\174\005\112" + + "\006\137\007\136\010\151\011\150\021\116\022\115\023" + + "\215\024\214\025\164\026\163\030\u0221\031\224\040\110" + + "\041\107\042\221\043\220\044\232\045\231\046\205\047" + + "\203\053\213\054\043\057\106\060\105\061\120\062\117" + + "\063\154\064\153\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\146\114\145\115\200\116\176" + + "\117\227\120\226\121\172\122\171\124\211\125\210\126" + + "\202\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\146\002\114\003\113\004\174\005\112\006" + + "\137\007\136\010\151\011\150\021\116\022\115\023\215" + + "\024\214\025\164\026\163\030\u0225\031\224\040\110\041" + + "\107\042\221\043\220\044\232\045\231\046\205\047\203" + + "\053\213\054\043\057\106\060\105\061\120\062\117\063" + + "\154\064\153\065\124\066\122\070\135\071\134\073\166" + + "\074\165\102\143\113\146\114\145\115\200\116\176\117" + + "\227\120\226\121\172\122\171\124\211\125\210\126\202" + + "\001\001\000\002\001\001\000\146\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\u0227\031" + + "\224\040\110\041\107\042\221\043\220\044\232\045\231" + + "\046\205\047\203\053\213\054\043\057\106\060\105\061" + + "\120\062\117\063\154\064\153\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\124\211" + + "\125\210\126\202\001\001\000\002\001\001\000\002\001" + + "\001\000\146\002\114\003\113\004\174\005\112\006\137" + + "\007\136\010\151\011\150\021\116\022\115\023\215\024" + + "\214\025\164\026\163\030\u022a\031\224\040\110\041\107" + + "\042\221\043\220\044\232\045\231\046\205\047\203\053" + + "\213\054\043\057\106\060\105\061\120\062\117\063\154" + + "\064\153\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\146\114\145\115\200\116\176\117\227" + + "\120\226\121\172\122\171\124\211\125\210\126\202\001" + + "\001\000\004\031\u022b\001\001\000\002\001\001\000\002" + + "\001\001\000\010\053\067\054\043\055\u023f\001\001\000" + + "\002\001\001\000\010\053\067\054\043\055\u0231\001\001" + + "\000\010\053\067\054\043\055\u0236\001\001\000\002\001" + + "\001\000\146\002\114\003\113\004\174\005\112\006\137" + + "\007\136\010\151\011\150\021\116\022\115\023\215\024" + + "\214\025\164\026\163\030\u0233\031\224\040\110\041\107" + + "\042\221\043\220\044\232\045\231\046\205\047\203\053" + + "\213\054\043\057\106\060\105\061\120\062\117\063\154" + + "\064\153\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\146\114\145\115\200\116\176\117\227" + + "\120\226\121\172\122\171\124\211\125\210\126\202\001" + + "\001\000\002\001\001\000\146\002\114\003\113\004\174" + + "\005\112\006\137\007\136\010\151\011\150\021\116\022" + + "\115\023\215\024\214\025\164\026\163\030\u0235\031\224" + + "\040\110\041\107\042\221\043\220\044\232\045\231\046" + + "\205\047\203\053\213\054\043\057\106\060\105\061\120" + + "\062\117\063\154\064\153\065\124\066\122\070\135\071" + + "\134\073\166\074\165\102\143\113\146\114\145\115\200" + + "\116\176\117\227\120\226\121\172\122\171\124\211\125" + + "\210\126\202\001\001\000\002\001\001\000\002\001\001" + + "\000\146\002\114\003\113\004\174\005\112\006\137\007" + + "\136\010\151\011\150\021\116\022\115\023\215\024\214" + + "\025\164\026\163\030\u0238\031\224\040\110\041\107\042" + + "\221\043\220\044\232\045\231\046\205\047\203\053\213" + + "\054\043\057\106\060\105\061\120\062\117\063\154\064" + + "\153\065\124\066\122\070\135\071\134\073\166\074\165" + + "\102\143\113\146\114\145\115\200\116\176\117\227\120" + + "\226\121\172\122\171\124\211\125\210\126\202\001\001" + + "\000\002\001\001\000\146\002\114\003\113\004\174\005" + + "\112\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\025\164\026\163\030\u023a\031\224\040" + + "\110\041\107\042\221\043\220\044\232\045\231\046\205" + + "\047\203\053\213\054\043\057\106\060\105\061\120\062" + + "\117\063\154\064\153\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\146\114\145\115\200\116" + + "\176\117\227\120\226\121\172\122\171\124\211\125\210" + + "\126\202\001\001\000\002\001\001\000\146\002\114\003" + + "\113\004\174\005\112\006\137\007\136\010\151\011\150" + + "\021\116\022\115\023\215\024\214\025\164\026\163\030" + + "\u023c\031\224\040\110\041\107\042\221\043\220\044\232" + + "\045\231\046\205\047\203\053\213\054\043\057\106\060" + + "\105\061\120\062\117\063\154\064\153\065\124\066\122" + + "\070\135\071\134\073\166\074\165\102\143\113\146\114" + + "\145\115\200\116\176\117\227\120\226\121\172\122\171" + + "\124\211\125\210\126\202\001\001\000\002\001\001\000" + + "\146\002\114\003\113\004\174\005\112\006\137\007\136" + + "\010\151\011\150\021\116\022\115\023\215\024\214\025" + + "\164\026\163\030\u023e\031\224\040\110\041\107\042\221" + + "\043\220\044\232\045\231\046\205\047\203\053\213\054" + + "\043\057\106\060\105\061\120\062\117\063\154\064\153" + + "\065\124\066\122\070\135\071\134\073\166\074\165\102" + + "\143\113\146\114\145\115\200\116\176\117\227\120\226" + + "\121\172\122\171\124\211\125\210\126\202\001\001\000" + + "\002\001\001\000\002\001\001\000\146\002\114\003\113" + + "\004\174\005\112\006\137\007\136\010\151\011\150\021" + + "\116\022\115\023\215\024\214\025\164\026\163\030\u0241" + + "\031\224\040\110\041\107\042\221\043\220\044\232\045" + + "\231\046\205\047\203\053\213\054\043\057\106\060\105" + + "\061\120\062\117\063\154\064\153\065\124\066\122\070" + + "\135\071\134\073\166\074\165\102\143\113\146\114\145" + + "\115\200\116\176\117\227\120\226\121\172\122\171\124" + + "\211\125\210\126\202\001\001\000\002\001\001\000\146" + + "\002\114\003\113\004\174\005\112\006\137\007\136\010" + + "\151\011\150\021\116\022\115\023\215\024\214\025\164" + + "\026\163\030\u0243\031\224\040\110\041\107\042\221\043" + + "\220\044\232\045\231\046\205\047\203\053\213\054\043" + + "\057\106\060\105\061\120\062\117\063\154\064\153\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\146\114\145\115\200\116\176\117\227\120\226\121" + + "\172\122\171\124\211\125\210\126\202\001\001\000\002" + + "\001\001\000\146\002\114\003\113\004\174\005\112\006" + + "\137\007\136\010\151\011\150\021\116\022\115\023\215" + + "\024\214\025\164\026\163\030\u0245\031\224\040\110\041" + + "\107\042\221\043\220\044\232\045\231\046\205\047\203" + + "\053\213\054\043\057\106\060\105\061\120\062\117\063" + + "\154\064\153\065\124\066\122\070\135\071\134\073\166" + + "\074\165\102\143\113\146\114\145\115\200\116\176\117" + + "\227\120\226\121\172\122\171\124\211\125\210\126\202" + + "\001\001\000\002\001\001\000\146\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\u0247\031" + + "\224\040\110\041\107\042\221\043\220\044\232\045\231" + + "\046\205\047\203\053\213\054\043\057\106\060\105\061" + + "\120\062\117\063\154\064\153\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\124\211" + + "\125\210\126\202\001\001\000\002\001\001\000\016\014" + + "\072\015\070\017\u0249\053\067\054\043\055\071\001\001" + + "\000\002\001\001\000\002\001\001\000\146\002\114\003" + + "\113\004\174\005\112\006\137\007\136\010\151\011\150" + + "\021\116\022\115\023\215\024\214\025\164\026\163\030" + + "\u024c\031\224\040\110\041\107\042\221\043\220\044\232" + + "\045\231\046\205\047\203\053\213\054\043\057\106\060" + + "\105\061\120\062\117\063\154\064\153\065\124\066\122" + + "\070\135\071\134\073\166\074\165\102\143\113\146\114" + + "\145\115\200\116\176\117\227\120\226\121\172\122\171" + + "\124\211\125\210\126\202\001\001\000\002\001\001\000" + + "\146\002\114\003\113\004\174\005\112\006\137\007\136" + + "\010\151\011\150\021\116\022\115\023\215\024\214\025" + + "\164\026\163\030\u024e\031\224\040\110\041\107\042\221" + + "\043\220\044\232\045\231\046\205\047\203\053\213\054" + + "\043\057\106\060\105\061\120\062\117\063\154\064\153" + + "\065\124\066\122\070\135\071\134\073\166\074\165\102" + + "\143\113\146\114\145\115\200\116\176\117\227\120\226" + + "\121\172\122\171\124\211\125\210\126\202\001\001\000" + + "\002\001\001\000\002\001\001\000\146\002\114\003\113" + + "\004\174\005\112\006\137\007\136\010\151\011\150\021" + + "\116\022\115\023\215\024\214\025\164\026\163\030\u0251" + + "\031\224\040\110\041\107\042\221\043\220\044\232\045" + + "\231\046\205\047\203\053\213\054\043\057\106\060\105" + + "\061\120\062\117\063\154\064\153\065\124\066\122\070" + + "\135\071\134\073\166\074\165\102\143\113\146\114\145" + + "\115\200\116\176\117\227\120\226\121\172\122\171\124" + + "\211\125\210\126\202\001\001\000\002\001\001\000\146" + + "\002\114\003\113\004\174\005\112\006\137\007\136\010" + + "\151\011\150\021\116\022\115\023\215\024\214\025\164" + + "\026\163\030\u0253\031\224\040\110\041\107\042\221\043" + + "\220\044\232\045\231\046\205\047\203\053\213\054\043" + + "\057\106\060\105\061\120\062\117\063\154\064\153\065" + + "\124\066\122\070\135\071\134\073\166\074\165\102\143" + + "\113\146\114\145\115\200\116\176\117\227\120\226\121" + + "\172\122\171\124\211\125\210\126\202\001\001\000\002" + + "\001\001\000\002\001\001\000\146\002\114\003\113\004" + + "\174\005\112\006\137\007\136\010\151\011\150\021\116" + + "\022\115\023\215\024\214\025\164\026\163\030\u0256\031" + + "\224\040\110\041\107\042\221\043\220\044\232\045\231" + + "\046\205\047\203\053\213\054\043\057\106\060\105\061" + + "\120\062\117\063\154\064\153\065\124\066\122\070\135" + + "\071\134\073\166\074\165\102\143\113\146\114\145\115" + + "\200\116\176\117\227\120\226\121\172\122\171\124\211" + + "\125\210\126\202\001\001\000\002\001\001\000\146\002" + + "\114\003\113\004\174\005\112\006\137\007\136\010\151" + + "\011\150\021\116\022\115\023\215\024\214\025\164\026" + + "\163\030\u0258\031\224\040\110\041\107\042\221\043\220" + + "\044\232\045\231\046\205\047\203\053\213\054\043\057" + + "\106\060\105\061\120\062\117\063\154\064\153\065\124" + + "\066\122\070\135\071\134\073\166\074\165\102\143\113" + + "\146\114\145\115\200\116\176\117\227\120\226\121\172" + + "\122\171\124\211\125\210\126\202\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\146\002\114" + + "\003\113\004\174\005\112\006\137\007\136\010\151\011" + + "\150\021\116\022\115\023\215\024\214\025\164\026\163" + + "\030\u025c\031\224\040\110\041\107\042\221\043\220\044" + + "\232\045\231\046\205\047\203\053\213\054\043\057\106" + + "\060\105\061\120\062\117\063\154\064\153\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\146" + + "\114\145\115\200\116\176\117\227\120\226\121\172\122" + + "\171\124\211\125\210\126\202\001\001\000\004\031\u025d" + + "\001\001\000\002\001\001\000\004\031\u025f\001\001\000" + + "\002\001\001\000\146\002\114\003\113\004\174\005\112" + + "\006\137\007\136\010\151\011\150\021\116\022\115\023" + + "\215\024\214\025\164\026\163\030\u026d\031\224\040\110" + + "\041\107\042\221\043\220\044\232\045\231\046\205\047" + + "\203\053\213\054\043\057\106\060\105\061\120\062\117" + + "\063\154\064\153\065\124\066\122\070\135\071\134\073" + + "\166\074\165\102\143\113\146\114\145\115\200\116\176" + + "\117\227\120\226\121\172\122\171\124\211\125\210\126" + + "\202\001\001\000\016\014\072\015\070\017\u0268\053\067" + + "\054\043\055\071\001\001\000\016\014\072\015\070\017" + + "\u0263\053\067\054\043\055\071\001\001\000\002\001\001" + + "\000\002\001\001\000\146\002\114\003\113\004\174\005" + + "\112\006\137\007\136\010\151\011\150\021\116\022\115" + + "\023\215\024\214\025\164\026\163\030\u0266\031\224\040" + + "\110\041\107\042\221\043\220\044\232\045\231\046\205" + + "\047\203\053\213\054\043\057\106\060\105\061\120\062" + + "\117\063\154\064\153\065\124\066\122\070\135\071\134" + + "\073\166\074\165\102\143\113\146\114\145\115\200\116" + + "\176\117\227\120\226\121\172\122\171\124\211\125\210" + + "\126\202\001\001\000\004\031\u0267\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\146\002\114" + + "\003\113\004\174\005\112\006\137\007\136\010\151\011" + + "\150\021\116\022\115\023\215\024\214\025\164\026\163" + + "\030\u026b\031\224\040\110\041\107\042\221\043\220\044" + + "\232\045\231\046\205\047\203\053\213\054\043\057\106" + + "\060\105\061\120\062\117\063\154\064\153\065\124\066" + + "\122\070\135\071\134\073\166\074\165\102\143\113\146" + + "\114\145\115\200\116\176\117\227\120\226\121\172\122" + + "\171\124\211\125\210\126\202\001\001\000\004\031\u026c" + + "\001\001\000\002\001\001\000\004\031\u026e\001\001\000" + + "\002\001\001\000\002\001\001\000\006\053\u027a\054\043" + + "\001\001\000\014\053\213\054\043\102\u0274\103\u0273\104" + + "\u0272\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\010\053\213\054\043\102\u0276\001\001\000" + + "\002\001\001\000\002\001\001\000\006\053\u0279\054\043" + + "\001\001\000\002\001\001\000\002\001\001\000\004\031" + + "\u0288\001\001\000\002\001\001\000\006\053\u027e\054\043" + + "\001\001\000\004\031\u027f\001\001\000\002\001\001\000" + + "\016\014\072\015\070\017\u0285\053\067\054\043\055\071" + + "\001\001\000\016\014\072\015\070\017\u0282\053\067\054" + + "\043\055\071\001\001\000\002\001\001\000\004\031\u0284" + + "\001\001\000\002\001\001\000\002\001\001\000\004\031" + + "\u0287\001\001\000\002\001\001\000\002\001\001\000\016" + + "\014\072\015\070\017\u028e\053\067\054\043\055\071\001" + + "\001\000\016\014\072\015\070\017\u028b\053\067\054\043" + + "\055\071\001\001\000\002\001\001\000\004\031\u028d\001" + + "\001\000\002\001\001\000\002\001\001\000\004\031\u0290" + + "\001\001\000\002\001\001\000\006\031\u0294\052\u0293\001" + + "\001\000\146\002\114\003\113\004\174\005\112\006\137" + + "\007\136\010\151\011\150\021\116\022\115\023\215\024" + + "\214\025\164\026\163\030\u02a1\031\224\040\110\041\107" + + "\042\221\043\220\044\232\045\231\046\205\047\203\053" + + "\213\054\043\057\106\060\105\061\120\062\117\063\154" + + "\064\153\065\124\066\122\070\135\071\134\073\166\074" + + "\165\102\143\113\146\114\145\115\200\116\176\117\227" + + "\120\226\121\172\122\171\124\211\125\210\126\202\001" + + "\001\000\002\001\001\000\002\001\001\000\010\053\067" + + "\054\043\055\u029d\001\001\000\010\053\067\054\043\055" + + "\u0297\001\001\000\002\001\001\000\006\031\u0294\052\u0299" + + "\001\001\000\002\001\001\000\006\031\u0294\052\u029b\001" + + "\001\000\002\001\001\000\006\031\u0294\052\u02a0\001\001" + + "\000\002\001\001\000\006\031\u0294\052\u029f\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\010\053\066\054\041\055\u024e\001\001\000" + + "\001\001\000\010\053\067\054\043\055\u02a4\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\004" + - "\013\u0252\001\001\000\010\031\u0254\053\u0253\054\041\001" + - "\001\000\012\031\u027b\053\u027a\054\041\075\u027c\001\001" + - "\000\004\075\u0255\001\001\000\004\027\u0277\001\001\000" + - "\010\110\u0258\111\u025b\112\u0259\001\001\000\002\001\001" + - "\000\006\053\u0269\054\041\001\001\000\002\001\001\000" + + "\013\u02a8\001\001\000\010\031\u02aa\053\u02a9\054\043\001" + + "\001\000\012\031\u02d2\053\u02d1\054\043\075\u02d3\001\001" + + "\000\004\075\u02ab\001\001\000\004\027\u02ce\001\001\000" + + "\010\110\u02ae\111\u02b1\112\u02af\001\001\000\002\001\001" + + "\000\006\053\u02c0\054\043\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\010" + - "\110\u0258\111\u025b\112\u0263\001\001\000\002\001\001\000" + + "\110\u02ae\111\u02b1\112\u02b9\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\006\110" + - "\u0258\111\u0266\001\001\000\002\001\001\000\002\001\001" + + "\u02ae\111\u02bc\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\004\075\u0280\001\001" + - "\000\004\075\u027e\001\001\000\004\027\u027d\001\001\000" + - "\002\001\001\000\004\027\u027f\001\001\000\002\001\001" + - "\000\004\027\u0281\001\001\000\002\001\001\000\004\077" + - "\u0286\001\001\000\012\053\200\054\041\102\u028d\105\u0291" + - "\001\001\000\010\053\200\054\041\102\u0290\001\001\000" + - "\012\053\200\054\041\102\u028d\105\u028c\001\001\000\002" + - "\001\001\000\016\014\070\015\065\017\u0288\053\066\054" + - "\041\055\067\001\001\000\002\001\001\000\006\031\u028b" + - "\032\u028a\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\010\053\200\054\041" + - "\102\u028f\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\004" + + "\075\u02d7\001\001\000\004\075\u02d5\001\001\000\004\027" + + "\u02d4\001\001\000\002\001\001\000\004\027\u02d6\001\001" + + "\000\002\001\001\000\004\027\u02d8\001\001\000\002\001" + + "\001\000\004\077\u02dd\001\001\000\012\053\213\054\043" + + "\102\u02e4\105\u02e8\001\001\000\010\053\213\054\043\102" + + "\u02e7\001\001\000\012\053\213\054\043\102\u02e4\105\u02e3" + + "\001\001\000\002\001\001\000\016\014\072\015\070\017" + + "\u02df\053\067\054\043\055\071\001\001\000\002\001\001" + + "\000\006\031\u02e2\032\u02e1\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\010" + + "\053\213\054\043\102\u02e6\001\001\000\002\001\001\000" + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + - "\001\001\000\010\053\u0296\054\041\056\u0298\001\001\000" + - "\002\001\001\000\006\053\u029e\054\041\001\001\000\002" + - "\001\001\000\006\053\u029b\054\041\001\001\000\002\001" + - "\001\000\002\001\001\000\006\053\u029d\054\041\001\001" + - "\000\002\001\001\000\002\001\001\000\004\031\u02a3\001" + - "\001\000\004\031\u02a2\001\001\000\002\001\001\000\002" + - "\001\001\000\002\001\001\000\012\031\u02a9\053\u02a8\054" + - "\041\075\u02aa\001\001\000\004\075\u02a6\001\001\000\004" + - "\027\u02a7\001\001\000\002\001\001\000\004\075\u02ae\001" + - "\001\000\004\075\u02ac\001\001\000\004\027\u02ab\001\001" + - "\000\002\001\001\000\004\027\u02ad\001\001\000\002\001" + - "\001\000\004\027\u02af\001\001\000\002\001\001\000\004" + - "\031\u02b4\001\001\000\004\031\u02b3\001\001\000\002\001" + + "\001\001\000\002\001\001\000\010\053\u02ed\054\043\056" + + "\u02ef\001\001\000\002\001\001\000\006\053\u02f5\054\043" + + "\001\001\000\002\001\001\000\006\053\u02f2\054\043\001" + + "\001\000\002\001\001\000\002\001\001\000\006\053\u02f4" + + "\054\043\001\001\000\002\001\001\000\002\001\001\000" + + "\004\031\u02fa\001\001\000\004\031\u02f9\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\012\031" + + "\u0300\053\u02ff\054\043\075\u0301\001\001\000\004\075\u02fd" + + "\001\001\000\004\027\u02fe\001\001\000\002\001\001\000" + + "\004\075\u0305\001\001\000\004\075\u0303\001\001\000\004" + + "\027\u0302\001\001\000\002\001\001\000\004\027\u0304\001" + + "\001\000\002\001\001\000\004\027\u0306\001\001\000\002" + + "\001\001\000\004\031\u030b\001\001\000\004\031\u030a\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + - "" }); + "\000\002\001\001" }); /** Access to reduce_goto table. */ + @Override public short[][] reduce_table() {return _reduce_table;} /** Instance of action encapsulation class. */ protected CUP$CompParser$actions action_obj; /** Action encapsulation object initializer. */ + @Override protected void init_actions() { action_obj = new CUP$CompParser$actions(this); } /** Invoke a user supplied parse action. */ + @Override public java_cup.runtime.Symbol do_action( int act_num, java_cup.runtime.lr_parser parser, - java.util.Stack stack, + java.util.Stack stack, int top) throws java.lang.Exception { @@ -2027,14 +2603,18 @@ public java_cup.runtime.Symbol do_action( } /** Indicates start state. */ + @Override public int start_state() {return 0;} /** Indicates start production. */ + @Override public int start_production() {return 1;} /** EOF Symbol index. */ + @Override public int EOF_sym() {return 0;} /** error Symbol index. */ + @Override public int error_sym() {return 1;} @@ -2060,13 +2640,13 @@ public java_cup.runtime.Symbol do_action( for (_done_parsing = false; !_done_parsing; ) { act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym); if (act > 0) { // "shift"; thus, we shift to the encoded state by pushing it on the stack - if (logging) System.out.println("shift " + cur_token.sym); + // if (logging) System.out.println("shift " + cur_token.sym); cur_token.parse_state = act-1; stack.push(cur_token); tos++; cur_token = scan(); } else if (act<0) { // "reduce" - if (logging) System.out.println("reduce " + ((-act)-1)); + // if (logging) System.out.println("reduce " + ((-act)-1)); lhs_sym = do_action((-act)-1, this, stack, tos); lhs_sym_num = production_tab[(-act)-1][0]; handle_size = production_tab[(-act)-1][1]; @@ -2200,6 +2780,20 @@ public void syntax_error(Symbol x) throws Err { ch.put(CompSym.ID, "NAME"); ch.put(CompSym.NUMBER, "NUMBER"); ch.put(CompSym.STR, "STRING"); + ch.put(CompSym.VAR, "var"); + ch.put(CompSym.ALWAYS, "always"); + ch.put(CompSym.EVENTUALLY, "eventually"); + ch.put(CompSym.AFTER, "after"); + ch.put(CompSym.BEFORE, "before"); + ch.put(CompSym.HISTORICALLY, "historically"); + ch.put(CompSym.ONCE, "once"); + ch.put(CompSym.RELEASES, "releases"); + ch.put(CompSym.UNTIL, "until"); + ch.put(CompSym.SINCE, "since"); + ch.put(CompSym.TRIGGERED, "triggered"); + ch.put(CompSym.TRCSEQ, ";"); + ch.put(CompSym.PRIME, "'"); + ch.put(CompSym.TIME, "steps"); TreeSet list = new TreeSet(); Pos p=Pos.UNKNOWN; if (x!=null && x.value instanceof Pos) p=(Pos)(x.value); @@ -2314,6 +2908,7 @@ private void nod(List names) throws Err { private void c(boolean follow, ExprVar o, ExprVar x, ExprVar n, Expr e, List s, ExprConstant c) throws Err { if (n!=null) nod(n); int bitwidth=(-1), maxseq=(-1), overall=(-1), expects=(c==null ? -1 : c.num); + int maxtime = (-1), mintime = (-1); Pos p = o.pos.merge(n!=null ? n.span() : e.span()); for(int i=s.size()-1; i>=0; i--) { Sig j=s.get(i).sig; int k=s.get(i).startingScope; @@ -2321,11 +2916,23 @@ private void c(boolean follow, ExprVar o, ExprVar x, ExprVar n, Expr e, List=0) throw new ErrorSyntax(j.pos, "The bitwidth cannot be specified more than once."); bitwidth=k; s.remove(i); continue; } if (j.label.equals("seq")) { if (maxseq>=0) throw new ErrorSyntax(j.pos, "The maximum sequence length cannot be specified more than once."); maxseq=k; s.remove(i); continue; } + // [electrum] process time scopes + if (j.label.equals("steps")) { + if (s.get(i).endingScope == Integer.MAX_VALUE && s.get(i).startingScope != 1) throw new ErrorSyntax(j.pos, "Unbounded time scope must start at 1."); + if (s.get(i).increment != 1) throw new ErrorSyntax(j.pos, "Step scopes must be incremented by 1."); + if (k<1) throw new ErrorSyntax(j.pos, "Trace solutions must contain at least one step."); + if (maxtime>=0) throw new ErrorSyntax(j.pos, "Steps scope cannot be specified more than once."); + maxtime=k; + if (s.get(i).isExact) mintime = k; + else if (s.get(i).endingScope != s.get(i).startingScope) { + maxtime = s.get(i).endingScope; mintime = s.get(i).startingScope; } + s.remove(i); continue; + } } if (n!=null) - parser.alloymodule.addCommand(follow, p, n, o.label.equals("c"), overall, bitwidth, maxseq, expects, s, x); + parser.alloymodule.addCommand(follow, p, n, o.label.equals("c"), overall, bitwidth, maxseq, mintime, maxtime, expects, s, x); else - parser.alloymodule.addCommand(follow, p, e, o.label.equals("c"), overall, bitwidth, maxseq, expects, s, x); + parser.alloymodule.addCommand(follow, p, e, o.label.equals("c"), overall, bitwidth, maxseq, mintime, maxtime, expects, s, x); } private Expr t(Pos pos, Pos oldClosing, Expr left, Expr right, Pos close) throws Err { if (right instanceof ExprVar) { @@ -2351,7 +2958,7 @@ else if (right instanceof ExprList) { public final java_cup.runtime.Symbol CUP$CompParser$do_action( int CUP$CompParser$act_num, java_cup.runtime.lr_parser CUP$CompParser$parser, - java.util.Stack CUP$CompParser$stack, + java.util.Stack CUP$CompParser$stack, int CUP$CompParser$top) throws java.lang.Exception { @@ -2362,5474 +2969,13033 @@ else if (right instanceof ExprList) { switch (CUP$CompParser$act_num) { /*. . . . . . . . . . . . . . . . . . . .*/ - case 349: // BaseExpr ::= LBRACE Declz RBRACE + case 397: // BaseExpr ::= LBRACE Declz RBRACE { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.COMPREHENSION.make(o, c, a, ExprConstant.TRUE); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case397( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 348: // BaseExpr ::= LBRACE Declz SuperOrBar RBRACE + case 396: // BaseExpr ::= LBRACE Declz SuperOrBar RBRACE { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.COMPREHENSION.make(o, c, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case396( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 347: // BaseExpr ::= Super + case 395: // BaseExpr ::= Super { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case395( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 346: // BaseExpr ::= AT Name + case 394: // BaseExpr ::= AT Name { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(x); RESULT = ExprVar.make(o.merge(x.pos), "@"+x.label); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case394( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 345: // BaseExpr ::= SigRef + case 393: // BaseExpr ::= SigRef { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case393( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 344: // BaseExpr ::= LPAREN Expr RPAREN + case 392: // BaseExpr ::= LPAREN Expr RPAREN { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case392( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 343: // BaseExpr ::= INTNEXT + case 391: // BaseExpr ::= INTNEXT { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprConstant.Op.NEXT.make(o, 0); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case391( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 342: // BaseExpr ::= INTMAX + case 390: // BaseExpr ::= INTMAX { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprConstant.Op.MAX.make(o, 0); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case390( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 341: // BaseExpr ::= INTMIN + case 389: // BaseExpr ::= INTMIN { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprConstant.Op.MIN.make(o, 0); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case389( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 340: // BaseExpr ::= THIS + case 388: // BaseExpr ::= THIS { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprVar.make(o, "this"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case388( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 339: // BaseExpr ::= IDEN + case 387: // BaseExpr ::= IDEN { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprVar.make(o, "iden"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case387( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 338: // BaseExpr ::= STR + case 386: // BaseExpr ::= STR { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant x = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case386( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 337: // BaseExpr ::= NUMBER + case 385: // BaseExpr ::= NUMBER { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant x = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case385( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 336: // UnopExprB ::= CARET UnopExprB + case 384: // UnopExprB ::= UnopExprB PRIME { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CLOSURE .make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case384( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 335: // UnopExprB ::= STAR UnopExprB + case 383: // UnopExprA ::= UnopExprA PRIME { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.RCLOSURE .make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case383( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 334: // UnopExprB ::= TILDE UnopExprB + case 382: // UnopExprA ::= Bind PRIME { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case382( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 333: // UnopExprB ::= BaseExpr + case 381: // UnopExprB ::= CARET UnopExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case381( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 332: // UnopExprA ::= CARET UnopExprA + case 380: // UnopExprB ::= STAR UnopExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CLOSURE .make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case380( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 331: // UnopExprA ::= STAR UnopExprA + case 379: // UnopExprB ::= TILDE UnopExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.RCLOSURE .make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case379( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 330: // UnopExprA ::= TILDE UnopExprA + case 378: // UnopExprB ::= BaseExpr { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case378( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 329: // UnopExprA ::= CARET Bind + case 377: // UnopExprA ::= CARET UnopExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CLOSURE .make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case377( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 328: // UnopExprA ::= STAR Bind + case 376: // UnopExprA ::= STAR UnopExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.RCLOSURE .make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case376( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 327: // UnopExprA ::= TILDE Bind + case 375: // UnopExprA ::= TILDE UnopExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case375( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 326: // DotExprB ::= BracketExprB DOT SUM + case 374: // UnopExprA ::= CARET Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, a)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case374( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 325: // DotExprB ::= BracketExprB DOT INT + case 373: // UnopExprA ::= STAR Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, a)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case373( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 324: // DotExprB ::= BracketExprB DOT TOTALORDER + case 372: // UnopExprA ::= TILDE Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=t(o, null, a, ExprVar.make(b, "pred/totalOrder"), null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case372( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 323: // DotExprB ::= BracketExprB DOT DISJ + case 371: // DotExprB ::= BracketExprB DOT SUM { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=t(o, null, a, ExprVar.make(b, "disj"), null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case371( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 322: // DotExprB ::= BracketExprB DOT UnopExprB + case 370: // DotExprB ::= BracketExprB DOT INT { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=t(o, null, a, b, null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case370( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 321: // DotExprB ::= UnopExprB + case 369: // DotExprB ::= BracketExprB DOT TOTALORDER { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case369( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 320: // DotExprA ::= BracketExprB DOT Bind + case 368: // DotExprB ::= BracketExprB DOT DISJ { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=t(o, null, a, b, null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprA",17, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case368( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 319: // DotExprA ::= UnopExprA + case 367: // DotExprB ::= BracketExprB DOT UnopExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprA",17, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case367( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 318: // BracketExprB ::= SUM LBRACKET Exprs RBRACKET + case 366: // DotExprB ::= UnopExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - Expr aa=ExprVar.make(a, "int"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=ExprUnary.Op.CAST2SIGINT.make(a, aa); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case366( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 317: // BracketExprB ::= INT LBRACKET Exprs RBRACKET + case 365: // DotExprA ::= BracketExprB DOT Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - Expr aa=ExprVar.make(a, "int"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=ExprUnary.Op.CAST2SIGINT.make(a, aa); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case365( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 316: // BracketExprB ::= TOTALORDER LBRACKET Exprs RBRACKET + case 364: // DotExprA ::= UnopExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - Expr aa=ExprVar.make(a, "pred/totalOrder"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=aa; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case364( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 315: // BracketExprB ::= DISJ LBRACKET Exprs RBRACKET + case 363: // BracketExprB ::= SUM LBRACKET Exprs RBRACKET { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - Expr aa=ExprVar.make(a, "disj"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=aa; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case363( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 314: // BracketExprB ::= BracketExprB LBRACKET Exprs RBRACKET + case 362: // BracketExprB ::= INT LBRACKET Exprs RBRACKET { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - Expr aa=a; for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=aa; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case362( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 313: // BracketExprB ::= DotExprB + case 361: // BracketExprB ::= TOTALORDER LBRACKET Exprs RBRACKET { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case361( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 312: // BracketExprA ::= DotExprA + case 360: // BracketExprB ::= DISJ LBRACKET Exprs RBRACKET { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprA",4, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case360( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 311: // RangeExprB ::= RangeExprB RANGE BracketExprB + case 359: // BracketExprB ::= BracketExprB LBRACKET Exprs RBRACKET { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.RANGE.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprB",55, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case359( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 310: // RangeExprB ::= BracketExprB + case 358: // BracketExprB ::= DotExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprB",55, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case358( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 309: // RangeExprA ::= RangeExprB RANGE Bind + case 357: // BracketExprA ::= DotExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.RANGE.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprA",54, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case357( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 308: // RangeExprA ::= BracketExprA + case 356: // RangeExprB ::= RangeExprB RANGE BracketExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprA",54, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case356( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 307: // DomainExprB ::= DomainExprB DOMAIN RangeExprB + case 355: // RangeExprB ::= BracketExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.DOMAIN.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprB",16, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case355( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 306: // DomainExprB ::= RangeExprB + case 354: // RangeExprA ::= RangeExprB RANGE Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprB",16, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case354( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 305: // DomainExprA ::= DomainExprB DOMAIN Bind + case 353: // RangeExprA ::= BracketExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.DOMAIN.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprA",15, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case353( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 304: // DomainExprA ::= RangeExprA + case 352: // DomainExprB ::= DomainExprB DOMAIN RangeExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprA",15, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case352( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 303: // RelationExprB ::= DomainExprB RelOp RelationExprB + case 351: // DomainExprB ::= RangeExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pair o = (Pair)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=o.b.make(o.a, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprB",58, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case351( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 302: // RelationExprB ::= DomainExprB + case 350: // DomainExprA ::= DomainExprB DOMAIN Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprB",58, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case350( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 301: // RelationExprA ::= DomainExprB RelOp Bind + case 349: // DomainExprA ::= RangeExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pair o = (Pair)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=o.b.make(o.a, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprA",57, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case349( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 300: // RelationExprA ::= DomainExprA + case 348: // RelationExprB ::= DomainExprB RelOp RelationExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprA",57, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case348( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 299: // RelOp ::= LONE_ARROW_LONE + case 347: // RelationExprB ::= DomainExprB { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_LONE); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case347( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 298: // RelOp ::= LONE_ARROW_ONE + case 346: // RelationExprA ::= DomainExprB RelOp Bind { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_ONE ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case346( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 297: // RelOp ::= LONE_ARROW_SOME + case 345: // RelationExprA ::= DomainExprA { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_SOME); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case345( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 296: // RelOp ::= LONE_ARROW_ANY + case 344: // RelOp ::= LONE_ARROW_LONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_ANY ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case344( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 295: // RelOp ::= ONE_ARROW_LONE + case 343: // RelOp ::= LONE_ARROW_ONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_LONE ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case343( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 294: // RelOp ::= ONE_ARROW_ONE + case 342: // RelOp ::= LONE_ARROW_SOME { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_ONE ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case342( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 293: // RelOp ::= ONE_ARROW_SOME + case 341: // RelOp ::= LONE_ARROW_ANY { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_SOME ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case341( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 292: // RelOp ::= ONE_ARROW_ANY + case 340: // RelOp ::= ONE_ARROW_LONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_ANY ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case340( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 291: // RelOp ::= SOME_ARROW_LONE + case 339: // RelOp ::= ONE_ARROW_ONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_LONE); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case339( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 290: // RelOp ::= SOME_ARROW_ONE + case 338: // RelOp ::= ONE_ARROW_SOME { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_ONE ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case338( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 289: // RelOp ::= SOME_ARROW_SOME + case 337: // RelOp ::= ONE_ARROW_ANY { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_SOME); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case337( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 288: // RelOp ::= SOME_ARROW_ANY + case 336: // RelOp ::= SOME_ARROW_LONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_ANY ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case336( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 287: // RelOp ::= ANY_ARROW_LONE + case 335: // RelOp ::= SOME_ARROW_ONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ANY_ARROW_LONE ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case335( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 286: // RelOp ::= ANY_ARROW_ONE + case 334: // RelOp ::= SOME_ARROW_SOME { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ANY_ARROW_ONE ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case334( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 285: // RelOp ::= ANY_ARROW_SOME + case 333: // RelOp ::= SOME_ARROW_ANY { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ANY_ARROW_SOME ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case333( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 284: // RelOp ::= ARROW + case 332: // RelOp ::= ANY_ARROW_LONE { - Pair RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Pair(o, ExprBinary.Op.ARROW ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case332( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 283: // IntersectExprB ::= IntersectExprB AMPERSAND RelationExprB + case 331: // RelOp ::= ANY_ARROW_ONE { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.INTERSECT.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprB",37, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case331( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 282: // IntersectExprB ::= RelationExprB + case 330: // RelOp ::= ANY_ARROW_SOME { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprB",37, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case330( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 281: // IntersectExprA ::= IntersectExprB AMPERSAND Bind + case 329: // RelOp ::= ARROW { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.INTERSECT.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprA",36, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case329( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 280: // IntersectExprA ::= RelationExprA + case 328: // IntersectExprB ::= IntersectExprB AMPERSAND RelationExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprA",36, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case328( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 279: // OverrideExprB ::= OverrideExprB PLUSPLUS IntersectExprB + case 327: // IntersectExprB ::= RelationExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.PLUSPLUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprB",52, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case327( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 278: // OverrideExprB ::= IntersectExprB + case 326: // IntersectExprA ::= IntersectExprB AMPERSAND Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprB",52, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case326( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 277: // OverrideExprA ::= OverrideExprB PLUSPLUS Bind + case 325: // IntersectExprA ::= RelationExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.PLUSPLUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprA",51, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case325( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 276: // OverrideExprA ::= IntersectExprA + case 324: // OverrideExprB ::= OverrideExprB PLUSPLUS IntersectExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprA",51, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case324( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 275: // NumUnopExprB ::= INT NumUnopExprB + case 323: // OverrideExprB ::= IntersectExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case323( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 274: // NumUnopExprB ::= SUM NumUnopExprB + case 322: // OverrideExprA ::= OverrideExprB PLUSPLUS Bind { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case322( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 273: // NumUnopExprB ::= HASH NumUnopExprB + case 321: // OverrideExprA ::= IntersectExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CARDINALITY.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case321( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 272: // NumUnopExprB ::= OverrideExprB + case 320: // NumUnopExprB ::= INT NumUnopExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case320( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 271: // NumUnopExprA ::= INT NumUnopExprA + case 319: // NumUnopExprB ::= SUM NumUnopExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case319( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 270: // NumUnopExprA ::= SUM NumUnopExprA + case 318: // NumUnopExprB ::= HASH NumUnopExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case318( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 269: // NumUnopExprA ::= HASH NumUnopExprA + case 317: // NumUnopExprB ::= OverrideExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CARDINALITY.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case317( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 268: // NumUnopExprA ::= INT Bind + case 316: // NumUnopExprA ::= INT NumUnopExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case316( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 267: // NumUnopExprA ::= SUM Bind + case 315: // NumUnopExprA ::= SUM NumUnopExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case315( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 266: // NumUnopExprA ::= HASH Bind + case 314: // NumUnopExprA ::= HASH NumUnopExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.CARDINALITY.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case314( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 265: // NumUnopExprA ::= OverrideExprA + case 313: // NumUnopExprA ::= INT Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case313( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 264: // MulExprB ::= MulExprB INTREM NumUnopExprB + case 312: // NumUnopExprA ::= SUM Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.REM .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case312( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 263: // MulExprB ::= MulExprB INTDIV NumUnopExprB + case 311: // NumUnopExprA ::= HASH Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.DIV .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case311( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 262: // MulExprB ::= MulExprB INTMUL NumUnopExprB + case 310: // NumUnopExprA ::= OverrideExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.MUL .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case310( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 261: // MulExprB ::= NumUnopExprB + case 309: // MulExprB ::= MulExprB INTREM NumUnopExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case309( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 260: // MulExprA ::= MulExprB INTREM Bind + case 308: // MulExprB ::= MulExprB INTDIV NumUnopExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.REM .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case308( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 259: // MulExprA ::= MulExprB INTDIV Bind + case 307: // MulExprB ::= MulExprB INTMUL NumUnopExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.DIV .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case307( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 258: // MulExprA ::= MulExprB INTMUL Bind + case 306: // MulExprB ::= NumUnopExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.MUL .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case306( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 257: // MulExprA ::= NumUnopExprA + case 305: // MulExprA ::= MulExprB INTREM Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case305( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 256: // UnionDiffExprB ::= UnionDiffExprB INTSUB MulExprB + case 304: // MulExprA ::= MulExprB INTDIV Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IMINUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case304( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 255: // UnionDiffExprB ::= UnionDiffExprB INTADD MulExprB + case 303: // MulExprA ::= MulExprB INTMUL Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IPLUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case303( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 254: // UnionDiffExprB ::= UnionDiffExprB MINUS MulExprB + case 302: // MulExprA ::= NumUnopExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.MINUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case302( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 253: // UnionDiffExprB ::= UnionDiffExprB PLUS MulExprB + case 301: // UnionDiffExprB ::= UnionDiffExprB INTSUB MulExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.PLUS .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case301( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 252: // UnionDiffExprB ::= MulExprB + case 300: // UnionDiffExprB ::= UnionDiffExprB INTADD MulExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case300( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 251: // UnionDiffExprA ::= UnionDiffExprB INTSUB Bind + case 299: // UnionDiffExprB ::= UnionDiffExprB MINUS MulExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IMINUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case299( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 250: // UnionDiffExprA ::= UnionDiffExprB INTADD Bind + case 298: // UnionDiffExprB ::= UnionDiffExprB PLUS MulExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IPLUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case298( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 249: // UnionDiffExprA ::= UnionDiffExprB MINUS Bind + case 297: // UnionDiffExprB ::= MulExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.MINUS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case297( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 248: // UnionDiffExprA ::= UnionDiffExprB PLUS Bind + case 296: // UnionDiffExprA ::= UnionDiffExprB INTSUB Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.PLUS .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case296( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 247: // UnionDiffExprA ::= MulExprA + case 295: // UnionDiffExprA ::= UnionDiffExprB INTADD Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case295( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 246: // ShiftExprB ::= ShiftExprB SHA UnionDiffExprB + case 294: // UnionDiffExprA ::= UnionDiffExprB MINUS Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.SHA.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case294( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 245: // ShiftExprB ::= ShiftExprB SHR UnionDiffExprB + case 293: // UnionDiffExprA ::= UnionDiffExprB PLUS Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.SHR.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case293( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 244: // ShiftExprB ::= ShiftExprB SHL UnionDiffExprB + case 292: // UnionDiffExprA ::= MulExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.SHL.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case292( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 243: // ShiftExprB ::= UnionDiffExprB + case 291: // ShiftExprB ::= ShiftExprB SHA UnionDiffExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case291( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 242: // ShiftExprA ::= ShiftExprB SHA Bind + case 290: // ShiftExprB ::= ShiftExprB SHR UnionDiffExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.SHA.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case290( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 241: // ShiftExprA ::= ShiftExprB SHR Bind + case 289: // ShiftExprB ::= ShiftExprB SHL UnionDiffExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.SHR.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case289( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 240: // ShiftExprA ::= ShiftExprB SHL Bind + case 288: // ShiftExprB ::= UnionDiffExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.SHL.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case288( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 239: // ShiftExprA ::= UnionDiffExprA + case 287: // ShiftExprA ::= ShiftExprB SHA Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case287( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 238: // CompareExprB ::= ShiftExprB + case 286: // ShiftExprA ::= ShiftExprB SHR Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case286( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 237: // CompareExprB ::= SEQ ShiftExprB + case 285: // ShiftExprA ::= ShiftExprB SHL Bind { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.ISSEQ_ARROW_LONE.make(o, null, ExprVar.make(o,"seq/Int"), b); parser.alloymodule.addSeq(o); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case285( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 236: // CompareExprB ::= SET ShiftExprB + case 284: // ShiftExprA ::= UnionDiffExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.SETOF.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case284( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 235: // CompareExprB ::= ONE ShiftExprB + case 283: // CompareExprB ::= ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.ONE .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case283( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 234: // CompareExprB ::= LONE ShiftExprB + case 282: // CompareExprB ::= SEQ ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.LONE .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case282( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 233: // CompareExprB ::= SOME ShiftExprB + case 281: // CompareExprB ::= SET ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.SOME .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case281( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 232: // CompareExprB ::= NO ShiftExprB + case 280: // CompareExprB ::= ONE ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.NO .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case280( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 231: // CompareExprB ::= ALL ShiftExprB + case 279: // CompareExprB ::= LONE ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - if (1==1) throw new ErrorSyntax(o,"The \"all x\" construct is no longer supported. If you know the range of possible values of x, consider rewriting it as \"x == set_of_all_possible_values\"."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case279( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 230: // CompareExprB ::= CompareExprB NOTGTE ShiftExprB + case 278: // CompareExprB ::= SOME ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_GTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case278( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 229: // CompareExprB ::= CompareExprB NOTLTE ShiftExprB + case 277: // CompareExprB ::= NO ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_LTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case277( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 228: // CompareExprB ::= CompareExprB NOTGT ShiftExprB + case 276: // CompareExprB ::= ALL ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_GT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case276( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 227: // CompareExprB ::= CompareExprB NOTLT ShiftExprB + case 275: // CompareExprB ::= CompareExprB NOTGTE ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_LT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case275( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 226: // CompareExprB ::= CompareExprB NOTEQUALS ShiftExprB + case 274: // CompareExprB ::= CompareExprB NOTLTE ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_EQUALS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case274( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 225: // CompareExprB ::= CompareExprB NOTIN ShiftExprB + case 273: // CompareExprB ::= CompareExprB NOTGT ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_IN .make(o, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case273( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 224: // CompareExprB ::= CompareExprB GTE ShiftExprB + case 272: // CompareExprB ::= CompareExprB NOTLT ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.GTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case272( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 223: // CompareExprB ::= CompareExprB LTE ShiftExprB + case 271: // CompareExprB ::= CompareExprB NOTEQUALS ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.LTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case271( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 222: // CompareExprB ::= CompareExprB GT ShiftExprB + case 270: // CompareExprB ::= CompareExprB NOTIN ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.GT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case270( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 221: // CompareExprB ::= CompareExprB LT ShiftExprB + case 269: // CompareExprB ::= CompareExprB GTE ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.LT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case269( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 220: // CompareExprB ::= CompareExprB EQUALS ShiftExprB + case 268: // CompareExprB ::= CompareExprB LTE ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.EQUALS .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case268( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 219: // CompareExprB ::= CompareExprB IN ShiftExprB + case 267: // CompareExprB ::= CompareExprB GT ShiftExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IN .make(o, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case267( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 218: // CompareExprA ::= ShiftExprA + case 266: // CompareExprB ::= CompareExprB LT ShiftExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case266( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 217: // CompareExprA ::= SEQ ShiftExprA + case 265: // CompareExprB ::= CompareExprB EQUALS ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.ISSEQ_ARROW_LONE.make(o, null, ExprVar.make(o, "seq/Int"), b); parser.alloymodule.addSeq(o); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case265( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 216: // CompareExprA ::= SET ShiftExprA + case 264: // CompareExprB ::= CompareExprB IN ShiftExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.SETOF.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case264( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 215: // CompareExprA ::= ONE ShiftExprA + case 263: // CompareExprA ::= ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.ONE .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case263( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 214: // CompareExprA ::= LONE ShiftExprA + case 262: // CompareExprA ::= SEQ ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.LONE .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case262( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 213: // CompareExprA ::= SOME ShiftExprA + case 261: // CompareExprA ::= SET ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.SOME .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case261( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 212: // CompareExprA ::= NO ShiftExprA + case 260: // CompareExprA ::= ONE ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.NO .make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case260( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 211: // CompareExprA ::= ALL ShiftExprA + case 259: // CompareExprA ::= LONE ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - if (1==1) throw new ErrorSyntax(o,"The \"all x\" construct is no longer supported. If you know the range of possible values of x, consider rewriting it as \"x == set_of_all_possible_values\"."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case259( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 210: // CompareExprA ::= CompareExprB NOTGTE ShiftExprA + case 258: // CompareExprA ::= SOME ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_GTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case258( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 209: // CompareExprA ::= CompareExprB NOTLTE ShiftExprA + case 257: // CompareExprA ::= NO ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_LTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case257( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 208: // CompareExprA ::= CompareExprB NOTGT ShiftExprA + case 256: // CompareExprA ::= ALL ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_GT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case256( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 207: // CompareExprA ::= CompareExprB NOTLT ShiftExprA + case 255: // CompareExprA ::= CompareExprB NOTGTE ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_LT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case255( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 206: // CompareExprA ::= CompareExprB NOTEQUALS ShiftExprA + case 254: // CompareExprA ::= CompareExprB NOTLTE ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_EQUALS.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case254( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 205: // CompareExprA ::= CompareExprB NOTIN ShiftExprA + case 253: // CompareExprA ::= CompareExprB NOTGT ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.NOT_IN .make(o, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case253( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 204: // CompareExprA ::= CompareExprB GTE ShiftExprA + case 252: // CompareExprA ::= CompareExprB NOTLT ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.GTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case252( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 203: // CompareExprA ::= CompareExprB LTE ShiftExprA + case 251: // CompareExprA ::= CompareExprB NOTEQUALS ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.LTE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case251( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 202: // CompareExprA ::= CompareExprB GT ShiftExprA + case 250: // CompareExprA ::= CompareExprB NOTIN ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.GT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case250( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 201: // CompareExprA ::= CompareExprB LT ShiftExprA + case 249: // CompareExprA ::= CompareExprB GTE ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.LT .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case249( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 200: // CompareExprA ::= CompareExprB EQUALS ShiftExprA + case 248: // CompareExprA ::= CompareExprB LTE ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.EQUALS .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case248( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 199: // CompareExprA ::= CompareExprB IN ShiftExprA + case 247: // CompareExprA ::= CompareExprB GT ShiftExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IN .make(o, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case247( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 198: // NegExprB ::= NOT NegExprB + case 246: // CompareExprA ::= CompareExprB LT ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.NOT.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NegExprB",46, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case246( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 197: // NegExprB ::= CompareExprB + case 245: // CompareExprA ::= CompareExprB EQUALS ShiftExprA { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NegExprB",46, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case245( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 196: // NegExprA ::= NOT NegExprA + case 244: // CompareExprA ::= CompareExprB IN ShiftExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.NOT.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NegExprA",45, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case244( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 195: // NegExprA ::= NOT Bind + case 243: // UnaryExprB ::= BEFORE UnaryExprB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.NOT.make(o, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NegExprA",45, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case243( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 194: // NegExprA ::= CompareExprA + case 242: // UnaryExprB ::= ONCE UnaryExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NegExprA",45, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case242( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 193: // AndExprB ::= AndExprB AND NegExprB + case 241: // UnaryExprB ::= HISTORICALLY UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.AND.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprB",1, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case241( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 192: // AndExprB ::= NegExprB + case 240: // UnaryExprB ::= AFTER UnaryExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprB",1, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case240( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 191: // AndExprA ::= AndExprB AND Bind + case 239: // UnaryExprB ::= EVENTUALLY UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.AND.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprA",0, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case239( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 190: // AndExprA ::= NegExprA + case 238: // UnaryExprB ::= ALWAYS UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprA",0, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case238( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 189: // ImpliesExprOpenB ::= AndExprB IMPLIES ImpliesExprB + case 237: // UnaryExprB ::= NOT UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenB",35, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case237( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 188: // ImpliesExprOpenB ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprOpenB + case 236: // UnaryExprB ::= CompareExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr c = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprITE.make(o,a,b,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenB",35, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case236( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 187: // ImpliesExprCloseB ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprCloseB + case 235: // UnaryExprA ::= BEFORE UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr c = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprITE.make(o,a,b,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseB",33, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case235( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 186: // ImpliesExprCloseB ::= AndExprB + case 234: // UnaryExprA ::= BEFORE Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseB",33, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case234( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 185: // ImpliesExprB ::= ImpliesExprOpenB + case 233: // UnaryExprA ::= ONCE UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprB",31, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case233( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 184: // ImpliesExprB ::= ImpliesExprCloseB + case 232: // UnaryExprA ::= ONCE Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprB",31, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case232( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 183: // ImpliesExprOpenA ::= AndExprB IMPLIES Bind + case 231: // UnaryExprA ::= HISTORICALLY UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenA",34, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case231( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 182: // ImpliesExprCloseA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE Bind + case 230: // UnaryExprA ::= HISTORICALLY Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr c = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprITE.make(o,a,b,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseA",32, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case230( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 181: // ImpliesExprOpenA ::= AndExprB IMPLIES ImpliesExprA + case 229: // UnaryExprA ::= AFTER UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenA",34, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case229( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 180: // ImpliesExprOpenA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprOpenA + case 228: // UnaryExprA ::= AFTER Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr c = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprITE.make(o,a,b,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenA",34, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case228( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 179: // ImpliesExprCloseA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprCloseA + case 227: // UnaryExprA ::= EVENTUALLY UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr c = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprITE.make(o,a,b,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseA",32, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case227( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 178: // ImpliesExprCloseA ::= AndExprA + case 226: // UnaryExprA ::= EVENTUALLY Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseA",32, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case226( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 177: // ImpliesExprA ::= ImpliesExprOpenA + case 225: // UnaryExprA ::= ALWAYS UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprA",30, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case225( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 176: // ImpliesExprA ::= ImpliesExprCloseA + case 224: // UnaryExprA ::= ALWAYS Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprA",30, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case224( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 175: // EquivExprB ::= EquivExprB IFF ImpliesExprB + case 223: // UnaryExprA ::= NOT UnaryExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IFF.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprB",20, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case223( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 174: // EquivExprB ::= ImpliesExprB + case 222: // UnaryExprA ::= NOT Bind { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprB",20, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case222( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 173: // EquivExprA ::= EquivExprB IFF Bind + case 221: // UnaryExprA ::= CompareExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.IFF.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprA",19, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case221( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 172: // EquivExprA ::= ImpliesExprA + case 220: // TempBinaryB ::= TempBinaryB TRIGGERED UnaryExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprA",19, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case220( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 171: // OrExprB ::= OrExprB OR EquivExprB + case 219: // TempBinaryB ::= TempBinaryB RELEASES UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.OR.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprB",50, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case219( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 170: // OrExprB ::= EquivExprB + case 218: // TempBinaryB ::= TempBinaryB SINCE UnaryExprB { - Expr RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprB",50, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case218( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 169: // OrExprA ::= OrExprB OR Bind + case 217: // TempBinaryB ::= TempBinaryB UNTIL UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.OR.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprA",49, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case217( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 168: // OrExprA ::= EquivExprA + case 216: // TempBinaryB ::= UnaryExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprA",49, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case216( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 167: // Bind ::= SUM2 Declp SuperOrBar + case 215: // TempBinaryA ::= TempBinaryB RELEASES Bind { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.SUM .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case215( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 166: // Bind ::= ONE2 Declp SuperOrBar + case 214: // TempBinaryA ::= TempBinaryB TRIGGERED Bind { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.ONE .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case214( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 165: // Bind ::= LONE2 Declp SuperOrBar + case 213: // TempBinaryA ::= TempBinaryB SINCE Bind { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.LONE.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case213( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 164: // Bind ::= SOME2 Declp SuperOrBar + case 212: // TempBinaryA ::= TempBinaryB UNTIL Bind { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.SOME.make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case212( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 163: // Bind ::= NO2 Declp SuperOrBar + case 211: // TempBinaryA ::= UnaryExprA { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.NO .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case211( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 162: // Bind ::= ALL2 Declp SuperOrBar + case 210: // AndExprB ::= AndExprB AND TempBinaryB { - Expr RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprQt.Op.ALL .make(o, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case210( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 161: // Bind ::= LET Let + case 209: // AndExprB ::= TempBinaryB { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case209( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 160: // Expr ::= Bind + case 208: // AndExprA ::= AndExprB AND Bind { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expr",22, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case208( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 159: // Expr ::= OrExprB + case 207: // AndExprA ::= TempBinaryA { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expr",22, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case207( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 158: // Expr ::= OrExprA + case 206: // ImpliesExprOpenB ::= AndExprB IMPLIES ImpliesExprB { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expr",22, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case206( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 157: // Exprp ::= Exprp COMMA Expr + case 205: // ImpliesExprOpenB ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprOpenB { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - a.add(b); RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprp",28, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case205( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 156: // Exprp ::= Expr + case 204: // ImpliesExprCloseB ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprCloseB { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprp",28, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case204( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 155: // Exprs ::= Exprp + case 203: // ImpliesExprCloseB ::= AndExprB { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List x = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprs",27, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case203( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 154: // Exprs ::= + case 202: // ImpliesExprB ::= ImpliesExprOpenB { - List RESULT =null; - RESULT=new ArrayList(); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprs",27, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case202( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 153: // SuperOrBar ::= Super + case 201: // ImpliesExprB ::= ImpliesExprCloseB { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOrBar",26, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case201( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 152: // SuperOrBar ::= BAR Expr + case 200: // ImpliesExprOpenA ::= AndExprB IMPLIES Bind { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOrBar",26, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case200( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 151: // SuperP ::= SuperP Expr + case 199: // ImpliesExprCloseA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE Bind { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprBinary.Op.AND.make(null, null, a, b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperP",25, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case199( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 150: // SuperP ::= Expr + case 198: // ImpliesExprOpenA ::= AndExprB IMPLIES ImpliesExprA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperP",25, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case198( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 149: // Super ::= LBRACE RBRACE + case 197: // ImpliesExprOpenA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprOpenA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprConstant.Op.TRUE.make(a.merge(b), 0); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Super",23, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case197( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 148: // Super ::= LBRACE SuperP RBRACE + case 196: // ImpliesExprCloseA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprCloseA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprUnary.Op.NOOP.make(a.merge(b), x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Super",23, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case196( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 147: // SuperOpt ::= Super + case 195: // ImpliesExprCloseA ::= AndExprA { - Expr RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOpt",24, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case195( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 146: // SuperOpt ::= + case 194: // ImpliesExprA ::= ImpliesExprOpenA { - Expr RESULT =null; - RESULT=null; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOpt",24, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case194( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 145: // Let ::= Name EQUALS Expr COMMA Let + case 193: // ImpliesExprA ::= ImpliesExprCloseA { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - nod(a); - if (a.label.indexOf('/')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'/\'"); - if (a.label.indexOf('@')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'@\'"); - RESULT = ExprLet.make(o, ExprVar.make(a.pos, a.label), b, x); + CUP$CompParser$result = case193( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Let",38, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 192: // EquivExprB ::= EquivExprB IFF ImpliesExprB + { + CUP$CompParser$result = case192( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 144: // Let ::= Name EQUALS Expr SuperOrBar + case 191: // EquivExprB ::= ImpliesExprB { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr x = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - nod(a); - if (a.label.indexOf('/')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'/\'"); - if (a.label.indexOf('@')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'@\'"); - RESULT = ExprLet.make(o, ExprVar.make(a.pos, a.label), b, x); + CUP$CompParser$result = case191( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Let",38, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 190: // EquivExprA ::= EquivExprB IFF Bind + { + CUP$CompParser$result = case190( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 143: // Decls ::= COMMA Decls + case 189: // EquivExprA ::= ImpliesExprA { - List RESULT =null; - int yleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int yright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List y = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=y; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case189( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 142: // Decls ::= Declb COMMA Decls + case 188: // OrExprB ::= OrExprB OR EquivExprB { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Decl x = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int yleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int yright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List y = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=y; RESULT.add(0,x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case188( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 141: // Decls ::= Declb + case 187: // OrExprB ::= EquivExprB { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Decl x = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case187( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 140: // Decls ::= + case 186: // OrExprA ::= OrExprB OR Bind { - List RESULT =null; - RESULT=new ArrayList(); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case186( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 139: // Declp ::= Declb + case 185: // OrExprA ::= EquivExprA { - List RESULT =null; - int yleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int yright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Decl y = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(y); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declp",12, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case185( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 138: // Declp ::= Declp COMMA Declb + case 184: // Bind ::= SUM2 Declp SuperOrBar { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List x = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int yleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int yright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Decl y = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; RESULT.add(y); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declp",12, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case184( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 137: // Declz ::= Decla + case 183: // Bind ::= ONE2 Declp SuperOrBar { - List RESULT =null; - int yleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int yright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Decl y = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(y); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declz",14, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case183( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 136: // Declz ::= Declz COMMA Decla + case 182: // Bind ::= LONE2 Declp SuperOrBar { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List x = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int yleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int yright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Decl y = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; RESULT.add(y); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declz",14, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case182( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 135: // Declb ::= Names EQUALS DISJ Expr + case 181: // Bind ::= SOME2 Declp SuperOrBar { - Decl RESULT =null; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case181( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 134: // Declb ::= PRIVATE Names EQUALS DISJ Expr + case 180: // Bind ::= NO2 Declp SuperOrBar { - Decl RESULT =null; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case180( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 133: // Declb ::= PRIVATE DISJ Names EQUALS DISJ Expr + case 179: // Bind ::= ALL2 Declp SuperOrBar { - Decl RESULT =null; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case179( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 132: // Declb ::= DISJ Names EQUALS DISJ Expr + case 178: // Bind ::= LET Let { - Decl RESULT =null; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case178( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 131: // Declb ::= EXH Names EQUALS DISJ Expr + case 177: // ExprNoSeq ::= Bind { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - if (1==1) throw CompModule.hint(k, "exh"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case177( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 130: // Declb ::= PART Names EQUALS DISJ Expr + case 176: // ExprNoSeq ::= OrExprB { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - if (1==1) throw CompModule.hint(k, "part"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case176( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 129: // Declb ::= Names EQUALS Expr + case 175: // ExprNoSeq ::= OrExprA { - Decl RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(null, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case175( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 128: // Declb ::= PRIVATE Names EQUALS Expr + case 174: // Expr ::= ExprNoSeq TRCSEQ Expr { - Decl RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(p, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case174( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 127: // Declb ::= PRIVATE DISJ Names EQUALS Expr + case 173: // Expr ::= ExprNoSeq { - Decl RESULT =null; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case173( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 126: // Declb ::= DISJ Names EQUALS Expr + case 172: // Exprp ::= Exprp COMMA Expr { - Decl RESULT =null; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case172( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 125: // Declb ::= EXH Names EQUALS Expr + case 171: // Exprp ::= Expr { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - if (1==1) throw CompModule.hint(k, "exh"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case171( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 124: // Declb ::= PART Names EQUALS Expr + case 170: // Exprs ::= Exprp { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - if (1==1) throw CompModule.hint(k, "part"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case170( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 123: // Declb ::= Decla + case 169: // Exprs ::= { - Decl RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Decl x = (Decl)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case169( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 122: // Decla ::= Names COLON DISJ Expr + case 168: // SuperOrBar ::= BAR ExprNoSeq TRCSEQ Expr { - Decl RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(null, null, d, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case168( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 121: // Decla ::= PRIVATE Names COLON DISJ Expr + case 167: // SuperOrBar ::= Super { - Decl RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(p, null, d, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case167( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 120: // Decla ::= PRIVATE DISJ Names COLON DISJ Expr + case 166: // SuperOrBar ::= BAR ExprNoSeq { - Decl RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(p, k, d, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case166( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 119: // Decla ::= DISJ Names COLON DISJ Expr + case 165: // SuperP ::= Expr TRCSEQ SuperP { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos d = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(null, k, d, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case165( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 118: // Decla ::= EXH Names COLON DISJ Expr + case 164: // SuperP ::= SuperP Expr { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - if (1==1) throw CompModule.hint(k, "exh"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case164( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 117: // Decla ::= PART Names COLON DISJ Expr + case 163: // SuperP ::= Expr { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - if (1==1) throw CompModule.hint(k, "part"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case163( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 116: // Decla ::= Names COLON Expr + case 162: // Super ::= LBRACE RBRACE { - Decl RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(null, null, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case162( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 115: // Decla ::= PRIVATE Names COLON Expr + case 161: // Super ::= LBRACE SuperP RBRACE { - Decl RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(p, null, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case161( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 114: // Decla ::= PRIVATE DISJ Names COLON Expr + case 160: // SuperOpt ::= Super { - Decl RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(p, k, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case160( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 113: // Decla ::= DISJ Names COLON Expr + case 159: // SuperOpt ::= { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr b = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new Decl(null, k, null, a, mult(b)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case159( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 112: // Decla ::= EXH Names COLON Expr + case 158: // Let ::= Name EQUALS Expr COMMA Let { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - if (1==1) throw CompModule.hint(k, "exh"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case158( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 111: // Decla ::= PART Names COLON Expr + case 157: // Let ::= Name EQUALS Expr SuperOrBar { - Decl RESULT =null; - int kleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int kright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos k = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - if (1==1) throw CompModule.hint(k, "part"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case157( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 110: // Namex ::= Namex COMMA EXACTLY Name + case 156: // Decls ::= COMMA Decls { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(b); a.add(null); a.add(b); RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case156( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 109: // Namex ::= Namex COMMA Name + case 155: // Decls ::= Declb COMMA Decls { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(b); a.add(b); RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case155( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 108: // Namex ::= EXACTLY Name + case 154: // Decls ::= Declb { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(x); RESULT=new ArrayList(); RESULT.add(null); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case154( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 107: // Namex ::= Name + case 153: // Decls ::= { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(x); RESULT=new ArrayList(); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case153( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 106: // Names ::= Names COMMA Name + case 152: // Declp ::= Declb { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(b); a.add(b); RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Names",43, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case152( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 105: // Names ::= Name + case 151: // Declp ::= Declp COMMA Declb { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(x); RESULT=new ArrayList(); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Names",43, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case151( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 104: // NameHelper ::= NameHelper SLASH ID + case 150: // Declz ::= Decla { - ExprVar RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(a.pos.merge(b.pos), a.label+"/"+b.label); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NameHelper",42, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case150( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 103: // NameHelper ::= ID + case 149: // Declz ::= Declz COMMA Decla { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NameHelper",42, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case149( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 102: // Name ::= SEQ SLASH NameHelper + case 148: // Declb ::= Names EQUALS DISJ Expr { - ExprVar RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(a.merge(b.pos), "seq/"+b.label); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Name",41, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case148( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 101: // Name ::= THIS SLASH NameHelper + case 147: // Declb ::= PRIVATE Names EQUALS DISJ Expr { - ExprVar RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(a.merge(b.pos), "this/"+b.label); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Name",41, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case147( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 100: // Name ::= NameHelper + case 146: // Declb ::= PRIVATE DISJ Names EQUALS DISJ Expr { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Name",41, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case146( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 99: // SigRefu ::= SigRefu PLUS SigRef + case 145: // Declb ::= DISJ Names EQUALS DISJ Expr { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - a.add(b); RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefu",67, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case145( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 98: // SigRefu ::= SigRef + case 144: // Declb ::= EXH Names EQUALS DISJ Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefu",67, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case144( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 97: // SigRefp ::= SigRefp COMMA SigRef + case 143: // Declb ::= PART Names EQUALS DISJ Expr { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - a.add(b); RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefp",65, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case143( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 96: // SigRefp ::= SigRef + case 142: // Declb ::= Names EQUALS Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefp",65, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case142( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 95: // SigRefs ::= SigRefp + case 141: // Declb ::= PRIVATE Names EQUALS Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List x = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefs",66, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case141( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 94: // SigRefs ::= + case 140: // Declb ::= PRIVATE DISJ Names EQUALS Expr { - List RESULT =null; - RESULT=new ArrayList(); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefs",66, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case140( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 93: // SigRef ::= NONE + case 139: // Declb ::= DISJ Names EQUALS Expr { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(x, "none"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case139( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 92: // SigRef ::= SEQ SLASH SIGINT + case 138: // Declb ::= EXH Names EQUALS Expr { - ExprVar RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(a.merge(b), "seq/Int"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case138( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 91: // SigRef ::= SIGINT + case 137: // Declb ::= PART Names EQUALS Expr { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(x, "Int"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case137( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 90: // SigRef ::= STRING + case 136: // Declb ::= Decla { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(x, "String"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case136( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 89: // SigRef ::= UNIV + case 135: // Decla ::= VAR Names COLON DISJ Expr { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=ExprVar.make(x, "univ"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case135( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 88: // SigRef ::= Name + case 134: // Decla ::= VAR PRIVATE Names COLON DISJ Expr { - ExprVar RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case134( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 87: // SigIn ::= + case 133: // Decla ::= VAR PRIVATE DISJ Names COLON DISJ Expr { - List RESULT =null; - RESULT=null; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case133( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 86: // SigIn ::= EQUALS SigRefu + case 132: // Decla ::= VAR DISJ Names COLON DISJ Expr { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List x = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; x.add(ExprVar.make(a,"=")); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case132( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 85: // SigIn ::= IN SigRefu + case 131: // Decla ::= Names COLON DISJ Expr { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List x = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=x; x.add(ExprVar.make(a,"in")); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case131( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 84: // SigIn ::= EXTENDS SigRef + case 130: // Decla ::= PRIVATE Names COLON DISJ Expr { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos a = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(2); RESULT.add(x); RESULT.add(ExprVar.make(a, "extends")); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case130( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 83: // SigQuals ::= SigQual SigQuals + case 129: // Decla ::= PRIVATE DISJ Names COLON DISJ Expr { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; for(int i=0;i<5;i++) if (a.get(i)==null) a.set(i,b.get(i)); else if (b.get(i)!=null) throw new ErrorSyntax(b.get(i), "The same qualifer cannot be specified more than once for the same sig."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQuals",63, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case129( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 82: // SigQuals ::= SIG + case 128: // Decla ::= DISJ Names COLON DISJ Expr { - List RESULT =null; - RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQuals",63, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case128( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 81: // SigQual ::= PRIVATE + case 127: // Decla ::= EXH Names COLON DISJ Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case127( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 80: // SigQual ::= SOME + case 126: // Decla ::= PART Names COLON DISJ Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case126( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 79: // SigQual ::= ONE + case 125: // Decla ::= VAR Names COLON Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case125( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 78: // SigQual ::= LONE + case 124: // Decla ::= VAR PRIVATE Names COLON Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(5); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case124( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 77: // SigQual ::= ABSTRACT + case 123: // Decla ::= VAR PRIVATE DISJ Names COLON Expr { - List RESULT =null; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos x = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(5); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case123( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 76: // Sig ::= SigQuals Names SigIn LBRACE Decls RBRACE SuperOpt + case 122: // Decla ::= VAR DISJ Names COLON Expr { - Object RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - List c = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - if (e==null) e = ExprConstant.Op.TRUE.make(o, 0); - ExprVar cc = (c!=null && c.size()>0) ? c.remove(c.size()-1) : null; - for(ExprVar bb:b) { - parser.alloymodule.addSig(bb.label, cc, c, d, e, - AttrType.WHERE .makenull(bb.pos.merge(e==null ? o : e.span())), - AttrType.ABSTRACT.makenull(a.get(0)), - AttrType.LONE .makenull(a.get(1)), - AttrType.ONE .makenull(a.get(2)), - AttrType.SOME .makenull(a.get(3)), - AttrType.PRIVATE .makenull(a.get(4))); - } - - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Sig",60, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case122( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 75: // Vis ::= PRIVATE + case 121: // Decla ::= Names COLON Expr { - Pos RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=p; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Vis",81, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case121( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 74: // Vis ::= + case 120: // Decla ::= PRIVATE Names COLON Expr { - Pos RESULT =null; - RESULT=null; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Vis",81, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case120( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 73: // Predicate ::= Vis PRED SigRef DOT Name Super + case 119: // Decla ::= PRIVATE DISJ Names COLON Expr { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar f = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , null , null, v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case119( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 72: // Predicate ::= Vis PRED SigRef DOT Name LBRACKET Decls RBRACKET Super + case 118: // Decla ::= DISJ Names COLON Expr { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - ExprVar f = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , null, v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case118( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 71: // Predicate ::= Vis PRED SigRef DOT Name LPAREN Decls RPAREN Super + case 117: // Decla ::= EXH Names COLON Expr { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - ExprVar f = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , null, v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } + CUP$CompParser$result = case117( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 70: // Predicate ::= Vis PRED Name Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, null , null, v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 69: // Predicate ::= Vis PRED Name LBRACKET Decls RBRACKET Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , null, v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 68: // Predicate ::= Vis PRED Name LPAREN Decls RPAREN Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , null, v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 67: // Function ::= Vis FUN SigRef DOT Name COLON Expr Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - ExprVar f = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr r = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , null , mult(r), v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 66: // Function ::= Vis FUN SigRef DOT Name LBRACKET Decls RBRACKET COLON Expr Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-9)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-9)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-9)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).right; - ExprVar f = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr r = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , mult(r), v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 65: // Function ::= Vis FUN SigRef DOT Name LPAREN Decls RPAREN COLON Expr Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-9)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-9)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-9)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).right; - ExprVar f = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr r = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , mult(r), v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-10)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 64: // Function ::= Vis FUN Name COLON Expr Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr r = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, null , mult(r), v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 63: // Function ::= Vis FUN Name LBRACKET Decls RBRACKET COLON Expr Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr r = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , mult(r), v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 62: // Function ::= Vis FUN Name LPAREN Decls RPAREN COLON Expr Super - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Expr r = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , mult(r), v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 61: // MacroBody ::= EQUALS Expr - { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MacroBody",40, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 60: // MacroBody ::= Super + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 116: // Decla ::= PART Names COLON Expr { - Expr RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr a = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MacroBody",40, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); - } - return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 59: // Macro ::= Vis LET Name MacroBody - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case116( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; - - /*. . . . . . . . . . . . . . . . . . . .*/ - case 58: // Macro ::= Vis LET Name LBRACKET RBRACKET MacroBody - { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 115: // Namex ::= Namex COMMA EXACTLY Name + { + CUP$CompParser$result = case115( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 57: // Macro ::= Vis LET Name LBRACKET Names RBRACKET MacroBody + case 114: // Namex ::= Namex COMMA Name { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, d , v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case114( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 56: // Macro ::= Vis LET Name LPAREN RPAREN MacroBody + case 113: // Namex ::= EXACTLY Name { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case113( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 55: // Macro ::= Vis LET Name LPAREN Names RPAREN MacroBody + case 112: // Namex ::= Name { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int dleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int dright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List d = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int vleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int vright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr v = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, d , v); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case112( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 54: // TypeNumber ::= NUMBER COLON NUMBER + case 111: // Names ::= Names COMMA Name { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int ileft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int iright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant i = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, false, a.num, Integer.MAX_VALUE, i.num); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case111( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 53: // TypeNumber ::= NUMBER DOT DOT NUMBER COLON NUMBER + case 110: // Names ::= Name { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprConstant b = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int ileft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int iright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant i = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, false, a.num, b.num, i.num); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case110( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 52: // TypeNumber ::= NUMBER DOT DOT NUMBER + case 109: // NameHelper ::= NameHelper SLASH ID { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant b = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(b.pos), Sig.NONE, false, a.num, b.num, 1 ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case109( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 51: // TypeNumber ::= NUMBER + case 108: // NameHelper ::= ID { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = new CommandScope(a.pos , Sig.NONE, false, a.num, a.num, 1 ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case108( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 50: // TypeNumber ::= EXACTLY NUMBER COLON NUMBER + case 107: // Name ::= SEQ SLASH NameHelper { - CommandScope RESULT =null; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos e = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int ileft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int iright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant i = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, Integer.MAX_VALUE, i.num); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case107( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 49: // TypeNumber ::= EXACTLY NUMBER DOT DOT NUMBER COLON NUMBER + case 106: // Name ::= THIS SLASH NameHelper { - CommandScope RESULT =null; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos e = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprConstant b = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int ileft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int iright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant i = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, b.num, i.num); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case106( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 48: // TypeNumber ::= EXACTLY NUMBER DOT DOT NUMBER + case 105: // Name ::= NameHelper { - CommandScope RESULT =null; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos e = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant b = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(b.pos), Sig.NONE, true, a.num, b.num, 1 ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case105( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 47: // TypeNumber ::= EXACTLY NUMBER + case 104: // SigRefu ::= SigRefu PLUS SigRef { - CommandScope RESULT =null; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos e = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = new CommandScope( e.merge(a.pos), Sig.NONE, true, a.num, a.num, 1 ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case104( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 46: // Typescope ::= TypeNumber NONE + case 103: // SigRefu ::= SigRef { - CommandScope RESULT =null; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope e = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos f = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (1==1) throw new ErrorSyntax(e.pos.merge(f), "You cannot set a scope on none."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case103( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 45: // Typescope ::= TypeNumber STRING + case 102: // SigRefp ::= SigRefp COMMA SigRef { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope a = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = new CommandScope(a.pos.merge(b), new PrimSig("String", AttrType.WHERE.make(a.pos.merge(b))), a.isExact, a.startingScope, a.endingScope, a.increment); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case102( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 44: // Typescope ::= TypeNumber UNIV + case 101: // SigRefp ::= SigRef { - CommandScope RESULT =null; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope e = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int fleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int fright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos f = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - if (1==1) throw new ErrorSyntax(e.pos.merge(f), "You cannot set a scope on univ."); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case101( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 43: // Typescope ::= TypeNumber SEQ + case 100: // SigRefs ::= SigRefp { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope a = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - Pos p = a.pos.merge(b); - if (a.endingScope>a.startingScope) throw new ErrorSyntax(p, "Cannot specify a growing scope for \"seq\""); - if (a.isExact) throw new ErrorSyntax(p, "The exactly keyword is redundant here since the number of sequence index has to be exact."); - RESULT = new CommandScope(p, new PrimSig("seq", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.startingScope, 1); + CUP$CompParser$result = case100( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 99: // SigRefs ::= + { + CUP$CompParser$result = case99( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 42: // Typescope ::= TypeNumber INT + case 98: // SigRef ::= NONE { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope a = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - Pos p = a.pos.merge(b); - if (a.endingScope>a.startingScope) throw new ErrorSyntax(p, "Cannot specify a growing scope for \"Int\""); - if (a.isExact) throw new ErrorSyntax(p, "The exactly keyword is redundant here since the integer bitwidth must be exact."); - RESULT = new CommandScope(p, new PrimSig("int", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.startingScope, 1); + CUP$CompParser$result = case98( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 97: // SigRef ::= SEQ SLASH SIGINT + { + CUP$CompParser$result = case97( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 41: // Typescope ::= TypeNumber SIGINT + case 96: // SigRef ::= SIGINT { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope a = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos b = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - Pos p = a.pos.merge(b); - if (a.endingScope>a.startingScope) throw new ErrorSyntax(p, "Cannot specify a growing scope for \"Int\""); - if (a.isExact) throw new ErrorSyntax(p, "The exactly keyword is redundant here since the integer bitwidth must be exact."); - RESULT = new CommandScope(p, new PrimSig("int", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.startingScope, 1); + CUP$CompParser$result = case96( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 95: // SigRef ::= TIME + { + CUP$CompParser$result = case95( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 40: // Typescope ::= TypeNumber Name + case 94: // SigRef ::= STRING { - CommandScope RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - CommandScope a = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar b = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - - nod(b); - RESULT = new CommandScope(a.pos.merge(b.pos), new PrimSig(b.label, AttrType.WHERE.make(a.pos.merge(b.pos))), a.isExact, a.startingScope, a.endingScope, a.increment); + CUP$CompParser$result = case94( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 93: // SigRef ::= UNIV + { + CUP$CompParser$result = case93( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 39: // Typescopes ::= Typescopes COMMA Typescope + case 92: // SigRef ::= Name { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - List a = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - CommandScope b = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; a.add(b); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescopes",72, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case92( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 38: // Typescopes ::= Typescope + case 91: // SigIn ::= { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - CommandScope a = (CommandScope)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(a); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescopes",72, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case91( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 37: // Scope ::= + case 90: // SigIn ::= EQUALS SigRefu { - List RESULT =null; - RESULT=new ArrayList(); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case90( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 36: // Scope ::= FOR Typescopes + case 89: // SigIn ::= IN SigRefu { - List RESULT =null; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case89( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 35: // Scope ::= FOR NUMBER BUT Typescopes + case 88: // SigIn ::= EXTENDS SigRef { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=b; b.add(new CommandScope(a.pos, new PrimSig("univ", AttrType.WHERE.make(a.pos)), true, a.num, a.num, 1)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case88( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 34: // Scope ::= FOR NUMBER + case 87: // SigQuals ::= SigQual SigQuals { - List RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=new ArrayList(); RESULT.add(new CommandScope(a.pos, new PrimSig("univ", AttrType.WHERE.make(a.pos)), true, a.num, a.num, 1)); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case87( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 33: // Expects ::= EXPECT NUMBER + case 86: // SigQuals ::= SIG { - ExprConstant RESULT =null; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant a = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT=a; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expects",21, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case86( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 32: // Expects ::= + case 85: // SigQual ::= VAR { - ExprConstant RESULT =null; - RESULT=null; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expects",21, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case85( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 31: // Command ::= Command IMPLIES CommandPrefix Name Scope Expects + case 84: // SigQual ::= PRIVATE { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(true ,o,null,n ,null,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case84( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 30: // Command ::= Command IMPLIES CommandPrefix Name Name Scope Expects + case 83: // SigQual ::= SOME { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(true ,o,x ,n ,null,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case83( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 29: // Command ::= CommandPrefix Name Scope Expects + case 82: // SigQual ::= ONE { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(false,o,null,n ,null,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case82( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 28: // Command ::= CommandPrefix Name Name Scope Expects + case 81: // SigQual ::= LONE { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(false,o,x ,n ,null,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case81( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 27: // Command ::= Command IMPLIES CommandPrefix Super Scope Expects + case 80: // SigQual ::= ABSTRACT { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(true ,o,null,null,e ,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case80( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 26: // Command ::= Command IMPLIES CommandPrefix Name Super Scope Expects + case 79: // Sig ::= SigQuals Names SigIn LBRACE Decls RBRACE SuperOpt { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(true ,o,x ,null,e ,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case79( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 25: // Command ::= CommandPrefix Super Scope Expects + case 78: // Vis ::= PRIVATE { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(false,o,null,null,e ,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case78( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 24: // Command ::= CommandPrefix Name Super Scope Expects + case 77: // Vis ::= { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - ExprVar o = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int xleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int xright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar x = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int sleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int sright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List s = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprConstant c = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - c(false,o,x ,null,e ,s,c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case77( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 23: // CommandPrefix ::= RUN + case 76: // Predicate ::= Vis PRED SigRef DOT Name Super { - ExprVar RESULT =null; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos r = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprVar.make(r, "r"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CommandPrefix",9, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case76( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 22: // CommandPrefix ::= CHECK + case 75: // Predicate ::= Vis PRED SigRef DOT Name LBRACKET Decls RBRACKET Super { - ExprVar RESULT =null; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - RESULT = ExprVar.make(c, "c"); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CommandPrefix",9, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case75( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 21: // Spec ::= + case 74: // Predicate ::= Vis PRED SigRef DOT Name LPAREN Decls RPAREN Super { - Object RESULT =null; + CUP$CompParser$result = case74( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 73: // Predicate ::= Vis PRED Name Super + { + CUP$CompParser$result = case73( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 20: // Spec ::= Spec Command + case 72: // Predicate ::= Vis PRED Name LBRACKET Decls RBRACKET Super { - Object RESULT =null; + CUP$CompParser$result = case72( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 71: // Predicate ::= Vis PRED Name LPAREN Decls RPAREN Super + { + CUP$CompParser$result = case71( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 19: // Spec ::= Spec Macro + case 70: // Function ::= Vis FUN SigRef DOT Name COLON Expr Super { - Object RESULT =null; + CUP$CompParser$result = case70( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 69: // Function ::= Vis FUN SigRef DOT Name LBRACKET Decls RBRACKET COLON Expr Super + { + CUP$CompParser$result = case69( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 18: // Spec ::= Spec Predicate + case 68: // Function ::= Vis FUN SigRef DOT Name LPAREN Decls RPAREN COLON Expr Super { - Object RESULT =null; + CUP$CompParser$result = case68( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 67: // Function ::= Vis FUN Name COLON Expr Super + { + CUP$CompParser$result = case67( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 17: // Spec ::= Spec Function + case 66: // Function ::= Vis FUN Name LBRACKET Decls RBRACKET COLON Expr Super { - Object RESULT =null; + CUP$CompParser$result = case66( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 65: // Function ::= Vis FUN Name LPAREN Decls RPAREN COLON Expr Super + { + CUP$CompParser$result = case65( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 16: // Spec ::= Spec Sig + case 64: // MacroBody ::= EQUALS Expr { - Object RESULT =null; + CUP$CompParser$result = case64( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 63: // MacroBody ::= Super + { + CUP$CompParser$result = case63( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 15: // Spec ::= Spec ASSERT STR Super + case 62: // Macro ::= Vis LET Name MacroBody { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprConstant n = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - parser.alloymodule.addAssertion (o , n.string , e); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case62( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 14: // Spec ::= Spec ASSERT Name Super + case 61: // Macro ::= Vis LET Name LBRACKET RBRACKET MacroBody { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addAssertion (o , n.label , e); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case61( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 13: // Spec ::= Spec ASSERT Super + case 60: // Macro ::= Vis LET Name LBRACKET Names RBRACKET MacroBody { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - parser.alloymodule.addAssertion (o , "" , e); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case60( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 12: // Spec ::= Spec FACT STR Super + case 59: // Macro ::= Vis LET Name LPAREN RPAREN MacroBody { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprConstant n = (ExprConstant)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - parser.alloymodule.addFact (o , n.string , e); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case59( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 11: // Spec ::= Spec FACT Name Super + case 58: // Macro ::= Vis LET Name LPAREN Names RPAREN MacroBody { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addFact (o , n.label , e); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case58( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 10: // Spec ::= Spec FACT Super + case 57: // TypeNumber ::= NUMBER COLON NUMBER { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int eleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int eright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Expr e = (Expr)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - parser.alloymodule.addFact (o , "" , e); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case57( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 9: // Spec ::= Spec Vis ENUM Name LBRACE RBRACE + case 56: // TypeNumber ::= NUMBER DOT DOT NUMBER COLON NUMBER { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(a); parser.alloymodule.addEnum(o.merge(c), p, a, null, c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case56( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 8: // Spec ::= Spec Vis ENUM Name LBRACE Names RBRACE + case 55: // TypeNumber ::= NUMBER DOT DOT { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List n = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(a); parser.alloymodule.addEnum(o.merge(c), p, a, n, c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case55( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 7: // Spec ::= Spec Vis OPEN Name LBRACKET SigRefs RBRACKET AS Name + case 54: // TypeNumber ::= NUMBER DOT DOT NUMBER { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar c = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(a); nod(c); parser.alloymodule.addOpen(o.merge(c.pos), p, a, b, c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-8)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case54( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 6: // Spec ::= Spec Vis OPEN Name LBRACKET SigRefs RBRACKET + case 53: // TypeNumber ::= NUMBER { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos c = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(a); parser.alloymodule.addOpen(o.merge(c), p, a, b, null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-6)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case53( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 5: // Spec ::= Spec Vis OPEN Name AS Name + case 52: // TypeNumber ::= EXACTLY NUMBER COLON NUMBER { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int cleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int cright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar c = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(a); nod(c); parser.alloymodule.addOpen(o.merge(c.pos), p, a, null, c); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case52( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 4: // Spec ::= Spec Vis OPEN Name + case 51: // TypeNumber ::= EXACTLY NUMBER DOT DOT NUMBER COLON NUMBER { - Object RESULT =null; - int pleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).left; - int pright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).right; - Pos p = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)).value; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int aleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int aright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar a = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(a); parser.alloymodule.addOpen(o.merge(a.pos), p, a, null, null); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case51( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 3: // Spec ::= Spec MODULE Name LBRACKET Namex RBRACKET + case 50: // TypeNumber ::= EXACTLY NUMBER DOT DOT { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3)).value; - int bleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int bright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - List b = (List)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int rleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int rright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - Pos r = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); nod(b); parser.alloymodule.addModelName(o.merge(r) , n.label , b ); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-5)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case50( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 2: // Spec ::= Spec MODULE Name + case 49: // TypeNumber ::= EXACTLY NUMBER DOT DOT NUMBER { - Object RESULT =null; - int oleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int oright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Pos o = (Pos)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - int nleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).left; - int nright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()).right; - ExprVar n = (ExprVar)((java_cup.runtime.Symbol) CUP$CompParser$stack.peek()).value; - nod(n); parser.alloymodule.addModelName(o.merge(n.pos) , n.label , new ArrayList()); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-2)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case49( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 1: // $START ::= File EOF + case 48: // TypeNumber ::= EXACTLY NUMBER { - Object RESULT =null; - int start_valleft = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).left; - int start_valright = ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).right; - Object start_val = (Object)((java_cup.runtime.Symbol) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)).value; - RESULT = start_val; - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("$START",0, ((java_cup.runtime.Symbol)CUP$CompParser$stack.elementAt(CUP$CompParser$top-1)), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case48( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } - /* ACCEPT */ - CUP$CompParser$parser.done_parsing(); return CUP$CompParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 0: // File ::= Spec + case 47: // Typescope ::= TypeNumber NONE { - Object RESULT =null; - parser.alloymodule.doneParsing(); - CUP$CompParser$result = parser.getSymbolFactory().newSymbol("File",68, ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), ((java_cup.runtime.Symbol)CUP$CompParser$stack.peek()), RESULT); + CUP$CompParser$result = case47( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); } return CUP$CompParser$result; - /* . . . . . .*/ - default: - throw new Exception( - "Invalid action number found in internal parse table"); + /*. . . . . . . . . . . . . . . . . . . .*/ + case 46: // Typescope ::= TypeNumber TIME + { + CUP$CompParser$result = case46( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 45: // Typescope ::= TypeNumber STRING + { + CUP$CompParser$result = case45( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 44: // Typescope ::= TypeNumber UNIV + { + CUP$CompParser$result = case44( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 43: // Typescope ::= TypeNumber SEQ + { + CUP$CompParser$result = case43( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 42: // Typescope ::= TypeNumber INT + { + CUP$CompParser$result = case42( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 41: // Typescope ::= TypeNumber SIGINT + { + CUP$CompParser$result = case41( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 40: // Typescope ::= TypeNumber Name + { + CUP$CompParser$result = case40( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 39: // Typescopes ::= Typescopes COMMA Typescope + { + CUP$CompParser$result = case39( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 38: // Typescopes ::= Typescope + { + CUP$CompParser$result = case38( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 37: // Scope ::= + { + CUP$CompParser$result = case37( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 36: // Scope ::= FOR Typescopes + { + CUP$CompParser$result = case36( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 35: // Scope ::= FOR NUMBER BUT Typescopes + { + CUP$CompParser$result = case35( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 34: // Scope ::= FOR NUMBER + { + CUP$CompParser$result = case34( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 33: // Expects ::= EXPECT NUMBER + { + CUP$CompParser$result = case33( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 32: // Expects ::= + { + CUP$CompParser$result = case32( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 31: // Command ::= Command IMPLIES CommandPrefix Name Scope Expects + { + CUP$CompParser$result = case31( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 30: // Command ::= Command IMPLIES CommandPrefix Name Name Scope Expects + { + CUP$CompParser$result = case30( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 29: // Command ::= CommandPrefix Name Scope Expects + { + CUP$CompParser$result = case29( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 28: // Command ::= CommandPrefix Name Name Scope Expects + { + CUP$CompParser$result = case28( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 27: // Command ::= Command IMPLIES CommandPrefix Super Scope Expects + { + CUP$CompParser$result = case27( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 26: // Command ::= Command IMPLIES CommandPrefix Name Super Scope Expects + { + CUP$CompParser$result = case26( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 25: // Command ::= CommandPrefix Super Scope Expects + { + CUP$CompParser$result = case25( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 24: // Command ::= CommandPrefix Name Super Scope Expects + { + CUP$CompParser$result = case24( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 23: // CommandPrefix ::= RUN + { + CUP$CompParser$result = case23( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 22: // CommandPrefix ::= CHECK + { + CUP$CompParser$result = case22( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 21: // Spec ::= + { + CUP$CompParser$result = case21( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 20: // Spec ::= Spec Command + { + CUP$CompParser$result = case20( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 19: // Spec ::= Spec Macro + { + CUP$CompParser$result = case19( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 18: // Spec ::= Spec Predicate + { + CUP$CompParser$result = case18( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 17: // Spec ::= Spec Function + { + CUP$CompParser$result = case17( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 16: // Spec ::= Spec Sig + { + CUP$CompParser$result = case16( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 15: // Spec ::= Spec ASSERT STR Super + { + CUP$CompParser$result = case15( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 14: // Spec ::= Spec ASSERT Name Super + { + CUP$CompParser$result = case14( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // Spec ::= Spec ASSERT Super + { + CUP$CompParser$result = case13( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // Spec ::= Spec FACT STR Super + { + CUP$CompParser$result = case12( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // Spec ::= Spec FACT Name Super + { + CUP$CompParser$result = case11( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // Spec ::= Spec FACT Super + { + CUP$CompParser$result = case10( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // Spec ::= Spec Vis ENUM Name LBRACE RBRACE + { + CUP$CompParser$result = case9( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // Spec ::= Spec Vis ENUM Name LBRACE Names RBRACE + { + CUP$CompParser$result = case8( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // Spec ::= Spec Vis OPEN Name LBRACKET SigRefs RBRACKET AS Name + { + CUP$CompParser$result = case7( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // Spec ::= Spec Vis OPEN Name LBRACKET SigRefs RBRACKET + { + CUP$CompParser$result = case6( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // Spec ::= Spec Vis OPEN Name AS Name + { + CUP$CompParser$result = case5( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // Spec ::= Spec Vis OPEN Name + { + CUP$CompParser$result = case4( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // Spec ::= Spec MODULE Name LBRACKET Namex RBRACKET + { + CUP$CompParser$result = case3( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // Spec ::= Spec MODULE Name + { + CUP$CompParser$result = case2( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // $START ::= File EOF + { + CUP$CompParser$result = case1( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + /* ACCEPT */ + CUP$CompParser$parser.done_parsing(); + return CUP$CompParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // File ::= Spec + { + CUP$CompParser$result = case0( + CUP$CompParser$act_num, + CUP$CompParser$parser, + CUP$CompParser$stack, + CUP$CompParser$top); + } + return CUP$CompParser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + }/*1*/ + //BaseExpr ::= LBRACE Declz RBRACE + java_cup.runtime.Symbol case397( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.COMPREHENSION.make(o, c, a, ExprConstant.TRUE); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= LBRACE Declz SuperOrBar RBRACE + java_cup.runtime.Symbol case396( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.COMPREHENSION.make(o, c, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= Super + java_cup.runtime.Symbol case395( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= AT Name + java_cup.runtime.Symbol case394( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + nod(x); RESULT = ExprVar.make(o.merge(x.pos), "@"+x.label); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= SigRef + java_cup.runtime.Symbol case393( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= LPAREN Expr RPAREN + java_cup.runtime.Symbol case392( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr x = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= INTNEXT + java_cup.runtime.Symbol case391( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprConstant.Op.NEXT.make(o, 0); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= INTMAX + java_cup.runtime.Symbol case390( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprConstant.Op.MAX.make(o, 0); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= INTMIN + java_cup.runtime.Symbol case389( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprConstant.Op.MIN.make(o, 0); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= THIS + java_cup.runtime.Symbol case388( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprVar.make(o, "this"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= IDEN + java_cup.runtime.Symbol case387( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprVar.make(o, "iden"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= STR + java_cup.runtime.Symbol case386( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprConstant x = (ExprConstant) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BaseExpr ::= NUMBER + java_cup.runtime.Symbol case385( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprConstant x = (ExprConstant) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BaseExpr",2, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprB ::= UnopExprB PRIME + java_cup.runtime.Symbol case384( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.PRIME .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= UnopExprA PRIME + java_cup.runtime.Symbol case383( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.PRIME .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= Bind PRIME + java_cup.runtime.Symbol case382( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.PRIME .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprB ::= CARET UnopExprB + java_cup.runtime.Symbol case381( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CLOSURE .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprB ::= STAR UnopExprB + java_cup.runtime.Symbol case380( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.RCLOSURE .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprB ::= TILDE UnopExprB + java_cup.runtime.Symbol case379( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprB ::= BaseExpr + java_cup.runtime.Symbol case378( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprB",80, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= CARET UnopExprA + java_cup.runtime.Symbol case377( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CLOSURE .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= STAR UnopExprA + java_cup.runtime.Symbol case376( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.RCLOSURE .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= TILDE UnopExprA + java_cup.runtime.Symbol case375( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= CARET Bind + java_cup.runtime.Symbol case374( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CLOSURE .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= STAR Bind + java_cup.runtime.Symbol case373( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.RCLOSURE .make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnopExprA ::= TILDE Bind + java_cup.runtime.Symbol case372( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.TRANSPOSE.make(o,b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnopExprA",79, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprB ::= BracketExprB DOT SUM + java_cup.runtime.Symbol case371( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, a)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprB ::= BracketExprB DOT INT + java_cup.runtime.Symbol case370( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, a)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprB ::= BracketExprB DOT TOTALORDER + java_cup.runtime.Symbol case369( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + RESULT=t(o, null, a, ExprVar.make(b, "pred/totalOrder"), null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprB ::= BracketExprB DOT DISJ + java_cup.runtime.Symbol case368( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + RESULT=t(o, null, a, ExprVar.make(b, "disj"), null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprB ::= BracketExprB DOT UnopExprB + java_cup.runtime.Symbol case367( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=t(o, null, a, b, null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprB ::= UnopExprB + java_cup.runtime.Symbol case366( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprB",18, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprA ::= BracketExprB DOT Bind + java_cup.runtime.Symbol case365( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=t(o, null, a, b, null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprA",17, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DotExprA ::= UnopExprA + java_cup.runtime.Symbol case364( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DotExprA",17, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprB ::= SUM LBRACKET Exprs RBRACKET + java_cup.runtime.Symbol case363( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + Expr aa=ExprVar.make(a, "int"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=ExprUnary.Op.CAST2SIGINT.make(a, aa); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprB ::= INT LBRACKET Exprs RBRACKET + java_cup.runtime.Symbol case362( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + Expr aa=ExprVar.make(a, "int"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=ExprUnary.Op.CAST2SIGINT.make(a, aa); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprB ::= TOTALORDER LBRACKET Exprs RBRACKET + java_cup.runtime.Symbol case361( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + Expr aa=ExprVar.make(a, "pred/totalOrder"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=aa; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprB ::= DISJ LBRACKET Exprs RBRACKET + java_cup.runtime.Symbol case360( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + Expr aa=ExprVar.make(a, "disj"); for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=aa; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprB ::= BracketExprB LBRACKET Exprs RBRACKET + java_cup.runtime.Symbol case359( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + Expr aa=a; for(Expr bb:b) aa=t(aa.span().merge(bb.span()), c, bb, aa, c); RESULT=aa; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprB ::= DotExprB + java_cup.runtime.Symbol case358( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprB",5, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //BracketExprA ::= DotExprA + java_cup.runtime.Symbol case357( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("BracketExprA",4, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RangeExprB ::= RangeExprB RANGE BracketExprB + java_cup.runtime.Symbol case356( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.RANGE.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprB",55, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RangeExprB ::= BracketExprB + java_cup.runtime.Symbol case355( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprB",55, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RangeExprA ::= RangeExprB RANGE Bind + java_cup.runtime.Symbol case354( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.RANGE.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprA",54, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RangeExprA ::= BracketExprA + java_cup.runtime.Symbol case353( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RangeExprA",54, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DomainExprB ::= DomainExprB DOMAIN RangeExprB + java_cup.runtime.Symbol case352( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.DOMAIN.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprB",16, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DomainExprB ::= RangeExprB + java_cup.runtime.Symbol case351( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprB",16, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DomainExprA ::= DomainExprB DOMAIN Bind + java_cup.runtime.Symbol case350( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.DOMAIN.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprA",15, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //DomainExprA ::= RangeExprA + java_cup.runtime.Symbol case349( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("DomainExprA",15, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelationExprB ::= DomainExprB RelOp RelationExprB + java_cup.runtime.Symbol case348( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pair o = (Pair) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=o.b.make(o.a, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprB",58, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelationExprB ::= DomainExprB + java_cup.runtime.Symbol case347( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprB",58, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelationExprA ::= DomainExprB RelOp Bind + java_cup.runtime.Symbol case346( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pair o = (Pair) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=o.b.make(o.a, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprA",57, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelationExprA ::= DomainExprA + java_cup.runtime.Symbol case345( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelationExprA",57, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= LONE_ARROW_LONE + java_cup.runtime.Symbol case344( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_LONE); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= LONE_ARROW_ONE + java_cup.runtime.Symbol case343( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_ONE ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= LONE_ARROW_SOME + java_cup.runtime.Symbol case342( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_SOME); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= LONE_ARROW_ANY + java_cup.runtime.Symbol case341( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.LONE_ARROW_ANY ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ONE_ARROW_LONE + java_cup.runtime.Symbol case340( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_LONE ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ONE_ARROW_ONE + java_cup.runtime.Symbol case339( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_ONE ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ONE_ARROW_SOME + java_cup.runtime.Symbol case338( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_SOME ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ONE_ARROW_ANY + java_cup.runtime.Symbol case337( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ONE_ARROW_ANY ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= SOME_ARROW_LONE + java_cup.runtime.Symbol case336( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_LONE); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= SOME_ARROW_ONE + java_cup.runtime.Symbol case335( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_ONE ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= SOME_ARROW_SOME + java_cup.runtime.Symbol case334( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_SOME); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= SOME_ARROW_ANY + java_cup.runtime.Symbol case333( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.SOME_ARROW_ANY ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ANY_ARROW_LONE + java_cup.runtime.Symbol case332( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ANY_ARROW_LONE ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ANY_ARROW_ONE + java_cup.runtime.Symbol case331( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ANY_ARROW_ONE ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ANY_ARROW_SOME + java_cup.runtime.Symbol case330( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ANY_ARROW_SOME ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //RelOp ::= ARROW + java_cup.runtime.Symbol case329( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pair RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.peek().left; + int oright = CUP$CompParser$stack.peek().right; + Pos o = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new Pair(o, ExprBinary.Op.ARROW ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("RelOp",56, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //IntersectExprB ::= IntersectExprB AMPERSAND RelationExprB + java_cup.runtime.Symbol case328( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.INTERSECT.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprB",37, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //IntersectExprB ::= RelationExprB + java_cup.runtime.Symbol case327( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprB",37, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //IntersectExprA ::= IntersectExprB AMPERSAND Bind + java_cup.runtime.Symbol case326( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.INTERSECT.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprA",36, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //IntersectExprA ::= RelationExprA + java_cup.runtime.Symbol case325( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("IntersectExprA",36, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OverrideExprB ::= OverrideExprB PLUSPLUS IntersectExprB + java_cup.runtime.Symbol case324( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.PLUSPLUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprB",52, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OverrideExprB ::= IntersectExprB + java_cup.runtime.Symbol case323( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprB",52, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OverrideExprA ::= OverrideExprB PLUSPLUS Bind + java_cup.runtime.Symbol case322( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.PLUSPLUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprA",51, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OverrideExprA ::= IntersectExprA + java_cup.runtime.Symbol case321( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OverrideExprA",51, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprB ::= INT NumUnopExprB + java_cup.runtime.Symbol case320( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprB ::= SUM NumUnopExprB + java_cup.runtime.Symbol case319( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprB ::= HASH NumUnopExprB + java_cup.runtime.Symbol case318( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CARDINALITY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprB ::= OverrideExprB + java_cup.runtime.Symbol case317( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprB",48, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= INT NumUnopExprA + java_cup.runtime.Symbol case316( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= SUM NumUnopExprA + java_cup.runtime.Symbol case315( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= HASH NumUnopExprA + java_cup.runtime.Symbol case314( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CARDINALITY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= INT Bind + java_cup.runtime.Symbol case313( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= SUM Bind + java_cup.runtime.Symbol case312( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CAST2SIGINT.make(o, ExprUnary.Op.CAST2INT.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= HASH Bind + java_cup.runtime.Symbol case311( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.CARDINALITY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NumUnopExprA ::= OverrideExprA + java_cup.runtime.Symbol case310( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NumUnopExprA",47, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprB ::= MulExprB INTREM NumUnopExprB + java_cup.runtime.Symbol case309( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.REM .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprB ::= MulExprB INTDIV NumUnopExprB + java_cup.runtime.Symbol case308( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.DIV .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprB ::= MulExprB INTMUL NumUnopExprB + java_cup.runtime.Symbol case307( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.MUL .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprB ::= NumUnopExprB + java_cup.runtime.Symbol case306( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprB",76, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprA ::= MulExprB INTREM Bind + java_cup.runtime.Symbol case305( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.REM .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprA ::= MulExprB INTDIV Bind + java_cup.runtime.Symbol case304( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.DIV .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprA ::= MulExprB INTMUL Bind + java_cup.runtime.Symbol case303( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.MUL .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MulExprA ::= NumUnopExprA + java_cup.runtime.Symbol case302( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MulExprA",75, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprB ::= UnionDiffExprB INTSUB MulExprB + java_cup.runtime.Symbol case301( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IMINUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprB ::= UnionDiffExprB INTADD MulExprB + java_cup.runtime.Symbol case300( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IPLUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprB ::= UnionDiffExprB MINUS MulExprB + java_cup.runtime.Symbol case299( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.MINUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprB ::= UnionDiffExprB PLUS MulExprB + java_cup.runtime.Symbol case298( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.PLUS .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprB ::= MulExprB + java_cup.runtime.Symbol case297( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprB",78, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprA ::= UnionDiffExprB INTSUB Bind + java_cup.runtime.Symbol case296( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IMINUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprA ::= UnionDiffExprB INTADD Bind + java_cup.runtime.Symbol case295( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IPLUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprA ::= UnionDiffExprB MINUS Bind + java_cup.runtime.Symbol case294( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.MINUS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprA ::= UnionDiffExprB PLUS Bind + java_cup.runtime.Symbol case293( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.PLUS .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnionDiffExprA ::= MulExprA + java_cup.runtime.Symbol case292( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnionDiffExprA",77, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprB ::= ShiftExprB SHA UnionDiffExprB + java_cup.runtime.Symbol case291( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SHA.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprB ::= ShiftExprB SHR UnionDiffExprB + java_cup.runtime.Symbol case290( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SHR.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprB ::= ShiftExprB SHL UnionDiffExprB + java_cup.runtime.Symbol case289( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SHL.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprB ::= UnionDiffExprB + java_cup.runtime.Symbol case288( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprB",74, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprA ::= ShiftExprB SHA Bind + java_cup.runtime.Symbol case287( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SHA.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprA ::= ShiftExprB SHR Bind + java_cup.runtime.Symbol case286( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SHR.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprA ::= ShiftExprB SHL Bind + java_cup.runtime.Symbol case285( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SHL.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ShiftExprA ::= UnionDiffExprA + java_cup.runtime.Symbol case284( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ShiftExprA",73, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= ShiftExprB + java_cup.runtime.Symbol case283( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= SEQ ShiftExprB + java_cup.runtime.Symbol case282( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.ISSEQ_ARROW_LONE.make(o, null, ExprVar.make(o,"seq/Int"), b); parser.alloymodule.addSeq(o); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= SET ShiftExprB + java_cup.runtime.Symbol case281( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.SETOF.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= ONE ShiftExprB + java_cup.runtime.Symbol case280( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ONE .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= LONE ShiftExprB + java_cup.runtime.Symbol case279( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.LONE .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= SOME ShiftExprB + java_cup.runtime.Symbol case278( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.SOME .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= NO ShiftExprB + java_cup.runtime.Symbol case277( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.NO .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= ALL ShiftExprB + java_cup.runtime.Symbol case276( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + if (1==1) throw new ErrorSyntax(o,"The \"all x\" construct is no longer supported. If you know the range of possible values of x, consider rewriting it as \"x == set_of_all_possible_values\"."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB NOTGTE ShiftExprB + java_cup.runtime.Symbol case275( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_GTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB NOTLTE ShiftExprB + java_cup.runtime.Symbol case274( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_LTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB NOTGT ShiftExprB + java_cup.runtime.Symbol case273( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_GT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB NOTLT ShiftExprB + java_cup.runtime.Symbol case272( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_LT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB NOTEQUALS ShiftExprB + java_cup.runtime.Symbol case271( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_EQUALS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB NOTIN ShiftExprB + java_cup.runtime.Symbol case270( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_IN .make(o, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB GTE ShiftExprB + java_cup.runtime.Symbol case269( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.GTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB LTE ShiftExprB + java_cup.runtime.Symbol case268( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.LTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB GT ShiftExprB + java_cup.runtime.Symbol case267( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.GT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB LT ShiftExprB + java_cup.runtime.Symbol case266( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.LT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB EQUALS ShiftExprB + java_cup.runtime.Symbol case265( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.EQUALS .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprB ::= CompareExprB IN ShiftExprB + java_cup.runtime.Symbol case264( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IN .make(o, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprB",7, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= ShiftExprA + java_cup.runtime.Symbol case263( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= SEQ ShiftExprA + java_cup.runtime.Symbol case262( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.ISSEQ_ARROW_LONE.make(o, null, ExprVar.make(o, "seq/Int"), b); parser.alloymodule.addSeq(o); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= SET ShiftExprA + java_cup.runtime.Symbol case261( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.SETOF.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= ONE ShiftExprA + java_cup.runtime.Symbol case260( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ONE .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= LONE ShiftExprA + java_cup.runtime.Symbol case259( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.LONE .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= SOME ShiftExprA + java_cup.runtime.Symbol case258( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.SOME .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= NO ShiftExprA + java_cup.runtime.Symbol case257( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.NO .make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= ALL ShiftExprA + java_cup.runtime.Symbol case256( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + if (1==1) throw new ErrorSyntax(o,"The \"all x\" construct is no longer supported. If you know the range of possible values of x, consider rewriting it as \"x == set_of_all_possible_values\"."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB NOTGTE ShiftExprA + java_cup.runtime.Symbol case255( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_GTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB NOTLTE ShiftExprA + java_cup.runtime.Symbol case254( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_LTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB NOTGT ShiftExprA + java_cup.runtime.Symbol case253( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_GT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB NOTLT ShiftExprA + java_cup.runtime.Symbol case252( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_LT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB NOTEQUALS ShiftExprA + java_cup.runtime.Symbol case251( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_EQUALS.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB NOTIN ShiftExprA + java_cup.runtime.Symbol case250( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.NOT_IN .make(o, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB GTE ShiftExprA + java_cup.runtime.Symbol case249( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.GTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB LTE ShiftExprA + java_cup.runtime.Symbol case248( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.LTE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB GT ShiftExprA + java_cup.runtime.Symbol case247( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.GT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB LT ShiftExprA + java_cup.runtime.Symbol case246( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.LT .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB EQUALS ShiftExprA + java_cup.runtime.Symbol case245( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.EQUALS .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CompareExprA ::= CompareExprB IN ShiftExprA + java_cup.runtime.Symbol case244( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IN .make(o, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CompareExprA",6, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= BEFORE UnaryExprB + java_cup.runtime.Symbol case243( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.BEFORE.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= ONCE UnaryExprB + java_cup.runtime.Symbol case242( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ONCE.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= HISTORICALLY UnaryExprB + java_cup.runtime.Symbol case241( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.HISTORICALLY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= AFTER UnaryExprB + java_cup.runtime.Symbol case240( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.AFTER.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= EVENTUALLY UnaryExprB + java_cup.runtime.Symbol case239( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.EVENTUALLY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= ALWAYS UnaryExprB + java_cup.runtime.Symbol case238( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ALWAYS.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= NOT UnaryExprB + java_cup.runtime.Symbol case237( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.NOT.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprB ::= CompareExprB + java_cup.runtime.Symbol case236( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprB",46, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= BEFORE UnaryExprA + java_cup.runtime.Symbol case235( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.BEFORE.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= BEFORE Bind + java_cup.runtime.Symbol case234( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.BEFORE.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= ONCE UnaryExprA + java_cup.runtime.Symbol case233( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ONCE.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= ONCE Bind + java_cup.runtime.Symbol case232( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ONCE.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= HISTORICALLY UnaryExprA + java_cup.runtime.Symbol case231( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.HISTORICALLY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= HISTORICALLY Bind + java_cup.runtime.Symbol case230( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.HISTORICALLY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= AFTER UnaryExprA + java_cup.runtime.Symbol case229( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.AFTER.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= AFTER Bind + java_cup.runtime.Symbol case228( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.AFTER.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= EVENTUALLY UnaryExprA + java_cup.runtime.Symbol case227( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.EVENTUALLY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= EVENTUALLY Bind + java_cup.runtime.Symbol case226( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.EVENTUALLY.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= ALWAYS UnaryExprA + java_cup.runtime.Symbol case225( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ALWAYS.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= ALWAYS Bind + java_cup.runtime.Symbol case224( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.ALWAYS.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= NOT UnaryExprA + java_cup.runtime.Symbol case223( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.NOT.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= NOT Bind + java_cup.runtime.Symbol case222( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.NOT.make(o, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //UnaryExprA ::= CompareExprA + java_cup.runtime.Symbol case221( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("UnaryExprA",45, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryB ::= TempBinaryB TRIGGERED UnaryExprB + java_cup.runtime.Symbol case220( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.TRIGGERED.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryB",83, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryB ::= TempBinaryB RELEASES UnaryExprB + java_cup.runtime.Symbol case219( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.RELEASES .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryB",83, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryB ::= TempBinaryB SINCE UnaryExprB + java_cup.runtime.Symbol case218( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SINCE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryB",83, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryB ::= TempBinaryB UNTIL UnaryExprB + java_cup.runtime.Symbol case217( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.UNTIL .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryB",83, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryB ::= UnaryExprB + java_cup.runtime.Symbol case216( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryB",83, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryA ::= TempBinaryB RELEASES Bind + java_cup.runtime.Symbol case215( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.RELEASES .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryA",82, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryA ::= TempBinaryB TRIGGERED Bind + java_cup.runtime.Symbol case214( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.TRIGGERED.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryA",82, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryA ::= TempBinaryB SINCE Bind + java_cup.runtime.Symbol case213( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.SINCE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryA",82, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryA ::= TempBinaryB UNTIL Bind + java_cup.runtime.Symbol case212( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.UNTIL .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryA",82, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TempBinaryA ::= UnaryExprA + java_cup.runtime.Symbol case211( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TempBinaryA",82, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //AndExprB ::= AndExprB AND TempBinaryB + java_cup.runtime.Symbol case210( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.AND.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprB",1, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //AndExprB ::= TempBinaryB + java_cup.runtime.Symbol case209( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprB",1, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //AndExprA ::= AndExprB AND Bind + java_cup.runtime.Symbol case208( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.AND.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprA",0, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //AndExprA ::= TempBinaryA + java_cup.runtime.Symbol case207( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("AndExprA",0, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprOpenB ::= AndExprB IMPLIES ImpliesExprB + java_cup.runtime.Symbol case206( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenB",35, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprOpenB ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprOpenB + java_cup.runtime.Symbol case205( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Expr c = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprITE.make(o,a,b,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenB",35, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprCloseB ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprCloseB + java_cup.runtime.Symbol case204( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Expr c = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprITE.make(o,a,b,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseB",33, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprCloseB ::= AndExprB + java_cup.runtime.Symbol case203( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseB",33, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprB ::= ImpliesExprOpenB + java_cup.runtime.Symbol case202( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprB",31, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprB ::= ImpliesExprCloseB + java_cup.runtime.Symbol case201( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprB",31, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprOpenA ::= AndExprB IMPLIES Bind + java_cup.runtime.Symbol case200( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenA",34, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprCloseA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE Bind + java_cup.runtime.Symbol case199( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Expr c = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprITE.make(o,a,b,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseA",32, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprOpenA ::= AndExprB IMPLIES ImpliesExprA + java_cup.runtime.Symbol case198( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprBinary.Op.IMPLIES.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenA",34, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprOpenA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprOpenA + java_cup.runtime.Symbol case197( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Expr c = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprITE.make(o,a,b,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprOpenA",34, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprCloseA ::= AndExprB IMPLIES ImpliesExprCloseB ELSE ImpliesExprCloseA + java_cup.runtime.Symbol case196( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Expr c = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprITE.make(o,a,b,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseA",32, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprCloseA ::= AndExprA + java_cup.runtime.Symbol case195( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprCloseA",32, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprA ::= ImpliesExprOpenA + java_cup.runtime.Symbol case194( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprA",30, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ImpliesExprA ::= ImpliesExprCloseA + java_cup.runtime.Symbol case193( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ImpliesExprA",30, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //EquivExprB ::= EquivExprB IFF ImpliesExprB + java_cup.runtime.Symbol case192( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IFF.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprB",20, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //EquivExprB ::= ImpliesExprB + java_cup.runtime.Symbol case191( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprB",20, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //EquivExprA ::= EquivExprB IFF Bind + java_cup.runtime.Symbol case190( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.IFF.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprA",19, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //EquivExprA ::= ImpliesExprA + java_cup.runtime.Symbol case189( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("EquivExprA",19, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OrExprB ::= OrExprB OR EquivExprB + java_cup.runtime.Symbol case188( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.OR.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprB",50, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OrExprB ::= EquivExprB + java_cup.runtime.Symbol case187( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprB",50, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OrExprA ::= OrExprB OR Bind + java_cup.runtime.Symbol case186( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.OR.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprA",49, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //OrExprA ::= EquivExprA + java_cup.runtime.Symbol case185( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("OrExprA",49, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= SUM2 Declp SuperOrBar + java_cup.runtime.Symbol case184( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.SUM .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= ONE2 Declp SuperOrBar + java_cup.runtime.Symbol case183( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.ONE .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= LONE2 Declp SuperOrBar + java_cup.runtime.Symbol case182( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.LONE.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= SOME2 Declp SuperOrBar + java_cup.runtime.Symbol case181( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.SOME.make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= NO2 Declp SuperOrBar + java_cup.runtime.Symbol case180( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.NO .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= ALL2 Declp SuperOrBar + java_cup.runtime.Symbol case179( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT = ExprQt.Op.ALL .make(o, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Bind ::= LET Let + java_cup.runtime.Symbol case178( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Bind",3, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ExprNoSeq ::= Bind + java_cup.runtime.Symbol case177( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ExprNoSeq",84, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ExprNoSeq ::= OrExprB + java_cup.runtime.Symbol case176( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ExprNoSeq",84, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //ExprNoSeq ::= OrExprA + java_cup.runtime.Symbol case175( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT = x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("ExprNoSeq",84, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Expr ::= ExprNoSeq TRCSEQ Expr + java_cup.runtime.Symbol case174( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.AND.make(o, null, a, ExprUnary.Op.AFTER.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expr",22, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Expr ::= ExprNoSeq + java_cup.runtime.Symbol case173( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expr",22, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Exprp ::= Exprp COMMA Expr + java_cup.runtime.Symbol case172( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + a.add(b); RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprp",28, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Exprp ::= Expr + java_cup.runtime.Symbol case171( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprp",28, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Exprs ::= Exprp + java_cup.runtime.Symbol case170( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + List x = (List) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprs",27, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Exprs ::= + java_cup.runtime.Symbol case169( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + RESULT=new ArrayList(); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Exprs",27, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperOrBar ::= BAR ExprNoSeq TRCSEQ Expr + java_cup.runtime.Symbol case168( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr x = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + Expr y = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.AND.make(o, null, x, ExprUnary.Op.AFTER.make(o, y)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOrBar",26, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperOrBar ::= Super + java_cup.runtime.Symbol case167( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOrBar",26, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperOrBar ::= BAR ExprNoSeq + java_cup.runtime.Symbol case166( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOrBar",26, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperP ::= Expr TRCSEQ SuperP + java_cup.runtime.Symbol case165( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.AND.make(o, null, a, ExprUnary.Op.AFTER.make(o, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperP",25, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperP ::= SuperP Expr + java_cup.runtime.Symbol case164( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr a = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=ExprBinary.Op.AND.make(null, null, a, b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperP",25, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperP ::= Expr + java_cup.runtime.Symbol case163( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperP",25, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Super ::= LBRACE RBRACE + java_cup.runtime.Symbol case162( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprConstant.Op.TRUE.make(a.merge(b), 0); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Super",23, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Super ::= LBRACE SuperP RBRACE + java_cup.runtime.Symbol case161( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr x = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprUnary.Op.NOOP.make(a.merge(b), x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Super",23, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperOpt ::= Super + java_cup.runtime.Symbol case160( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOpt",24, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SuperOpt ::= + java_cup.runtime.Symbol case159( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + RESULT=null; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SuperOpt",24, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Let ::= Name EQUALS Expr COMMA Let + java_cup.runtime.Symbol case158( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + + nod(a); + if (a.label.indexOf('/')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'/\'"); + if (a.label.indexOf('@')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'@\'"); + RESULT = ExprLet.make(o, ExprVar.make(a.pos, a.label), b, x); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Let",38, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Let ::= Name EQUALS Expr SuperOrBar + java_cup.runtime.Symbol case157( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr b = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Expr x = (Expr) CUP$CompParser$stack.peek().value; + + nod(a); + if (a.label.indexOf('/')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'/\'"); + if (a.label.indexOf('@')>=0) throw new ErrorSyntax(a.pos, "Let variable name cannot contain \'@\'"); + RESULT = ExprLet.make(o, ExprVar.make(a.pos, a.label), b, x); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Let",38, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decls ::= COMMA Decls + java_cup.runtime.Symbol case156( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + List y = (List) CUP$CompParser$stack.peek().value; + RESULT=y; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decls ::= Declb COMMA Decls + java_cup.runtime.Symbol case155( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Decl x = (Decl) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + List y = (List) CUP$CompParser$stack.peek().value; + RESULT=y; RESULT.add(0,x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decls ::= Declb + java_cup.runtime.Symbol case154( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Decl x = (Decl) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decls ::= + java_cup.runtime.Symbol case153( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + RESULT=new ArrayList(); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decls",13, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declp ::= Declb + java_cup.runtime.Symbol case152( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + Decl y = (Decl) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(y); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declp",12, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declp ::= Declp COMMA Declb + java_cup.runtime.Symbol case151( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List x = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + Decl y = (Decl) CUP$CompParser$stack.peek().value; + RESULT=x; RESULT.add(y); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declp",12, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declz ::= Decla + java_cup.runtime.Symbol case150( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + Decl y = (Decl) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(y); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declz",14, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declz ::= Declz COMMA Decla + java_cup.runtime.Symbol case149( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List x = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int yleft = CUP$CompParser$stack.peek().left; + int yright = CUP$CompParser$stack.peek().right; + Decl y = (Decl) CUP$CompParser$stack.peek().value; + RESULT=x; RESULT.add(y); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declz",14, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= Names EQUALS DISJ Expr + java_cup.runtime.Symbol case148( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= PRIVATE Names EQUALS DISJ Expr + java_cup.runtime.Symbol case147( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= PRIVATE DISJ Names EQUALS DISJ Expr + java_cup.runtime.Symbol case146( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= DISJ Names EQUALS DISJ Expr + java_cup.runtime.Symbol case145( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= EXH Names EQUALS DISJ Expr + java_cup.runtime.Symbol case144( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + if (1==1) throw CompModule.hint(k, "exh"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= PART Names EQUALS DISJ Expr + java_cup.runtime.Symbol case143( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + if (1==1) throw CompModule.hint(k, "part"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= Names EQUALS Expr + java_cup.runtime.Symbol case142( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, null, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= PRIVATE Names EQUALS Expr + java_cup.runtime.Symbol case141( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, null, null, null, a, ExprUnary.Op.EXACTLYOF.make(null, b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= PRIVATE DISJ Names EQUALS Expr + java_cup.runtime.Symbol case140( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= DISJ Names EQUALS Expr + java_cup.runtime.Symbol case139( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + if (1==1) throw new ErrorSyntax(d, "Defined fields cannot be disjoint."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= EXH Names EQUALS Expr + java_cup.runtime.Symbol case138( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + if (1==1) throw CompModule.hint(k, "exh"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= PART Names EQUALS Expr + java_cup.runtime.Symbol case137( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + if (1==1) throw CompModule.hint(k, "part"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Declb ::= Decla + java_cup.runtime.Symbol case136( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Decl x = (Decl) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Declb",11, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR Names COLON DISJ Expr + java_cup.runtime.Symbol case135( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, null, d, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR PRIVATE Names COLON DISJ Expr + java_cup.runtime.Symbol case134( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, null, d, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR PRIVATE DISJ Names COLON DISJ Expr + java_cup.runtime.Symbol case133( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, k, d, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR DISJ Names COLON DISJ Expr + java_cup.runtime.Symbol case132( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, k, d, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= Names COLON DISJ Expr + java_cup.runtime.Symbol case131( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, null, d, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= PRIVATE Names COLON DISJ Expr + java_cup.runtime.Symbol case130( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, null, d, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= PRIVATE DISJ Names COLON DISJ Expr + java_cup.runtime.Symbol case129( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, k, d, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= DISJ Names COLON DISJ Expr + java_cup.runtime.Symbol case128( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos d = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, k, d, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= EXH Names COLON DISJ Expr + java_cup.runtime.Symbol case127( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + if (1==1) throw CompModule.hint(k, "exh"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= PART Names COLON DISJ Expr + java_cup.runtime.Symbol case126( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + if (1==1) throw CompModule.hint(k, "part"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR Names COLON Expr + java_cup.runtime.Symbol case125( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, null, null, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR PRIVATE Names COLON Expr + java_cup.runtime.Symbol case124( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, null, null, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR PRIVATE DISJ Names COLON Expr + java_cup.runtime.Symbol case123( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, k, null, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= VAR DISJ Names COLON Expr + java_cup.runtime.Symbol case122( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int vleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int vright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos v = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, k, null, v, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= Names COLON Expr + java_cup.runtime.Symbol case121( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, null, null, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= PRIVATE Names COLON Expr + java_cup.runtime.Symbol case120( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, null, null, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= PRIVATE DISJ Names COLON Expr + java_cup.runtime.Symbol case119( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(p, k, null, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= DISJ Names COLON Expr + java_cup.runtime.Symbol case118( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Expr b = (Expr) CUP$CompParser$stack.peek().value; + RESULT=new Decl(null, k, null, null, a, mult(b)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= EXH Names COLON Expr + java_cup.runtime.Symbol case117( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + if (1==1) throw CompModule.hint(k, "exh"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Decla ::= PART Names COLON Expr + java_cup.runtime.Symbol case116( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Decl RESULT =null;/*3*/ + int kleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int kright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos k = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + if (1==1) throw CompModule.hint(k, "part"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Decla",10, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Namex ::= Namex COMMA EXACTLY Name + java_cup.runtime.Symbol case115( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + nod(b); a.add(null); a.add(b); RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Namex ::= Namex COMMA Name + java_cup.runtime.Symbol case114( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + nod(b); a.add(b); RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Namex ::= EXACTLY Name + java_cup.runtime.Symbol case113( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + nod(x); RESULT=new ArrayList(); RESULT.add(null); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Namex ::= Name + java_cup.runtime.Symbol case112( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + nod(x); RESULT=new ArrayList(); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Namex",44, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Names ::= Names COMMA Name + java_cup.runtime.Symbol case111( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + nod(b); a.add(b); RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Names",43, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Names ::= Name + java_cup.runtime.Symbol case110( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + nod(x); RESULT=new ArrayList(); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Names",43, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NameHelper ::= NameHelper SLASH ID + java_cup.runtime.Symbol case109( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(a.pos.merge(b.pos), a.label+"/"+b.label); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NameHelper",42, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //NameHelper ::= ID + java_cup.runtime.Symbol case108( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("NameHelper",42, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Name ::= SEQ SLASH NameHelper + java_cup.runtime.Symbol case107( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(a.merge(b.pos), "seq/"+b.label); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Name",41, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Name ::= THIS SLASH NameHelper + java_cup.runtime.Symbol case106( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(a.merge(b.pos), "this/"+b.label); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Name",41, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Name ::= NameHelper + java_cup.runtime.Symbol case105( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Name",41, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRefu ::= SigRefu PLUS SigRef + java_cup.runtime.Symbol case104( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + a.add(b); RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefu",67, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRefu ::= SigRef + java_cup.runtime.Symbol case103( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefu",67, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRefp ::= SigRefp COMMA SigRef + java_cup.runtime.Symbol case102( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + a.add(b); RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefp",65, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRefp ::= SigRef + java_cup.runtime.Symbol case101( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefp",65, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRefs ::= SigRefp + java_cup.runtime.Symbol case100( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + List x = (List) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefs",66, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRefs ::= + java_cup.runtime.Symbol case99( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + RESULT=new ArrayList(); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRefs",66, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= NONE + java_cup.runtime.Symbol case98( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(x, "none"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= SEQ SLASH SIGINT + java_cup.runtime.Symbol case97( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(a.merge(b), "seq/Int"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= SIGINT + java_cup.runtime.Symbol case96( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(x, "Int"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= TIME + java_cup.runtime.Symbol case95( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(x, "steps"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= STRING + java_cup.runtime.Symbol case94( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(x, "String"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= UNIV + java_cup.runtime.Symbol case93( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=ExprVar.make(x, "univ"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigRef ::= Name + java_cup.runtime.Symbol case92( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=x; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigRef",64, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigIn ::= + java_cup.runtime.Symbol case91( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + RESULT=null; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigIn ::= EQUALS SigRefu + java_cup.runtime.Symbol case90( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + List x = (List) CUP$CompParser$stack.peek().value; + RESULT=x; x.add(ExprVar.make(a,"=")); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigIn ::= IN SigRefu + java_cup.runtime.Symbol case89( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + List x = (List) CUP$CompParser$stack.peek().value; + RESULT=x; x.add(ExprVar.make(a,"in")); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigIn ::= EXTENDS SigRef + java_cup.runtime.Symbol case88( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos a = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + ExprVar x = (ExprVar) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(2); RESULT.add(x); RESULT.add(ExprVar.make(a, "extends")); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigIn",61, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQuals ::= SigQual SigQuals + java_cup.runtime.Symbol case87( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + List b = (List) CUP$CompParser$stack.peek().value; + RESULT=a; for(int i=0;i<6;i++) if (a.get(i)==null) a.set(i,b.get(i)); else if (b.get(i)!=null) throw new ErrorSyntax(b.get(i), "The same qualifer cannot be specified more than once for the same sig."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQuals",63, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQuals ::= SIG + java_cup.runtime.Symbol case86( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQuals",63, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQual ::= VAR + java_cup.runtime.Symbol case85( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQual ::= PRIVATE + java_cup.runtime.Symbol case84( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQual ::= SOME + java_cup.runtime.Symbol case83( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQual ::= ONE + java_cup.runtime.Symbol case82( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQual ::= LONE + java_cup.runtime.Symbol case81( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(6); RESULT.add(null); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //SigQual ::= ABSTRACT + java_cup.runtime.Symbol case80( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int xleft = CUP$CompParser$stack.peek().left; + int xright = CUP$CompParser$stack.peek().right; + Pos x = (Pos) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(6); RESULT.add(x); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); RESULT.add(null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("SigQual",62, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Sig ::= SigQuals Names SigIn LBRACE Decls RBRACE SuperOpt + java_cup.runtime.Symbol case79( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int cleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int cright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + List c = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + + if (e==null) e = ExprConstant.Op.TRUE.make(o, 0); + ExprVar cc = (c!=null && c.size()>0) ? c.remove(c.size()-1) : null; + for(ExprVar bb:b) { + parser.alloymodule.addSig(bb.label, cc, c, d, e, + AttrType.WHERE .makenull(bb.pos.merge(e==null ? o : e.span())), + AttrType.ABSTRACT.makenull(a.get(0)), + AttrType.LONE .makenull(a.get(1)), + AttrType.ONE .makenull(a.get(2)), + AttrType.SOME .makenull(a.get(3)), + AttrType.PRIVATE .makenull(a.get(4)), + AttrType.VARIABLE.makenull(a.get(5))); + } + /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Sig",60, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Vis ::= PRIVATE + java_cup.runtime.Symbol case78( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pos RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.peek().left; + int pright = CUP$CompParser$stack.peek().right; + Pos p = (Pos) CUP$CompParser$stack.peek().value; + RESULT=p; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Vis",81, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Vis ::= + java_cup.runtime.Symbol case77( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Pos RESULT =null;/*3*/ + RESULT=null; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Vis",81, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Predicate ::= Vis PRED SigRef DOT Name Super + java_cup.runtime.Symbol case76( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int fleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int fright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar f = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , null , null, v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Predicate ::= Vis PRED SigRef DOT Name LBRACKET Decls RBRACKET Super + java_cup.runtime.Symbol case75( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).value; + int fleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int fright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + ExprVar f = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , null, v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, CUP$CompParser$stack.elementAt(CUP$CompParser$top-8), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Predicate ::= Vis PRED SigRef DOT Name LPAREN Decls RPAREN Super + java_cup.runtime.Symbol case74( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).value; + int fleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int fright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + ExprVar f = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , null, v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, CUP$CompParser$stack.elementAt(CUP$CompParser$top-8), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Predicate ::= Vis PRED Name Super + java_cup.runtime.Symbol case73( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, null , null, v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Predicate ::= Vis PRED Name LBRACKET Decls RBRACKET Super + java_cup.runtime.Symbol case72( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , null, v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Predicate ::= Vis PRED Name LPAREN Decls RPAREN Super + java_cup.runtime.Symbol case71( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , null, v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Predicate",53, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Function ::= Vis FUN SigRef DOT Name COLON Expr Super + java_cup.runtime.Symbol case70( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int fleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int fright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + ExprVar f = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int rleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int rright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr r = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , null , mult(r), v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, CUP$CompParser$stack.elementAt(CUP$CompParser$top-7), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Function ::= Vis FUN SigRef DOT Name LBRACKET Decls RBRACKET COLON Expr Super + java_cup.runtime.Symbol case69( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-10).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-10).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-10).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-9).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-9).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-9).value; + int fleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).left; + int fright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).right; + ExprVar f = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int rleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int rright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr r = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , mult(r), v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, CUP$CompParser$stack.elementAt(CUP$CompParser$top-10), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Function ::= Vis FUN SigRef DOT Name LPAREN Decls RPAREN COLON Expr Super + java_cup.runtime.Symbol case68( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-10).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-10).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-10).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-9).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-9).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-9).value; + int fleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).left; + int fright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).right; + ExprVar f = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int rleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int rright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr r = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, f , d , mult(r), v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, CUP$CompParser$stack.elementAt(CUP$CompParser$top-10), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Function ::= Vis FUN Name COLON Expr Super + java_cup.runtime.Symbol case67( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int rleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int rright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr r = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, null , mult(r), v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Function ::= Vis FUN Name LBRACKET Decls RBRACKET COLON Expr Super + java_cup.runtime.Symbol case66( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int rleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int rright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr r = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , mult(r), v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, CUP$CompParser$stack.elementAt(CUP$CompParser$top-8), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Function ::= Vis FUN Name LPAREN Decls RPAREN COLON Expr Super + java_cup.runtime.Symbol case65( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-8).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int rleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int rright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Expr r = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFunc(o.merge(v.span()), p, n.label, null, d , mult(r), v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Function",29, CUP$CompParser$stack.elementAt(CUP$CompParser$top-8), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MacroBody ::= EQUALS Expr + java_cup.runtime.Symbol case64( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MacroBody",40, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //MacroBody ::= Super + java_cup.runtime.Symbol case63( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Expr RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + Expr a = (Expr) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("MacroBody",40, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Macro ::= Vis LET Name MacroBody + java_cup.runtime.Symbol case62( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Macro ::= Vis LET Name LBRACKET RBRACKET MacroBody + java_cup.runtime.Symbol case61( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Macro ::= Vis LET Name LBRACKET Names RBRACKET MacroBody + java_cup.runtime.Symbol case60( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, d , v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Macro ::= Vis LET Name LPAREN RPAREN MacroBody + java_cup.runtime.Symbol case59( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, null , v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Macro ::= Vis LET Name LPAREN Names RPAREN MacroBody + java_cup.runtime.Symbol case58( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int dleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int dright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List d = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int vleft = CUP$CompParser$stack.peek().left; + int vright = CUP$CompParser$stack.peek().right; + Expr v = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addMacro(o.merge(v.span()), p, n.label, d , v); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Macro",39, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= NUMBER COLON NUMBER + java_cup.runtime.Symbol case57( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int ileft = CUP$CompParser$stack.peek().left; + int iright = CUP$CompParser$stack.peek().right; + ExprConstant i = (ExprConstant) CUP$CompParser$stack.peek().value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, false, a.num, Integer.MAX_VALUE, i.num); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= NUMBER DOT DOT NUMBER COLON NUMBER + java_cup.runtime.Symbol case56( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant b = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int ileft = CUP$CompParser$stack.peek().left; + int iright = CUP$CompParser$stack.peek().right; + ExprConstant i = (ExprConstant) CUP$CompParser$stack.peek().value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(i.pos), Sig.NONE, a.num == b.num, a.num, b.num, i.num); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= NUMBER DOT DOT + java_cup.runtime.Symbol case55( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos , Sig.NONE, false, a.num, Integer.MAX_VALUE, 1 ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= NUMBER DOT DOT NUMBER + java_cup.runtime.Symbol case54( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprConstant b = (ExprConstant) CUP$CompParser$stack.peek().value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope(a.pos.merge(b.pos), Sig.NONE, a.num == b.num, a.num, b.num, 1 ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= NUMBER + java_cup.runtime.Symbol case53( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.peek().value; + RESULT = new CommandScope(a.pos , Sig.NONE, false, a.num, a.num, 1 ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= EXACTLY NUMBER COLON NUMBER + java_cup.runtime.Symbol case52( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos e = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int ileft = CUP$CompParser$stack.peek().left; + int iright = CUP$CompParser$stack.peek().right; + ExprConstant i = (ExprConstant) CUP$CompParser$stack.peek().value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, Integer.MAX_VALUE, i.num); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= EXACTLY NUMBER DOT DOT NUMBER COLON NUMBER + java_cup.runtime.Symbol case51( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos e = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant b = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int ileft = CUP$CompParser$stack.peek().left; + int iright = CUP$CompParser$stack.peek().right; + ExprConstant i = (ExprConstant) CUP$CompParser$stack.peek().value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(i.pos), Sig.NONE, true, a.num, b.num, i.num); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= EXACTLY NUMBER DOT DOT + java_cup.runtime.Symbol case50( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos e = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e , Sig.NONE, true, a.num, Integer.MAX_VALUE, 1 ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= EXACTLY NUMBER DOT DOT NUMBER + java_cup.runtime.Symbol case49( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos e = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprConstant b = (ExprConstant) CUP$CompParser$stack.peek().value; + if (!Version.experimental) throw new ErrorSyntax(a.pos, "Syntax error here."); RESULT = new CommandScope( e.merge(b.pos), Sig.NONE, true, a.num, b.num, 1 ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //TypeNumber ::= EXACTLY NUMBER + java_cup.runtime.Symbol case48( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos e = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.peek().value; + RESULT = new CommandScope( e.merge(a.pos), Sig.NONE, true, a.num, a.num, 1 ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("TypeNumber",70, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber NONE + java_cup.runtime.Symbol case47( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope e = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int fleft = CUP$CompParser$stack.peek().left; + int fright = CUP$CompParser$stack.peek().right; + Pos f = (Pos) CUP$CompParser$stack.peek().value; + if (1==1) throw new ErrorSyntax(e.pos.merge(f), "You cannot set a scope on none."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber TIME + java_cup.runtime.Symbol case46( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope a = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + + Pos p = a.pos.merge(b); + RESULT = new CommandScope(p, new PrimSig("steps", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.endingScope, a.increment); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber STRING + java_cup.runtime.Symbol case45( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope a = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + RESULT = new CommandScope(a.pos.merge(b), new PrimSig("String", AttrType.WHERE.make(a.pos.merge(b))), a.isExact, a.startingScope, a.endingScope, a.increment); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber UNIV + java_cup.runtime.Symbol case44( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope e = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int fleft = CUP$CompParser$stack.peek().left; + int fright = CUP$CompParser$stack.peek().right; + Pos f = (Pos) CUP$CompParser$stack.peek().value; + if (1==1) throw new ErrorSyntax(e.pos.merge(f), "You cannot set a scope on univ."); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber SEQ + java_cup.runtime.Symbol case43( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope a = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + + Pos p = a.pos.merge(b); + if (a.endingScope>a.startingScope) throw new ErrorSyntax(p, "Cannot specify a growing scope for \"seq\""); + if (a.isExact) throw new ErrorSyntax(p, "The exactly keyword is redundant here since the number of sequence index has to be exact."); + RESULT = new CommandScope(p, new PrimSig("seq", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.startingScope, 1); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber INT + java_cup.runtime.Symbol case42( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope a = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + + Pos p = a.pos.merge(b); + if (a.endingScope>a.startingScope) throw new ErrorSyntax(p, "Cannot specify a growing scope for \"Int\""); + if (a.isExact) throw new ErrorSyntax(p, "The exactly keyword is redundant here since the integer bitwidth must be exact."); + RESULT = new CommandScope(p, new PrimSig("int", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.startingScope, 1); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber SIGINT + java_cup.runtime.Symbol case41( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope a = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + Pos b = (Pos) CUP$CompParser$stack.peek().value; + + Pos p = a.pos.merge(b); + if (a.endingScope>a.startingScope) throw new ErrorSyntax(p, "Cannot specify a growing scope for \"Int\""); + if (a.isExact) throw new ErrorSyntax(p, "The exactly keyword is redundant here since the integer bitwidth must be exact."); + RESULT = new CommandScope(p, new PrimSig("int", AttrType.WHERE.make(p)), a.isExact, a.startingScope, a.startingScope, 1); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescope ::= TypeNumber Name + java_cup.runtime.Symbol case40( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + CommandScope RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + CommandScope a = (CommandScope) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + ExprVar b = (ExprVar) CUP$CompParser$stack.peek().value; + + nod(b); + RESULT = new CommandScope(a.pos.merge(b.pos), new PrimSig(b.label, AttrType.WHERE.make(a.pos.merge(b.pos))), a.isExact, a.startingScope, a.endingScope, a.increment); +/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescope",71, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescopes ::= Typescopes COMMA Typescope + java_cup.runtime.Symbol case39( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + List a = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + CommandScope b = (CommandScope) CUP$CompParser$stack.peek().value; + RESULT=a; a.add(b); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescopes",72, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Typescopes ::= Typescope + java_cup.runtime.Symbol case38( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + CommandScope a = (CommandScope) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(a); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Typescopes",72, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Scope ::= + java_cup.runtime.Symbol case37( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + RESULT=new ArrayList(); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Scope ::= FOR Typescopes + java_cup.runtime.Symbol case36( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + List b = (List) CUP$CompParser$stack.peek().value; + RESULT=b; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Scope ::= FOR NUMBER BUT Typescopes + java_cup.runtime.Symbol case35( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int bleft = CUP$CompParser$stack.peek().left; + int bright = CUP$CompParser$stack.peek().right; + List b = (List) CUP$CompParser$stack.peek().value; + RESULT=b; b.add(new CommandScope(a.pos, new PrimSig("univ", AttrType.WHERE.make(a.pos)), true, a.num, a.num, 1)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Scope ::= FOR NUMBER + java_cup.runtime.Symbol case34( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + List RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.peek().value; + RESULT=new ArrayList(); RESULT.add(new CommandScope(a.pos, new PrimSig("univ", AttrType.WHERE.make(a.pos)), true, a.num, a.num, 1)); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Scope",59, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Expects ::= EXPECT NUMBER + java_cup.runtime.Symbol case33( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprConstant RESULT =null;/*3*/ + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + ExprConstant a = (ExprConstant) CUP$CompParser$stack.peek().value; + RESULT=a; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expects",21, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Expects ::= + java_cup.runtime.Symbol case32( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprConstant RESULT =null;/*3*/ + RESULT=null; /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Expects",21, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= Command IMPLIES CommandPrefix Name Scope Expects + java_cup.runtime.Symbol case31( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(true ,o,null,n ,null,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= Command IMPLIES CommandPrefix Name Name Scope Expects + java_cup.runtime.Symbol case30( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar x = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(true ,o,x ,n ,null,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= CommandPrefix Name Scope Expects + java_cup.runtime.Symbol case29( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(false,o,null,n ,null,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= CommandPrefix Name Name Scope Expects + java_cup.runtime.Symbol case28( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar x = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(false,o,x ,n ,null,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= Command IMPLIES CommandPrefix Super Scope Expects + java_cup.runtime.Symbol case27( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr e = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(true ,o,null,null,e ,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= Command IMPLIES CommandPrefix Name Super Scope Expects + java_cup.runtime.Symbol case26( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar x = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr e = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(true ,o,x ,null,e ,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= CommandPrefix Super Scope Expects + java_cup.runtime.Symbol case25( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr e = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(false,o,null,null,e ,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Command ::= CommandPrefix Name Super Scope Expects + java_cup.runtime.Symbol case24( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + ExprVar o = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int xleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int xright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar x = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int eleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int eright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Expr e = (Expr) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int sleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int sright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List s = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprConstant c = (ExprConstant) CUP$CompParser$stack.peek().value; + c(false,o,x ,null,e ,s,c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Command",8, CUP$CompParser$stack.elementAt(CUP$CompParser$top-4), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CommandPrefix ::= RUN + java_cup.runtime.Symbol case23( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int rleft = CUP$CompParser$stack.peek().left; + int rright = CUP$CompParser$stack.peek().right; + Pos r = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprVar.make(r, "r"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CommandPrefix",9, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //CommandPrefix ::= CHECK + java_cup.runtime.Symbol case22( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + ExprVar RESULT =null;/*3*/ + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + RESULT = ExprVar.make(c, "c"); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("CommandPrefix",9, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= + java_cup.runtime.Symbol case21( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Command + java_cup.runtime.Symbol case20( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Macro + java_cup.runtime.Symbol case19( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Predicate + java_cup.runtime.Symbol case18( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Function + java_cup.runtime.Symbol case17( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Sig + java_cup.runtime.Symbol case16( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec ASSERT STR Super + java_cup.runtime.Symbol case15( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprConstant n = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + parser.alloymodule.addAssertion (o , n.string , e); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec ASSERT Name Super + java_cup.runtime.Symbol case14( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addAssertion (o , n.label , e); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec ASSERT Super + java_cup.runtime.Symbol case13( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + parser.alloymodule.addAssertion (o , "" , e); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec FACT STR Super + java_cup.runtime.Symbol case12( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprConstant n = (ExprConstant) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + parser.alloymodule.addFact (o , n.string , e); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec FACT Name Super + java_cup.runtime.Symbol case11( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addFact (o , n.label , e); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec FACT Super + java_cup.runtime.Symbol case10( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int eleft = CUP$CompParser$stack.peek().left; + int eright = CUP$CompParser$stack.peek().right; + Expr e = (Expr) CUP$CompParser$stack.peek().value; + parser.alloymodule.addFact (o , "" , e); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Vis ENUM Name LBRACE RBRACE + java_cup.runtime.Symbol case9( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + nod(a); parser.alloymodule.addEnum(o.merge(c), p, a, null, c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Vis ENUM Name LBRACE Names RBRACE + java_cup.runtime.Symbol case8( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List n = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + nod(a); parser.alloymodule.addEnum(o.merge(c), p, a, n, c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Vis OPEN Name LBRACKET SigRefs RBRACKET AS Name + java_cup.runtime.Symbol case7( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-7).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-6).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprVar c = (ExprVar) CUP$CompParser$stack.peek().value; + nod(a); nod(c); parser.alloymodule.addOpen(o.merge(c.pos), p, a, b, c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-8), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Vis OPEN Name LBRACKET SigRefs RBRACKET + java_cup.runtime.Symbol case6( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-5).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + Pos c = (Pos) CUP$CompParser$stack.peek().value; + nod(a); parser.alloymodule.addOpen(o.merge(c), p, a, b, null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-6), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Vis OPEN Name AS Name + java_cup.runtime.Symbol case5( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int aleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int aright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + ExprVar a = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int cleft = CUP$CompParser$stack.peek().left; + int cright = CUP$CompParser$stack.peek().right; + ExprVar c = (ExprVar) CUP$CompParser$stack.peek().value; + nod(a); nod(c); parser.alloymodule.addOpen(o.merge(c.pos), p, a, null, c); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec Vis OPEN Name + java_cup.runtime.Symbol case4( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int pleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).left; + int pright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).right; + Pos p = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-2).value; + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int aleft = CUP$CompParser$stack.peek().left; + int aright = CUP$CompParser$stack.peek().right; + ExprVar a = (ExprVar) CUP$CompParser$stack.peek().value; + nod(a); parser.alloymodule.addOpen(o.merge(a.pos), p, a, null, null); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-3), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec MODULE Name LBRACKET Namex RBRACKET + java_cup.runtime.Symbol case3( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-4).value; + int nleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).left; + int nright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).right; + ExprVar n = (ExprVar) CUP$CompParser$stack.elementAt(CUP$CompParser$top-3).value; + int bleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int bright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + List b = (List) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int rleft = CUP$CompParser$stack.peek().left; + int rright = CUP$CompParser$stack.peek().right; + Pos r = (Pos) CUP$CompParser$stack.peek().value; + nod(n); nod(b); parser.alloymodule.addModelName(o.merge(r) , n.label , b ); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-5), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //Spec ::= Spec MODULE Name + java_cup.runtime.Symbol case2( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int oleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int oright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Pos o = (Pos) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + int nleft = CUP$CompParser$stack.peek().left; + int nright = CUP$CompParser$stack.peek().right; + ExprVar n = (ExprVar) CUP$CompParser$stack.peek().value; + nod(n); parser.alloymodule.addModelName(o.merge(n.pos) , n.label , new ArrayList()); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("Spec",69, CUP$CompParser$stack.elementAt(CUP$CompParser$top-2), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //$START ::= File EOF + java_cup.runtime.Symbol case1( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + int start_valleft = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).left; + int start_valright = CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).right; + Object start_val = (Object) CUP$CompParser$stack.elementAt(CUP$CompParser$top-1).value; + RESULT = start_val;/*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("$START",0, CUP$CompParser$stack.elementAt(CUP$CompParser$top-1), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ + + } + //File ::= Spec + java_cup.runtime.Symbol case0( + int CUP$CompParser$act_num, + java_cup.runtime.lr_parser CUP$CompParser$parser, + java.util.Stack CUP$CompParser$stack, + int CUP$CompParser$top) + throws java.lang.Exception + { + java_cup.runtime.Symbol CUP$CompParser$result; + Object RESULT =null;/*3*/ + parser.alloymodule.doneParsing(); /*5*/ + CUP$CompParser$result = parser.getSymbolFactory().newSymbol("File",68, CUP$CompParser$stack.peek(), CUP$CompParser$stack.peek(), RESULT); /*6*/ + return CUP$CompParser$result;/*8*/ - } } } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompSym.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompSym.java index 3167f368d..7107746fa 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompSym.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompSym.java @@ -1,7 +1,7 @@ //---------------------------------------------------- -// The following code was generated by CUP v0.11a beta 20060608 -// Sun Apr 08 09:54:30 PDT 2018 +// The following code was generated by CUP v0.11a czt01 beta +// Sun Feb 21 15:30:14 WET 2021 //---------------------------------------------------- package edu.mit.csail.sdg.parser; @@ -13,9 +13,14 @@ public class CompSym { public static final int AS = 32; public static final int ANY_ARROW_SOME = 3; public static final int GT = 54; + public static final int BEFORE = 119; public static final int ARROW = 2; + public static final int TIME = 125; + public static final int TRIGGERED = 123; public static final int NOTLTE = 81; public static final int INTSUB = 19; + public static final int UNTIL = 121; + public static final int TRCSEQ = 124; public static final int ONE_ARROW_ANY = 10; public static final int ONE2 = 82; public static final int ENUM = 45; @@ -33,6 +38,8 @@ public class CompSym { public static final int ALL = 28; public static final int LT = 68; public static final int INTMUL = 20; + public static final int RELEASES = 120; + public static final int ALWAYS = 114; public static final int LBRACE = 62; public static final int SOME_ARROW_ANY = 6; public static final int LPAREN = 67; @@ -41,15 +48,18 @@ public class CompSym { public static final int TILDE = 111; public static final int PART = 86; public static final int SHL = 98; + public static final int AFTER = 116; + public static final int VAR = 113; public static final int NOTEQUALS = 76; - public static final int STR = 115; + public static final int STR = 129; public static final int SHA = 100; public static final int LONE_ARROW_ONE = 16; public static final int SOME_ARROW_LONE = 9; + public static final int ONCE = 117; public static final int INTADD = 18; public static final int INTDIV = 21; public static final int INTMAX = 24; - public static final int NUMBER = 114; + public static final int NUMBER = 128; public static final int ABSTRACT = 27; public static final int INTNEXT = 25; public static final int SLASH = 103; @@ -71,6 +81,7 @@ public class CompSym { public static final int FOR = 52; public static final int STAR = 106; public static final int LONE_ARROW_SOME = 15; + public static final int SINCE = 122; public static final int ELSE = 44; public static final int FUN = 53; public static final int DOT = 43; @@ -85,6 +96,7 @@ public class CompSym { public static final int ANY_ARROW_LONE = 5; public static final int BUT = 36; public static final int LONE_ARROW_ANY = 14; + public static final int EVENTUALLY = 115; public static final int ALL2 = 29; public static final int MINUS = 70; public static final int SOME_ARROW_SOME = 7; @@ -96,7 +108,7 @@ public class CompSym { public static final int NOTGT = 77; public static final int SEQ = 96; public static final int GTE = 55; - public static final int ID = 113; + public static final int ID = 127; public static final int ONE_ARROW_SOME = 11; public static final int ONE_ARROW_ONE = 12; public static final int COLON = 39; @@ -108,8 +120,10 @@ public class CompSym { public static final int CARET = 37; public static final int EXPECT = 49; public static final int PLUSPLUS = 88; + public static final int HISTORICALLY = 118; public static final int STRING = 107; public static final int RANGE = 91; + public static final int PRIME = 126; public static final int NO = 73; public static final int SOME_ARROW_ONE = 8; public static final int AND = 31; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompUtil.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompUtil.java index 1cb11f191..65f04d3e1 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompUtil.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/parser/CompUtil.java @@ -38,7 +38,9 @@ import edu.mit.csail.sdg.alloy4.Pos; import edu.mit.csail.sdg.alloy4.Util; import edu.mit.csail.sdg.ast.Command; +import edu.mit.csail.sdg.ast.Decl; import edu.mit.csail.sdg.ast.Expr; +import edu.mit.csail.sdg.ast.ExprBinary; import edu.mit.csail.sdg.ast.ExprCall; import edu.mit.csail.sdg.ast.ExprUnary; import edu.mit.csail.sdg.ast.ExprUnary.Op; @@ -52,6 +54,9 @@ /** * This class provides convenience methods for calling the parser and the * compiler. + * + * @modified [electrum] helper method to determine whether a model is fully + * static (classic Alloy); */ public final class CompUtil { @@ -59,7 +64,8 @@ public final class CompUtil { /** * Constructor is private, since this class never needs to be instantiated. */ - private CompUtil() {} + private CompUtil() { + } // =============================================================================================================// @@ -171,7 +177,46 @@ public Object visit(ExprUnary x) throws Err { }); if (intTriggerNode != null) return true; - } catch (Err e) {} + } catch (Err e) { + } + + return false; + } + + /** + * Whether the given command is a temporal model (either there are variable + * sigs/fields or temporal operators in the formula). + */ + public static boolean isTemporalModel(Iterable sigs, Command cmd) { + for (Sig sig : sigs) { + if (sig.isVariable != null && !sig.builtin) + return true; + else { + for (Decl dec : sig.getFieldDecls()) { + if (dec.isVar != null) + return true; + } + } + } + Object varTriggerNode; + varTriggerNode = cmd.formula.accept(new VisitQueryOnce() { + + @Override + public Object visit(ExprUnary x) throws Err { + if (x.op == Op.AFTER || x.op == Op.BEFORE || x.op == Op.PRIME || x.op == Op.HISTORICALLY || x.op == Op.ALWAYS || x.op == Op.ONCE || x.op == Op.EVENTUALLY) + return x; + return super.visit(x); + } + + @Override + public Object visit(ExprBinary x) throws Err { + if (x.op == ExprBinary.Op.UNTIL || x.op == ExprBinary.Op.SINCE || x.op == ExprBinary.Op.TRIGGERED || x.op == ExprBinary.Op.RELEASES) + return x; + return super.visit(x); + } + }); + if (varTriggerNode != null) + return true; return false; } @@ -245,7 +290,8 @@ private static CompModule parseRecursively(List seenDollar, Map + * Default value is off. + */ + public int decompose_mode = 0; + + /** + * This option specifies the number of threads when following a decompose + * strategy + *

+ * Default value is 4. + */ + public int decompose_threads = 4; + /** This method makes a copy of this Options object. */ public A4Options dup() { A4Options x = new A4Options(); @@ -302,6 +335,8 @@ public A4Options dup() { x.recordKodkod = recordKodkod; x.noOverflow = noOverflow; x.coreGranularity = coreGranularity; + x.decompose_mode = decompose_mode; + x.decompose_threads = decompose_threads; return x; } } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4Solution.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4Solution.java index ab121d04e..d9c712c75 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4Solution.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4Solution.java @@ -25,10 +25,13 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -38,9 +41,9 @@ import java.util.Set; import java.util.stream.Collectors; -import org.alloytools.alloy.core.AlloyCore; import org.alloytools.util.table.Table; +import edu.mit.csail.sdg.alloy4.A4Preferences; import edu.mit.csail.sdg.alloy4.A4Reporter; import edu.mit.csail.sdg.alloy4.ConstList; import edu.mit.csail.sdg.alloy4.ConstMap; @@ -64,6 +67,7 @@ import edu.mit.csail.sdg.ast.Sig; import edu.mit.csail.sdg.ast.Sig.Field; import edu.mit.csail.sdg.ast.Sig.PrimSig; +import edu.mit.csail.sdg.ast.Sig.SubsetSig; import edu.mit.csail.sdg.ast.Type; import edu.mit.csail.sdg.translator.A4Options.SatSolver; import kodkod.ast.BinaryExpression; @@ -77,21 +81,32 @@ import kodkod.ast.Variable; import kodkod.ast.operator.ExprOperator; import kodkod.ast.operator.FormulaOperator; +import kodkod.engine.AbstractKodkodSolver; import kodkod.engine.CapacityExceededException; import kodkod.engine.Evaluator; +import kodkod.engine.Explorer; +import kodkod.engine.InvalidSolverParamException; +import kodkod.engine.PardinusSolver; import kodkod.engine.Proof; import kodkod.engine.Solution; -import kodkod.engine.Solver; import kodkod.engine.config.AbstractReporter; +import kodkod.engine.config.DecomposedOptions.DMode; +import kodkod.engine.config.ExtendedOptions; import kodkod.engine.config.Options; import kodkod.engine.config.Reporter; +import kodkod.engine.config.SLF4JReporter; import kodkod.engine.fol2sat.TranslationRecord; import kodkod.engine.fol2sat.Translator; +import kodkod.engine.ltl2fol.InvalidMutableExpressionException; +import kodkod.engine.ltl2fol.TemporalBoundsExpander; import kodkod.engine.satlab.SATFactory; import kodkod.engine.ucore.HybridStrategy; import kodkod.engine.ucore.RCEStrategy; +import kodkod.engine.unbounded.InvalidUnboundedProblem; import kodkod.instance.Bounds; import kodkod.instance.Instance; +import kodkod.instance.PardinusBounds; +import kodkod.instance.TemporalInstance; import kodkod.instance.Tuple; import kodkod.instance.TupleFactory; import kodkod.instance.TupleSet; @@ -102,6 +117,19 @@ * This class stores a SATISFIABLE or UNSATISFIABLE solution. It is also used as * a staging area for the solver before generating the solution. Once solve() * has been called, then this object becomes immutable after that. + * + * @modified [electrum] adapted to support temporal problems (including + * decomposed); evaluation now also acts at a particular state + * (caching also per state); better handling of backend runtime + * errors, including: + * + * invalid mutable expressions (eg, total order over mutable + * elements); invalid steps scope for solvers (eg, open intervals not + * starting in 1); invalid iteration operations; setting an unbounded + * steps scope with a bounded solver + * + * supports additional iteration operations provided by the kodkod + * backend */ public final class A4Solution { @@ -162,6 +190,16 @@ public final class A4Solution { */ private final int maxseq; + /** + * The maximum allowed trace length; -1 if static model. + */ + private final int maxtrace; + + /** + * The minimum allowed trace length; -1 if static model. + */ + private final int mintrace; + /** * The maximum allowed number of loop unrolling and recursion level. */ @@ -183,7 +221,7 @@ public final class A4Solution { private final TupleSet stringBounds; /** The Kodkod Solver object. */ - private final Solver solver; + private final PardinusSolver solver; // ====== mutable fields (immutable after solve() has been called) // ===================================// @@ -192,7 +230,7 @@ public final class A4Solution { private boolean solved = false; /** The Kodkod Bounds object. */ - private Bounds bounds; + private PardinusBounds bounds; /** * The list of Kodkod formulas; can be empty if unknown; once a solution is @@ -232,7 +270,7 @@ public final class A4Solution { private Evaluator eval = null; /** If not null, you can ask it to get another solution. */ - private Iterator kEnumerator = null; + private Explorer kEnumerator = null; /** * The map from each Sig/Field/Skolem/Atom to its corresponding Kodkod @@ -279,7 +317,7 @@ public final class A4Solution { * @param expected - whether the user expected an instance or not (1 means yes, * 0 means no, -1 means the user did not express an expectation) */ - A4Solution(String originalCommand, int bitwidth, int maxseq, Set stringAtoms, Collection atoms, final A4Reporter rep, A4Options opt, int expected) throws Err { + A4Solution(String originalCommand, int bitwidth, int mintrace, int maxtrace, int maxseq, Set stringAtoms, Collection atoms, final A4Reporter rep, A4Options opt, int expected) throws Err { opt = opt.dup(); this.unrolls = opt.unrolls; this.sigs = new SafeList(Arrays.asList(UNIV, SIGINT, SEQIDX, STRING, NONE)); @@ -293,20 +331,25 @@ public final class A4Solution { this.originalCommand = (originalCommand == null ? "" : originalCommand); this.bitwidth = bitwidth; this.maxseq = maxseq; + this.maxtrace = maxtrace; + this.mintrace = mintrace; + // [electrum] test whether unbounded solver + if (maxtrace == Integer.MAX_VALUE && !(opt.solver.external() != null && opt.solver.external().equals("electrod"))) + throw new ErrorAPI("Bounded engines do not support open bounds on steps."); if (bitwidth < 0) - throw new ErrorSyntax("Cannot specify a bitwidth less than 0"); + throw new ErrorSyntax("Cannot specify a bitwidth less than 0."); if (bitwidth > 30) - throw new ErrorSyntax("Cannot specify a bitwidth greater than 30"); + throw new ErrorSyntax("Cannot specify a bitwidth greater than 30."); if (maxseq < 0) throw new ErrorSyntax("The maximum sequence length cannot be negative."); if (maxseq > 0 && maxseq > max()) - throw new ErrorSyntax("With integer bitwidth of " + bitwidth + ", you cannot have sequence length longer than " + max()); + throw new ErrorSyntax("With integer bitwidth of " + bitwidth + ", you cannot have sequence length longer than " + max() + "."); if (atoms.isEmpty()) { atoms = new ArrayList(1); atoms.add(""); } kAtoms = ConstList.make(atoms); - bounds = new Bounds(new Universe(kAtoms)); + bounds = new PardinusBounds(new Universe(kAtoms)); factory = bounds.universe().factory(); TupleSet sigintBounds = factory.noneOf(1); TupleSet seqidxBounds = factory.noneOf(1); @@ -347,80 +390,127 @@ public final class A4Solution { this.stringBounds = stringBounds.unmodifiableView(); bounds.boundExactly(KK_STRING, this.stringBounds); int sym = (expected == 1 ? 0 : opt.symmetry); - solver = new Solver(); - solver.options().setNoOverflow(opt.noOverflow); + // [electrum] set temporal solving options + ExtendedOptions solver_opts = new ExtendedOptions(); + solver_opts.setReporter(new SLF4JReporter()); + solver_opts.setRunTemporal(maxtrace > 0); + solver_opts.setNoOverflow(opt.noOverflow); + solver_opts.setMaxTraceLength(maxtrace); + solver_opts.setMinTraceLength(mintrace); + solver_opts.setRunUnbounded(maxtrace == Integer.MAX_VALUE); + if (opt.decompose_mode > 0) { + solver_opts.setRunDecomposed(true); + if (opt.decompose_mode == 1) + solver_opts.setDecomposedMode(DMode.HYBRID); + else + solver_opts.setDecomposedMode(DMode.PARALLEL); + if (opt.decompose_threads > 0) + solver_opts.setThreads(opt.decompose_threads); + } else { + solver_opts.setRunDecomposed(false); + } // solver.options().setFlatten(false); // added for now, since // multiplication and division circuit takes forever to flatten - if (opt.solver.external() != null) { + // [electrum] pushed solver creation further below as solver choice is needed for initialization + if (opt.solver.id().equals(A4Options.SatSolver.ElectrodS.id())) { + String[] nopts = new String[opt.solver.options().length + 2]; + System.arraycopy(opt.solver.options(), 0, nopts, 2, opt.solver.options().length); + nopts[0] = "-t"; + nopts[1] = "NuSMV"; + solver_opts.setSolver(SATFactory.electrod(nopts)); + } else if (opt.solver.id().equals(A4Options.SatSolver.ElectrodX.id())) { + String[] nopts = new String[opt.solver.options().length + 2]; + System.arraycopy(opt.solver.options(), 0, nopts, 2, opt.solver.options().length); + nopts[0] = "-t"; + nopts[1] = "nuXmv"; + solver_opts.setSolver(SATFactory.electrod(nopts)); + } else if (opt.solver.external() != null) { String ext = opt.solver.external(); if (opt.solverDirectory.length() > 0 && ext.indexOf(File.separatorChar) < 0) ext = opt.solverDirectory + File.separatorChar + ext; try { File tmp = File.createTempFile("tmp", ".cnf", new File(opt.tempDirectory)); tmp.deleteOnExit(); - solver.options().setSolver(SATFactory.externalFactory(ext, tmp.getAbsolutePath(), opt.solver.options())); + solver_opts.setSolver(SATFactory.externalFactory(ext, tmp.getAbsolutePath(), false, false, opt.solver.options())); // solver.options().setSolver(SATFactory.externalFactory(ext, // tmp.getAbsolutePath(), opt.solver.options())); } catch (IOException ex) { throw new ErrorFatal("Cannot create temporary directory.", ex); } } else if (opt.solver.equals(A4Options.SatSolver.LingelingJNI)) { - solver.options().setSolver(SATFactory.Lingeling); + solver_opts.setSolver(SATFactory.Lingeling); } else if (opt.solver.equals(A4Options.SatSolver.PLingelingJNI)) { - solver.options().setSolver(SATFactory.plingeling(4, null)); + solver_opts.setSolver(SATFactory.plingeling(4, null)); } else if (opt.solver.equals(A4Options.SatSolver.GlucoseJNI)) { - solver.options().setSolver(SATFactory.Glucose); + solver_opts.setSolver(SATFactory.Glucose); } else if (opt.solver.equals(A4Options.SatSolver.Glucose41JNI)) { - solver.options().setSolver(SATFactory.Glucose41); + throw new UnsupportedOperationException("Glucose 4.1 still not supported by Pardinus."); + // solver_opts.setSolver(SATFactory.Glucose41); } else if (opt.solver.equals(A4Options.SatSolver.CryptoMiniSatJNI)) { - solver.options().setSolver(SATFactory.CryptoMiniSat); + solver_opts.setSolver(SATFactory.CryptoMiniSat); } else if (opt.solver.equals(A4Options.SatSolver.MiniSatJNI)) { - solver.options().setSolver(SATFactory.MiniSat); + solver_opts.setSolver(SATFactory.MiniSat); } else if (opt.solver.equals(A4Options.SatSolver.MiniSatProverJNI)) { sym = 20; - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setLogTranslation(2); - solver.options().setCoreGranularity(opt.coreGranularity); + solver_opts.setSolver(SATFactory.MiniSatProver); + solver_opts.setLogTranslation(2); + solver_opts.setCoreGranularity(opt.coreGranularity); } else { - solver.options().setSolver(SATFactory.DefaultSAT4J); // Even for - // "KK" and - // "CNF", we - // choose - // SAT4J - // here; - // later, - // just - // before - // solving, - // we'll - // change it - // to a - // Write2CNF - // solver + // Even for "KK" and "CNF", we choose SAT4J here; later, just before solving, we'll change it to a Write2CNF solver + solver_opts.setSolver(SATFactory.DefaultSAT4J); + } + solver_opts.setSymmetryBreaking(sym); + solver_opts.setSkolemDepth(opt.skolemDepth); + solver_opts.setBitwidth(bitwidth > 0 ? bitwidth : (int) Math.ceil(Math.log(atoms.size())) + 1); + solver_opts.setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); + // [electrum] create unique readable name, allows some traceability at backend level + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm"); + String file = "untitled"; + if (!getOriginalFilename().isEmpty()) { + String[] pths = getOriginalFilename().split("/"); + file = pths[pths.length - 1].substring(0, pths[pths.length - 1].length() - 4).replace(' ', '_'); } - solver.options().setSymmetryBreaking(sym); - solver.options().setSkolemDepth(opt.skolemDepth); - solver.options().setBitwidth(bitwidth > 0 ? bitwidth : (int) Math.ceil(Math.log(atoms.size())) + 1); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); + String check = getOriginalCommand().replace(' ', '_').replace('$', '-'); + solver_opts.setUniqueName(file + "-" + check + "-" + dateFormat.format(new Date()) + "-" + this.hashCode()); + solver = new PardinusSolver(solver_opts); } /** * Construct a new A4Solution that is the continuation of the old one, but with - * the "next" instance. + * the "next" instance. An additional parameter determines how to calculate this + * "next" (-3 standard next, -2 next path, -1 next config, >=0 fork at state). */ - private A4Solution(A4Solution old) throws Err { + private A4Solution(A4Solution old, int state) throws Err { if (!old.solved) throw new ErrorAPI("This solution is not yet solved, so next() is not allowed."); if (old.kEnumerator == null) throw new ErrorAPI("This solution was not generated by an incremental SAT solver.\n" + "Solution enumeration is currently only implemented for MiniSat and SAT4J."); if (old.eval == null) throw new ErrorAPI("This solution is already unsatisfiable, so you cannot call next() to get the next solution."); - Instance inst = old.kEnumerator.next().instance(); + Instance inst; + // [electrum] better reporting of unsupported iterations + try { + if (state == -1) // [electrum] this is a next config + inst = old.kEnumerator.nextC().instance(); + else if (state == -2) // [electrum] this is a next path + inst = old.kEnumerator.nextP().instance(); + else if (state >= 0) { // [electrum] this is a fork at "state" + Set rels = ((TemporalInstance) old.eval.instance()).state(0).relations().stream().filter(r -> r.isVariable()).collect(Collectors.toSet()); + inst = old.kEnumerator.nextS(state, 1, rels).instance(); + } else + inst = old.kEnumerator.next().instance(); + } catch (UnsupportedOperationException e) { + throw new ErrorAPI(e.getMessage()); + } + if (inst != null && !(inst instanceof TemporalInstance)) + inst = new TemporalInstance(Arrays.asList(inst), 0, 1); unrolls = old.unrolls; originalOptions = old.originalOptions; originalCommand = old.originalCommand; bitwidth = old.bitwidth; maxseq = old.maxseq; + maxtrace = old.maxtrace; + mintrace = old.mintrace; kAtoms = old.kAtoms; factory = old.factory; sigintBounds = old.sigintBounds; @@ -489,6 +579,20 @@ public int getMaxSeq() { return maxseq; } + /** + * Returns the maximum allowed trace length; -1 if static model. + */ + public int getMaxTrace() { + return maxtrace; + } + + /** + * Returns the minimum allowed trace length; -1 if static model. + */ + public int getMinTrace() { + return mintrace; + } + /** * Returns the largest allowed integer, or -1 if no integers are allowed. */ @@ -536,9 +640,9 @@ public String getOriginalCommand() { */ public String debugExtractKInput() { if (solved) - return TranslateKodkodToJava.convert(Formula.and(formulas), bitwidth, kAtoms, bounds, atom2name); + return TranslateKodkodToJava.convert(Formula.and(formulas), bitwidth, kAtoms, bounds, atom2name, mintrace, maxtrace); else - return TranslateKodkodToJava.convert(Formula.and(formulas), bitwidth, kAtoms, bounds.unmodifiableView(), null); + return TranslateKodkodToJava.convert(Formula.and(formulas), bitwidth, kAtoms, bounds.unmodifiableView(), null, mintrace, maxtrace); } // ===================================================================================================// @@ -556,17 +660,42 @@ Bounds getBounds() { } /** - * Add a new relation with the given label and the given lower and upper bound. + * Add a new relation with the given label and the given lower and upper bound + * with variable information that could not be retrieved when expr + * is null (static instances) by + * {@link #addRel(String, TupleSet, TupleSet, Expr)}. + * + * @param label - the label for the new relation; need not be unique + * @param lower - the lowerbound; can be null if you want it to be the empty set + * @param upper - the upperbound; cannot be null; must contain everything in + * lowerbound + */ + Relation addRel(String label, TupleSet lower, TupleSet upper, boolean var) throws ErrorFatal { + if (solved) + throw new ErrorFatal("Cannot add a Kodkod relation since solve() has completed."); + Relation rel; + if (var) + rel = Relation.variable(label, upper.arity()); + else + rel = Relation.nary(label, upper.arity()); + + addPreRel(label, lower, upper, rel); + + return rel; + } + + /** + * Add a new relation with the given label and the given lower and upper bound + * without creating a new object. * * @param label - the label for the new relation; need not be unique * @param lower - the lowerbound; can be null if you want it to be the empty set * @param upper - the upperbound; cannot be null; must contain everything in * lowerbound */ - Relation addRel(String label, TupleSet lower, TupleSet upper) throws ErrorFatal { + void addPreRel(String label, TupleSet lower, TupleSet upper, Relation rel) throws ErrorFatal { if (solved) throw new ErrorFatal("Cannot add a Kodkod relation since solve() has completed."); - Relation rel = Relation.nary(label, upper.arity()); if (lower == upper) { bounds.boundExactly(rel, upper); } else if (lower == null) { @@ -576,9 +705,9 @@ Relation addRel(String label, TupleSet lower, TupleSet upper) throws ErrorFatal throw new ErrorFatal("Relation " + label + " must have same arity for lowerbound and upperbound."); bounds.bound(rel, lower, upper); } - return rel; } + /** * Add a new sig to this solution and associate it with the given expression * (and if s.isTopLevel then add this expression into Sig.UNIV).
@@ -733,7 +862,10 @@ Expression a2k(Expr expr) throws ErrorFatal { * given expression. */ TupleSet approximate(Expression expression) { - return factory.setOf(expression.arity(), Translator.approximate(expression, bounds, solver.options()).denseIndices()); + PardinusBounds b = bounds.clone(); + b.resolve(new AbstractReporter() { + }); + return factory.setOf(expression.arity(), Translator.approximate(expression, b, solver.options()).denseIndices()); } /** @@ -750,6 +882,8 @@ TupleSet query(boolean findUpper, Expression expr, boolean makeMutable) throws E if (expr == KK_STRING) return makeMutable ? stringBounds.clone() : stringBounds; if (expr instanceof Relation) { + if (bounds.lowerSymbBound((Relation) expr) != null) + return query(findUpper, findUpper ? bounds.upperSymbBound((Relation) expr) : bounds.lowerSymbBound((Relation) expr), makeMutable); TupleSet ans = findUpper ? bounds.upperBound((Relation) expr) : bounds.lowerBound((Relation) expr); if (ans != null) return makeMutable ? ans.clone() : ans; @@ -785,6 +919,8 @@ void shrink(Relation relation, TupleSet lowerBound, TupleSet upperBound) throws } } + + // ===================================================================================================// /** @@ -802,6 +938,21 @@ public SafeList getAllReachableSigs() { return sigs.dup(); } + /** + * Checks whether the this solution's model contains any configuration (static) + * elements. + */ + public boolean hasConfigs() { + for (Sig s : sigs) { + if (s.isVariable == null && !s.builtin) + return true; + for (edu.mit.csail.sdg.ast.Decl f : s.getFieldDecls()) + if (f.isVar == null) + return true; + } + return false; + } + /** * Returns an unmodifiable copy of the list of all skolems if the problem is * solved and is satisfiable; else returns an empty list. @@ -818,6 +969,16 @@ public Iterable getAllAtoms() { return atoms.dup(); } + /** Returns the back loop instance of this instance (should always exist). */ + public int getLoopState() { + return ((TemporalInstance) eval.instance()).loop; + } + + /** Returns the length of the finite prefix. */ + public int getTraceLength() { + return ((TemporalInstance) eval.instance()).prefixLength(); + } + /** * Returns the short unique name corresponding to the given atom if the problem * is solved and is satisfiable; else returns atom.toString(). @@ -837,42 +998,63 @@ PrimSig atom2sig(Object atom) { } /** Caches eval(Sig) and eval(Field) results. */ - private Map evalCache = new LinkedHashMap(); + // [electrum] cache per state + private Map> evalCache = new LinkedHashMap>(); /** * Return the A4TupleSet for the given sig (if solution not yet solved, or - * unsatisfiable, or sig not found, then return an empty tupleset) + * unsatisfiable, or sig not found, then return an empty tupleset). */ public A4TupleSet eval(Sig sig) { + return eval(sig, 0); + } + + /** + * Return the A4TupleSet for the given sig (if solution not yet solved, or + * unsatisfiable, or sig not found, then return an empty tupleset). + */ + public A4TupleSet eval(Sig sig, int state) { try { if (!solved || eval == null) return new A4TupleSet(factory.noneOf(1), this); - A4TupleSet ans = evalCache.get(sig); + if (evalCache.get(state) == null) + evalCache.put(state, new LinkedHashMap()); + A4TupleSet ans = evalCache.get(state).get(sig); if (ans != null) return ans; - TupleSet ts = eval.evaluate((Expression) TranslateAlloyToKodkod.alloy2kodkod(this, sig)); + TupleSet ts = eval.evaluate((Expression) TranslateAlloyToKodkod.alloy2kodkod(this, sig), state); ans = new A4TupleSet(ts, this); - evalCache.put(sig, ans); + evalCache.get(state).put(sig, ans); return ans; } catch (Err er) { return new A4TupleSet(factory.noneOf(1), this); } + } /** * Return the A4TupleSet for the given field (if solution not yet solved, or - * unsatisfiable, or field not found, then return an empty tupleset) + * unsatisfiable, or field not found, then return an empty tupleset). */ public A4TupleSet eval(Field field) { + return eval(field, 0); + } + + /** + * Return the A4TupleSet for the given field (if solution not yet solved, or + * unsatisfiable, or field not found, then return an empty tupleset). + */ + public A4TupleSet eval(Field field, int state) { try { if (!solved || eval == null) return new A4TupleSet(factory.noneOf(field.type().arity()), this); - A4TupleSet ans = evalCache.get(field); - if (ans != null) - return ans; - TupleSet ts = eval.evaluate((Expression) TranslateAlloyToKodkod.alloy2kodkod(this, field)); + if (evalCache.get(state) == null) + evalCache.put(state, new LinkedHashMap()); + A4TupleSet ans = evalCache.get(state).get(field); + //if (ans!=null) return ans; + TupleSet ts = eval.evaluate((Expression) TranslateAlloyToKodkod.alloy2kodkod(this, field), state); ans = new A4TupleSet(ts, this); - evalCache.put(field, ans); + evalCache.get(state).put(field, ans); return ans; } catch (Err er) { return new A4TupleSet(factory.noneOf(field.type().arity()), this); @@ -884,11 +1066,19 @@ public A4TupleSet eval(Field field) { * and returns an A4TupleSet, a java Integer, or a java Boolean. */ public Object eval(Expr expr) throws Err { + return eval(expr, 0); + } + + /** + * If this solution is solved and satisfiable, evaluates the given expression at + * the given state and returns an A4TupleSet, a java Integer, or a java Boolean. + */ + public Object eval(Expr expr, int state) throws Err { try { if (expr instanceof Sig) - return eval((Sig) expr); + return eval((Sig) expr, state); if (expr instanceof Field) - return eval((Field) expr); + return eval((Field) expr, state); if (!solved) throw new ErrorAPI("This solution is not yet solved, so eval() is not allowed."); if (eval == null) @@ -899,11 +1089,11 @@ public Object eval(Expr expr) throws Err { throw expr.errors.pick(); Object result = TranslateAlloyToKodkod.alloy2kodkod(this, expr); if (result instanceof IntExpression) - return eval.evaluate((IntExpression) result) + (eval.wasOverflow() ? " (OF)" : ""); + return eval.evaluate((IntExpression) result, state) + (eval.wasOverflow() ? " (OF)" : ""); if (result instanceof Formula) - return eval.evaluate((Formula) result); + return eval.evaluate((Formula) result, state); if (result instanceof Expression) - return new A4TupleSet(eval.evaluate((Expression) result), this); + return new A4TupleSet(eval.evaluate((Expression) result, state), this); throw new ErrorFatal("Unknown internal error encountered in the evaluator."); } catch (CapacityExceededException ex) { throw TranslateAlloyToKodkod.rethrow(ex); @@ -1069,10 +1259,10 @@ void addFormula(Formula newFormula, Expr expr) throws Err { * Helper class that wraps an iterator up where it will pre-fetch the first * element (note: it will not prefetch subsequent elements). */ - private static final class Peeker implements Iterator { + private static final class Peeker implements Explorer { /** The encapsulated iterator. */ - private Iterator iterator; + private Explorer iterator; /** True iff we have captured the first element. */ private boolean hasFirst; /** @@ -1081,7 +1271,7 @@ private static final class Peeker implements Iterator { private T first; /** Constructrs a Peeker object. */ - private Peeker(Iterator it) { + private Peeker(Explorer it) { iterator = it; if (it.hasNext()) { hasFirst = true; @@ -1112,6 +1302,31 @@ public T next() { public void remove() { throw new UnsupportedOperationException(); } + + @Override + public T nextC() { + return iterator.nextC(); + } + + @Override + public T nextP() { + return iterator.nextP(); + } + + @Override + public T nextS(int state, int delta, Set change) { + return iterator.nextS(state, delta, change); + } + + @Override + public boolean hasNextP() { + return iterator.hasNextP(); + } + + @Override + public boolean hasNextC() { + return iterator.hasNextC(); + } } // ===================================================================================================// @@ -1278,9 +1493,11 @@ private static void rename(A4Solution frame, PrimSig s, Map> nex for (PrimSig c : s.children()) rename(frame, c, nexts, un); String signame = un.make(s.label.startsWith("this/") ? s.label.substring(5) : s.label); + // [electrum] collect atoms from every state List list = new ArrayList(); - for (Tuple t : frame.eval.evaluate(frame.a2k(s))) - list.add(t); + for (int i = 0; i < frame.getTraceLength(); i++) + for (Tuple t : frame.eval.evaluate(frame.a2k(s), i)) + list.add(t); List order = nexts.get(s); if (order != null && order.size() == list.size() && order.containsAll(list)) { list = order; @@ -1288,15 +1505,14 @@ private static void rename(A4Solution frame, PrimSig s, Map> nex int i = 0; for (Tuple t : list) { if (frame.atom2sig.containsKey(t.atom(0))) - continue; // This means one of the subsig has already claimed - // this atom. + continue; // This means one of the subsig has already claimed this atom. String x = signame + "$" + i; i++; frame.atom2sig.put(t.atom(0), s); frame.atom2name.put(t.atom(0), x); ExprVar v = ExprVar.make(null, x, s.type()); TupleSet ts = t.universe().factory().range(t, t); - Relation r = Relation.unary(x); + Relation r = Relation.atom(x); // [electrum] set to atom relation frame.eval.instance().add(r, ts); frame.a2k.put(v, r); frame.atoms.add(v); @@ -1305,6 +1521,50 @@ private static void rename(A4Solution frame, PrimSig s, Map> nex // ===================================================================================================// + + /** + * Solve for the solution if not solved already simply using the lowerbound of + * each relation as its value. For trace solutions should be called iteratively, + * and will build on the information from the previous steps. + */ + // [electrum] this is the method now called, iteratively, by the static reader; + // it reads a state at a time, and the solution is built incrementally + A4Solution solve(final A4Reporter rep, A4Solution pre_sol, int loop) throws Err, IOException { + // construct the instance from the current state + Universe static_uni; + if (pre_sol != null) + static_uni = ((TemporalInstance) pre_sol.eval.instance()).staticUniverse(); + else + static_uni = bounds.universe(); + Instance inst = new Instance(static_uni); + for (int max = max(), i = min(); i <= max; i++) { + Tuple it = static_uni.factory().tuple("" + i); + inst.add(i, static_uni.factory().range(it, it)); + } + for (Relation r : bounds.relations()) + inst.add(r, TemporalBoundsExpander.convertToUniv(bounds.lowerBound(r), static_uni)); + + // retrieve previous steps of the trace + List instances = new ArrayList(); + if (pre_sol != null) { + for (int i = 0; i < ((TemporalInstance) pre_sol.eval.instance()).prefixLength(); i++) + instances.add(((TemporalInstance) pre_sol.eval.instance()).state(i)); + } + instances.add(inst); + + if (loop >= instances.size()) + loop = instances.size() - 1; + + // create temporal instance + TemporalInstance prev = new TemporalInstance(instances, loop, 1); + eval = new Evaluator(prev, solver.options()); + rename(this, null, null, new UniqueNameGenerator()); + toStringCache.clear(); + evalCache = new HashMap<>(); + solved(); + return this; + } + /** * Solve for the solution if not solved already; if cmd==null, we will simply * use the lowerbound of each relation as its value. @@ -1315,18 +1575,9 @@ A4Solution solve(final A4Reporter rep, Command cmd, Simplifier simp, boolean try return this; // If cmd==null, then all four arguments are ignored, and we simply use // the lower bound of each relation + // [electrum] behaviour refactored into A4Solution#solve(A4Reporter,A4Solution,int) if (cmd == null) { - Instance inst = new Instance(bounds.universe()); - for (int max = max(), i = min(); i <= max; i++) { - Tuple it = factory.tuple("" + i); - inst.add(i, factory.range(it, it)); - } - for (Relation r : bounds.relations()) - inst.add(r, bounds.lowerBound(r)); - eval = new Evaluator(inst, solver.options()); - rename(this, null, null, new UniqueNameGenerator()); - solved(); - return this; + throw new RuntimeException("Should not be null, refactored."); } // Otherwise, prepare to do the solve... final A4Options opt = originalOptions; @@ -1334,7 +1585,7 @@ A4Solution solve(final A4Reporter rep, Command cmd, Simplifier simp, boolean try rep.debug("Simplifying the bounds...\n"); if (opt.inferPartialInstance && simp != null && formulas.size() > 0 && !simp.simplify(rep, this, formulas)) addFormula(Formula.FALSE, Pos.UNKNOWN); - rep.translate(opt.solver.id(), bitwidth, maxseq, solver.options().skolemDepth(), solver.options().symmetryBreaking()); + rep.translate(opt.solver.id(), bitwidth, maxseq, mintrace, maxtrace, solver.options().skolemDepth(), solver.options().symmetryBreaking(), A4Preferences.Decompose.values()[opt.decompose_mode].toString()); Formula fgoal = Formula.and(formulas); rep.debug("Generating the solution...\n"); kEnumerator = null; @@ -1343,11 +1594,8 @@ A4Solution solve(final A4Reporter rep, Command cmd, Simplifier simp, boolean try final boolean solved[] = new boolean[] { true }; - solver.options().setReporter(new AbstractReporter() { // Set up a - // reporter to - // catch the - // type+pos of - // skolems + // [electrum] sl4j reporter for backend + solver.options().setReporter(new SLF4JReporter() { // Set up a reporter to catch the type+pos of skolems @Override public void skolemizing(Decl decl, Relation skolem, List predecl) { @@ -1362,30 +1610,33 @@ public void skolemizing(Decl decl, Relation skolem, List predecl) { t = pp.product(t); } kr2type(skolem, t); - } catch (Throwable ex) {} // Exception here is not fatal + } catch (Throwable ex) { + } // Exception here is not fatal } @Override - public void solvingCNF(int primaryVars, int vars, int clauses) { - if (solved[0]) - return; - else - solved[0] = true; // initially solved[0] is true, so we - // won't report the # of vars/clauses + // [electrum] synchronized due to multiple parallel problems reporting + public synchronized void solvingCNF(int step, int primaryVars, int vars, int clauses) { + // [electrum] this is now called multiple times during iterative temporal solving + // if (solved[0]) + // return; + // else + solved[0] = true; // initially solved[0] is true, so we + // won't report the # of vars/clauses if (rep != null) - rep.solve(primaryVars, vars, clauses); + rep.solve(step, primaryVars, vars, clauses); } + }); - if (!opt.solver.equals(SatSolver.CNF) && !opt.solver.equals(SatSolver.KK) && tryBookExamples) { // try - // book - // examples - A4Reporter r = AlloyCore.isDebug() ? rep : null; + if (!opt.solver.equals(SatSolver.CNF) && !opt.solver.equals(SatSolver.KK) && tryBookExamples) { // try book examples + A4Reporter r = "yes".equals(System.getProperty("debug")) ? rep : null; try { - sol = BookExamples.trial(r, this, fgoal, solver, cmd.check); + sol = BookExamples.trial(r, this, fgoal, (AbstractKodkodSolver) solver.solver, cmd.check); } catch (Throwable ex) { sol = null; } } + solved[0] = false; // this allows the reporter to report the # of // vars/clauses for (Relation r : bounds.relations()) { @@ -1418,19 +1669,34 @@ public void solvingCNF(int primaryVars, int vars, int clauses) { rep.resultCNF(out); return null; } - if (!solver.options().solver().incremental() /* - * || solver.options().solver()==SATFactory. ZChaffMincost - */) { - if (sol == null) - sol = solver.solve(fgoal, bounds); + if (/* solver.options().solver()==SATFactory.ZChaffMincost || */ !solver.options().solver().incremental()) { + sol = solver.solve(fgoal, bounds); } else { - kEnumerator = new Peeker(solver.solveAll(fgoal, bounds)); + PardinusBounds b; + if (solver.options().decomposed()) + b = PardinusBounds.splitAtTemporal(bounds); // [electrum] split bounds on temporal + else + b = bounds; + // [electrum] better handling of solving runtime errors + try { + kEnumerator = new Peeker(solver.solveAll(fgoal, b)); + } catch (InvalidMutableExpressionException e) { + Pos p = ((Expr) k2pos(e.node())).pos; + throw new ErrorAPI(p, "Mutable expression not supported by solver.\n"); + } catch (InvalidSolverParamException e) { + throw new ErrorAPI(cmd.pos, "Invalid solver parameters.\n" + e.getMessage()); + } catch (InvalidUnboundedProblem e) { + Pos p = ((Expr) k2pos(e.node())).pos; + throw new ErrorAPI(p, "Invalid specification for complete backend.\n" + e.getMessage()); + } if (sol == null) sol = kEnumerator.next(); } if (!solved[0]) - rep.solve(0, 0, 0); - final Instance inst = sol.instance(); + rep.solve(0, 0, 0, 0); + Instance inst = sol.instance(); + if (inst != null && !(inst instanceof TemporalInstance)) + inst = new TemporalInstance(Arrays.asList(inst), 0, 1); // To ensure no more output during SolutionEnumeration solver.options().setReporter(oldReporter); // If unsatisfiable, then retreive the unsat core if desired @@ -1446,11 +1712,13 @@ public void solvingCNF(int primaryVars, int vars, int clauses) { if (opt.coreMinimization == 0) try { p.minimize(new RCEStrategy(p.log())); - } catch (Throwable ex) {} + } catch (Throwable ex) { + } if (opt.coreMinimization == 1) try { p.minimize(new HybridStrategy(p.log())); - } catch (Throwable ex) {} + } catch (Throwable ex) { + } rep.minimized(cmd, i, p.highLevelCore().size()); } for (Iterator it = p.core(); it.hasNext();) { @@ -1483,21 +1751,34 @@ public void solvingCNF(int primaryVars, int vars, int clauses) { // ===================================================================================================// /** This caches the toString() output. */ - private String toStringCache = null; + // [electrum] cache per state + private final Map toStringCache = new HashMap(); /** Dumps the Kodkod solution into String. */ @Override public String toString() { + return toString(-1); + } + + // [electrum] print particular state, if -1 all + public String toString(int state) { if (!solved) return "---OUTCOME---\nUnknown.\n"; if (eval == null) return "---OUTCOME---\nUnsatisfiable.\n"; - String answer = toStringCache; + String answer = toStringCache.get(state); if (answer != null) return answer; Instance sol = eval.instance(); StringBuilder sb = new StringBuilder(); - sb.append("---INSTANCE---\n" + "integers={"); + sb.append("---INSTANCE---"); + if (sol instanceof TemporalInstance) { + sb.append("\nloop="); + sb.append(getLoopState()); + sb.append("\nend="); + sb.append(getTraceLength() - 1); + } + sb.append("\nintegers={"); boolean firstTuple = true; for (IndexedEntry e : sol.intTuples()) { if (firstTuple) @@ -1511,18 +1792,36 @@ public String toString() { } sb.append("}\n"); try { - for (Sig s : sigs) { - sb.append(s.label).append("=").append(eval(s)).append("\n"); - for (Field f : s.getFields()) - sb.append(s.label).append("<:").append(f.label).append("=").append(eval(f)).append("\n"); - } - for (ExprVar v : skolems) { - sb.append("skolem ").append(v.label).append("=").append(eval(v)).append("\n"); + if (sol instanceof TemporalInstance && state < 0) { + for (int i = 0; i < getTraceLength(); i++) { + sb.append("------State " + i + "-------\n"); + for (Sig s : sigs) { + sb.append(s.label).append("=").append(eval(s, i)).append("\n"); + for (Field f : s.getFields()) + sb.append(s.label).append("<:").append(f.label).append("=").append(eval(f, i)).append("\n"); + } + for (ExprVar v : skolems) { + sb.append("skolem ").append(v.label).append("=").append(eval(v, i)).append("\n"); + } + } + } else { + state = Math.max(0, state); + for (Sig s : sigs) { + sb.append(s.label).append("=").append(eval(s, state)).append("\n"); + for (Field f : s.getFields()) + sb.append(s.label).append("<:").append(f.label).append("=").append(eval(f, state)).append("\n"); + } + for (ExprVar v : skolems) { + sb.append("skolem ").append(v.label).append("=").append(eval(v, state)).append("\n"); + } } - return toStringCache = sb.toString(); } catch (Err er) { - return toStringCache = (""); + toStringCache.put(state, ""); + return toStringCache.get(state); } + toStringCache.put(state, sb.toString()); + return toStringCache.get(state); + } // ===================================================================================================// @@ -1537,13 +1836,27 @@ public String toString() { * @throws ErrorAPI if the solver was not an incremental solver */ public A4Solution next() throws Err { + return fork(-3); + } + + /** + * If this solution is UNSAT, return itself; else return the next solution + * according to the selected operation (which could be SAT or UNSAT). + * + * @throws ErrorAPI if the solver was not an incremental solver + */ + public A4Solution fork(int p) throws Err { if (!solved) throw new ErrorAPI("This solution is not yet solved, so next() is not allowed."); if (eval == null) return this; - if (nextCache == null) - nextCache = new A4Solution(this); - return nextCache; + if (p == -3) { + if (nextCache == null) + nextCache = new A4Solution(this, -3); + return nextCache; + } + + return new A4Solution(this, p); // [electrum] do not cache, may have different arguments } /** @@ -1670,13 +1983,83 @@ public void writeXML(A4Reporter rep, PrintWriter writer, Iterable macros, } public String format() { + return format(-1); + } + + // [electrum] format particular state, if -1 all + public String format(int state) { if (!solved) return "---OUTCOME---\nUnknown.\n"; if (eval == null) return "---OUTCOME---\nUnsatisfiable.\n"; - Map table = TableView.toTable(this, eval.instance(), sigs); + Map table = TableView.toTable(this, eval.instance(), sigs, state); return String.join("\n", table.values().stream().map(x -> x.toString()).collect(Collectors.toSet())); } + /** + * Extract symbolic bounds from the model's signatures and add them to the + * problem's bounds. + */ + protected void addSymbolicBound(Sig s) { + if (s.builtin || s.isTopLevel() || s instanceof PrimSig) + return; + Relation r; + Expression e = a2k.get(s); + if (!(e instanceof Relation)) + return; // happens with sigs defined by equality + else + r = (Relation) e; + if (bounds.lowerBound(r).size() == bounds.upperBound(r).size()) + return; + Expression ke = Expression.NONE; + if (s instanceof PrimSig) + ke = a2k.get(((PrimSig) s).parent); + else + for (Sig ss : ((SubsetSig) s).parents) + ke = ke.union(a2k.get(ss)); + if (ke != Expression.NONE && ke != null) { + bounds.relations().remove(r); + bounds.bound(r, ke); + } + } + + /** + * Extract symbolic bounds from the model's fields and add them to the problem's + * bounds. + */ + protected void addSymbolicBound(Field f) { + Relation r; + Expression e = a2k.get(f); + if (e instanceof Relation) + r = (Relation) e; + else if (e instanceof BinaryExpression && // singleton sig, collapsed relation + ((BinaryExpression) e).op() == ExprOperator.PRODUCT && ((BinaryExpression) e).right() instanceof Relation) + r = (Relation) ((BinaryExpression) e).right(); + else + throw new UnsupportedOperationException(); + if (bounds.lowerBound(r).size() == bounds.upperBound(r).size()) + return; + boolean isOne = f.sig.isOne != null; + boolean isVar = f.sig.isVariable != null; + Type t = isOne && !isVar ? Sig.UNIV.type().join(f.type()) : f.type(); + Expression ub = null; + for (List p : t.fold()) { + Expression upper = null; + for (PrimSig b : p) { + Expression tmp = a2k(b); + if (upper == null) + upper = tmp; + else + upper = upper.product(tmp); + } + if (ub == null) + ub = upper; + else + ub = ub.union(upper); + } + bounds.relations().remove(r); + bounds.bound(r, ub); + } + } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionReader.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionReader.java index 9c28a1ab9..f705e71de 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionReader.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionReader.java @@ -51,12 +51,16 @@ /** * This helper class contains helper routines for reading an A4Solution object * from an XML file. + * + * @modified [electrum] incrementally builds a solution by iteratively reading + * states from the XML; must start by collecting all used atoms, since + * univ varies from state to state */ public final class A4SolutionReader { /** The resulting A4Solution object. */ - private final A4Solution sol; + private A4Solution sol; /** The provided choices of existing Sig and Field. */ private final LinkedHashSet choices = new LinkedHashSet(); @@ -80,7 +84,7 @@ public final class A4SolutionReader { private final Map expr2ts = new LinkedHashMap(); /** The Kodkod tupleset factory. */ - private final TupleFactory factory; + private TupleFactory factory; /** * Helper method that returns true if the given attribute value in the given XML @@ -147,7 +151,8 @@ private TupleSet parseTuples(XMLNode tuples, int arity) throws Err { /** Parse sig/set. */ private Sig parseSig(String id, int depth) throws IOException, Err { Sig ans = id2sig.get(id); - if (ans != null) + // [electrum] identify that has not been processed in this step (ans may be != null from previous steps) + if (ans != null && expr2ts.get(ans) != null) return ans; XMLNode node = nmap.get(id); if (node == null) @@ -163,6 +168,7 @@ private Sig parseSig(String id, int depth) throws IOException, Err { Attr isMeta = yes(node, "meta") ? Attr.META : null; Attr isEnum = yes(node, "enum") ? Attr.ENUM : null; Attr isExact = yes(node, "exact") ? Attr.EXACT : null; + Attr isVar = yes(node, "var") ? Attr.VARIABLE : null; if (yes(node, "builtin")) { if (label.equals(UNIV.label)) { id2sig.put(id, UNIV); @@ -210,7 +216,7 @@ private Sig parseSig(String id, int depth) throws IOException, Err { break; } if (ans == null) { - ans = new PrimSig(label, (PrimSig) parent, isAbstract, isLone, isOne, isSome, isPrivate, isMeta, isEnum); + ans = new PrimSig(label, (PrimSig) parent, isAbstract, isLone, isOne, isSome, isPrivate, isMeta, isEnum, isVar); allsigs.add(ans); } } else { @@ -221,7 +227,7 @@ private Sig parseSig(String id, int depth) throws IOException, Err { break; } if (ans == null) { - ans = new SubsetSig(label, parents, isExact, isLone, isOne, isSome, isPrivate, isMeta); + ans = new SubsetSig(label, parents, isExact, isLone, isOne, isSome, isPrivate, isMeta, isVar); allsigs.add(ans); } } @@ -271,6 +277,7 @@ private Field parseField(String id) throws IOException, Err { String label = label(node); Pos isPrivate = yes(node, "private") ? Pos.UNKNOWN : null; Pos isMeta = yes(node, "meta") ? Pos.UNKNOWN : null; + Pos isVar = yes(node, "var") ? Pos.UNKNOWN : null; Expr type = null; for (XMLNode sub : node) if (sub.is("types")) { @@ -295,8 +302,8 @@ private Field parseField(String id) throws IOException, Err { break; } if (field == null) - field = parent.addTrickyField(Pos.UNKNOWN, isPrivate, null, null, isMeta, new String[] { - label + field = parent.addTrickyField(Pos.UNKNOWN, isPrivate, null, null, isMeta, isVar, new String[] { + label }, UNIV.join(type))[0]; TupleSet ts = parseTuples(node, arity); expr2ts.put(field, ts); @@ -323,100 +330,167 @@ private ExprVar parseSkolem(String id) throws IOException, Err { int arity; if (type == null || (arity = type.type().arity()) < 1) throw new IOException("Skolem " + label + " is maltyped."); - ExprVar var = ExprVar.make(Pos.UNKNOWN, label, type.type()); + // [electrum] try to use previously created expr for skolem, not registered anywhere + ExprVar var = null; + for (Expr exp : expr2ts.keySet()) + if (exp instanceof ExprVar && ((ExprVar) exp).label.equals(label)) + var = (ExprVar) exp; + if (var == null) + var = ExprVar.make(Pos.UNKNOWN, label, type.type()); TupleSet ts = parseTuples(node, arity); expr2ts.put(var, ts); return var; } /** Parse everything. */ + // [electrum] heavily modified to support sequences of nodes, A4Solutions are built incrementally private A4SolutionReader(Iterable sigs, XMLNode xml) throws IOException, Err { - for (Sig s : sigs) - if (!s.builtin) { - allsigs.add(s); - choices.add(s); - for (Field f : s.getFields()) - choices.add(f); - } // find .. if (!xml.is("alloy")) throw new ErrorSyntax("The XML file's root node must be or ."); XMLNode inst = null; + A4Solution prev = null; for (XMLNode sub : xml) if (sub.is("instance")) { inst = sub; break; } + if (inst == null) throw new ErrorSyntax("The XML file must contain an element."); + // set up the basic values of the A4Solution object final int bitwidth = Integer.parseInt(inst.getAttribute("bitwidth")); final int maxseq = Integer.parseInt(inst.getAttribute("maxseq")); + final int tracelength; + final int backloop; + final int maxtrace; + final int mintrace; + try { + mintrace = Integer.parseInt(inst.getAttribute("mintrace")); + maxtrace = Integer.parseInt(inst.getAttribute("maxtrace")); + tracelength = Integer.parseInt(inst.getAttribute("tracelength")); + backloop = Integer.parseInt(inst.getAttribute("backloop")); + } catch (Exception ex) { + throw new ErrorSyntax("Missing trace attributes."); + } final int max = Util.max(bitwidth), min = Util.min(bitwidth); if (bitwidth >= 1 && bitwidth <= 30) for (int i = min; i <= max; i++) { atoms.add(Integer.toString(i)); } - for (XMLNode x : inst) { - String id = x.getAttribute("ID"); - if (id.length() > 0 && (x.is("field") || x.is("skolem") || x.is("sig"))) { - if (nmap.put(id, x) != null) - throw new IOException("ID " + id + " is repeated."); - if (x.is("sig")) { - boolean isString = STRING.label.equals(label(x)) && yes(x, "builtin"); - for (XMLNode y : x) - if (y.is("atom")) { - String attr = y.getAttribute("label"); - atoms.add(attr); - if (isString) - strings.add(attr); - } + + // [electrum] get all atoms of the universe, must traverse all states + for (XMLNode sub : xml) + if (sub.is("instance")) { + inst = sub; + for (XMLNode x : inst) { + if (x.is("sig")) { + boolean isString = STRING.label.equals(label(x)) && yes(x, "builtin"); + for (XMLNode y : x) + if (y.is("atom")) { + String attr = y.getAttribute("label"); + atoms.add(attr); + if (isString) + strings.add(attr); + } + } } } - } - // create the A4Solution object - A4Options opt = new A4Options(); - opt.originalFilename = inst.getAttribute("filename"); - sol = new A4Solution(inst.getAttribute("command"), bitwidth, maxseq, strings, atoms, null, opt, 1); - factory = sol.getFactory(); - // parse all the sigs, fields, and skolems - for (Map.Entry e : nmap.entrySet()) - if (e.getValue().is("sig")) - parseSig(e.getKey(), 0); - for (Map.Entry e : nmap.entrySet()) - if (e.getValue().is("field")) - parseField(e.getKey()); - for (Map.Entry e : nmap.entrySet()) - if (e.getValue().is("skolem")) - parseSkolem(e.getKey()); - for (Sig s : allsigs) - if (!s.builtin) { - TupleSet ts = expr2ts.remove(s); - if (ts == null) - ts = factory.noneOf(1); // If the sig was NOT mentioned in - // the XML file... - Relation r = sol.addRel(s.label, ts, ts); - sol.addSig(s, r); - for (Field f : s.getFields()) { - ts = expr2ts.remove(f); - if (ts == null) - ts = factory.noneOf(f.type().arity()); // If the field - // was NOT - // mentioned in - // the XML - // file... - r = sol.addRel(s.label + "." + f.label, ts, ts); - sol.addField(f, r); + + for (XMLNode sub : xml) + if (sub.is("instance")) { + inst = sub; + + // [electrum] if not first step, retrieve already created sigs + prev = sol; + if (prev != null) + sigs = prev.getAllReachableSigs(); + + for (Sig s : sigs) + if (!s.builtin) { + allsigs.add(s); + choices.add(s); + for (Field f : s.getFields()) + choices.add(f); + } + + nmap.clear(); + expr2ts.clear(); + for (XMLNode x : inst) { + String id = x.getAttribute("ID"); + if (id.length() > 0 && (x.is("field") || x.is("skolem") || x.is("sig"))) { + if (nmap.put(id, x) != null) + throw new IOException("ID " + id + " is repeated."); + } + } + + // create the A4Solution object + A4Options opt = new A4Options(); + opt.originalFilename = inst.getAttribute("filename"); + // [electrum] do not use actual max trace, solution would identify unbounded solving but no unbounded solver + sol = new A4Solution(inst.getAttribute("command"), bitwidth, mintrace, tracelength, maxseq, strings, atoms, null, opt, 1); + factory = sol.getFactory(); + // parse all the sigs, fields, and skolems + for (Map.Entry e : nmap.entrySet()) + if (e.getValue().is("sig")) + parseSig(e.getKey(), 0); + for (Map.Entry e : nmap.entrySet()) + if (e.getValue().is("field")) + parseField(e.getKey()); + for (Map.Entry e : nmap.entrySet()) + if (e.getValue().is("skolem")) + parseSkolem(e.getKey()); + for (Sig s : allsigs) + if (!s.builtin) { + TupleSet ts = expr2ts.remove(s); + if (ts == null) + ts = factory.noneOf(1); // If the sig was NOT mentioned in the XML file... + Relation r; + // [electrum] if first state create the relation + if (prev == null) + r = sol.addRel(s.label, ts, ts, s.isVariable != null); + // [electrum] otherwise use previously created + else { + r = (Relation) prev.a2k(s); + sol.addPreRel(s.label, ts, ts, r); + } + sol.addSig(s, r); + for (Field f : s.getFields()) { + ts = expr2ts.remove(f); + if (ts == null) + ts = factory.noneOf(f.type().arity()); // If the field was NOT mentioned in the XML file... + // [electrum] if first state create the relation + if (prev == null) + r = sol.addRel(s.label + "." + f.label, ts, ts, f.isVariable != null); + // [electrum] otherwise use previously created + else { + r = (Relation) prev.a2k(f); + sol.addPreRel(s.label + "." + f.label, ts, ts, r); + } + sol.addField(f, r); + } + } + for (Map.Entry e : expr2ts.entrySet()) { + ExprVar v = (ExprVar) (e.getKey()); + TupleSet ts = e.getValue(); + Relation r = null; + if (prev == null) + r = sol.addRel(v.label, ts, ts, true); + else { + // [electrum] search for skolem relation, not registered anywhere, but skolems always present in all instances + for (Expr exp : prev.a2k().keySet()) + if (exp instanceof ExprVar && ((Relation) prev.a2k(exp)).name().equals(v.label)) { + r = (Relation) prev.a2k(exp); + break; + } + sol.addPreRel(v.label, ts, ts, r); + } + sol.kr2type(r, v.type()); } + // Done! + sol.solve(null, prev, backloop); // [electrum] merge current solution with previous, if any } - for (Map.Entry e : expr2ts.entrySet()) { - ExprVar v = (ExprVar) (e.getKey()); - TupleSet ts = e.getValue(); - Relation r = sol.addRel(v.label, ts, ts); - sol.kr2type(r, v.type()); - } - // Done! - sol.solve(null, null, null, false); } /** diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionWriter.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionWriter.java index 9b1b53618..f5fd75e82 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionWriter.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/A4SolutionWriter.java @@ -40,6 +40,17 @@ /** * This helper class contains helper routines for writing an A4Solution object * out as an XML file. + * + * @modified [electrum] prints full trace instance into XML; each state is added + * as an XML Instance element; trace meta-data (length, loop, variable + * elements) is also printed; + * + * writing of skolems has been tweaked, in two different scenarios: + * static skolem vars (from existential quantifications) may have + * atoms assigned that do not exist in every state (so it is no longer + * enforced that skolems always belong to a sig); mutable skolem vars + * (from auxiliary functions) may be empty in certain states and + * should still be printed (so empty skolem vars are always printed); */ public final class A4SolutionWriter { @@ -87,7 +98,7 @@ private Iterable children(PrimSig x) throws Err { } /** Write the given Expr and its Type. */ - private boolean writeExpr(String prefix, Expr expr) throws Err { + private boolean writeExpr(String prefix, Expr expr, int state) throws Err { Type type = expr.type(); if (!type.hasTuple()) return false; @@ -99,9 +110,9 @@ private boolean writeExpr(String prefix, Expr expr) throws Err { Expr sum = type.toExpr(); int lastSize = (-1); while (true) { - A4TupleSet ts = (A4TupleSet) (sol.eval(expr.minus(sum))); + A4TupleSet ts = (A4TupleSet) (sol.eval(expr.minus(sum), state)); int n = ts.size(); - if (n <= 0) + if (n <= 0 || expr instanceof ExprVar) // [electrum] static skolem vars (from quantifications) may not be part of the sig in other states break; if (lastSize > 0 && lastSize <= n) throw new ErrorFatal("An internal error occurred in the evaluator."); @@ -111,12 +122,13 @@ private boolean writeExpr(String prefix, Expr expr) throws Err { sum = sum.plus(extra.toExpr()); } // Now, write out the tupleset - A4TupleSet ts = (A4TupleSet) (sol.eval(expr)); + A4TupleSet ts = (A4TupleSet) (sol.eval(expr, state)); + // [electrum] force printing of element even if ts empty, otherwise mutable skolem funs missing from certain steps + if (prefix.length() > 0) { + out.print(prefix); + prefix = ""; + } for (A4Tuple t : ts) { - if (prefix.length() > 0) { - out.print(prefix); - prefix = ""; - } out.print(" "); for (int i = 0; i < t.arity(); i++) Util.encodeXMLs(out, " "); @@ -136,7 +148,7 @@ private boolean writeExpr(String prefix, Expr expr) throws Err { } /** Write the given Sig. */ - private A4TupleSet writesig(final Sig x) throws Err { + private A4TupleSet writeSig(final Sig x, int state) throws Err { A4TupleSet ts = null, ts2 = null; if (x == Sig.NONE) return null; // should not happen, but we test for it anyway @@ -144,7 +156,7 @@ private A4TupleSet writesig(final Sig x) throws Err { return null; // When writing the metamodel, skip the metamodel sigs! if (x instanceof PrimSig) for (final PrimSig sub : children((PrimSig) x)) { - A4TupleSet ts3 = writesig(sub); + A4TupleSet ts3 = writeSig(sub, state); if (ts2 == null) ts2 = ts3; else @@ -173,10 +185,12 @@ private A4TupleSet writesig(final Sig x) throws Err { out.print("\" exact=\"yes"); if (x.isEnum != null) out.print("\" enum=\"yes"); + if (x.isVariable != null) + out.print("\" var=\"yes"); out.print("\">\n"); try { if (sol != null && x != Sig.UNIV && x != Sig.SIGINT && x != Sig.SEQIDX) { - ts = (sol.eval(x)); + ts = (sol.eval(x, state)); for (A4Tuple t : ts.minus(ts2)) Util.encodeXMLs(out, " \n"); } @@ -188,12 +202,12 @@ private A4TupleSet writesig(final Sig x) throws Err { Util.encodeXMLs(out, " \n"); out.print("\n"); for (Field field : x.getFields()) - writeField(field); + writeField(field, state); return ts; } /** Write the given Field. */ - private void writeField(Field x) throws Err { + private void writeField(Field x, int state) throws Err { try { if (sol == null && x.isMeta != null) return; // when writing the metamodel, skip the metamodel @@ -208,8 +222,10 @@ private void writeField(Field x) throws Err { out.print("\" private=\"yes"); if (x.isMeta != null) out.print("\" meta=\"yes"); + if (x.isVariable != null) + out.print("\" var=\"yes"); out.print("\">\n"); - writeExpr("", x); + writeExpr("", x, state); out.print("\n"); } catch (Throwable ex) { throw new ErrorFatal("Error evaluating field " + x.sig.label + "." + x.label, ex); @@ -217,7 +233,7 @@ private void writeField(Field x) throws Err { } /** Write the given Skolem. */ - private void writeSkolem(ExprVar x) throws Err { + private void writeSkolem(ExprVar x, int state) throws Err { try { if (sol == null) return; // when writing a metamodel, skip the skolems @@ -226,7 +242,7 @@ private void writeSkolem(ExprVar x) throws Err { // declarations StringBuilder sb = new StringBuilder(); Util.encodeXMLs(sb, "\n\n"); - if (writeExpr(sb.toString(), x)) { + if (writeExpr(sb.toString(), x, state)) { out.print("\n"); } } catch (Throwable ex) { @@ -238,33 +254,42 @@ private void writeSkolem(ExprVar x) throws Err { * If sol==null, write the list of Sigs as a Metamodel, else write the solution * as an XML file. */ - private A4SolutionWriter(A4Reporter rep, A4Solution sol, Iterable sigs, int bitwidth, int maxseq, String originalCommand, String originalFileName, PrintWriter out, Iterable extraSkolems) throws Err { + private A4SolutionWriter(A4Reporter rep, A4Solution sol, Iterable sigs, int bitwidth, int maxseq, int mintrace, int maxtrace, int tracelength, int backloop, String originalCommand, String originalFileName, PrintWriter out, Iterable extraSkolems, int state) throws Err { this.rep = rep; this.out = out; this.sol = sol; for (Sig s : sigs) if (s instanceof PrimSig && ((PrimSig) s).parent == Sig.UNIV) toplevels.add((PrimSig) s); + // [electrum] write temporal metadata out.print("\n"); - writesig(Sig.UNIV); + writeSig(Sig.UNIV, state); for (Sig s : sigs) if (s instanceof SubsetSig) - writesig(s); + writeSig(s, state); if (sol != null) for (ExprVar s : sol.getAllSkolems()) { if (rep != null) rep.write(s); - writeSkolem(s); + writeSkolem(s, state); } int m = 0; if (sol != null && extraSkolems != null) @@ -279,7 +304,7 @@ private A4SolutionWriter(A4Reporter rep, A4Solution sol, Iterable sigs, int rep.write(f.call()); StringBuilder sb = new StringBuilder(); Util.encodeXMLs(sb, "\n\n"); - if (writeExpr(sb.toString(), f.call())) { + if (writeExpr(sb.toString(), f.call(), state)) { out.print("\n"); } m++; @@ -292,14 +317,17 @@ private A4SolutionWriter(A4Reporter rep, A4Solution sol, Iterable sigs, int /** * If this solution is a satisfiable solution, this method will write it out in - * XML format. + * XML format as a sequence of <instance>..</instance>. */ static void writeInstance(A4Reporter rep, A4Solution sol, PrintWriter out, Iterable extraSkolems, Map sources) throws Err { if (!sol.satisfiable()) throw new ErrorAPI("This solution is unsatisfiable."); try { Util.encodeXMLs(out, "\n\n"); - new A4SolutionWriter(rep, sol, sol.getAllReachableSigs(), sol.getBitwidth(), sol.getMaxSeq(), sol.getOriginalCommand(), sol.getOriginalFilename(), out, extraSkolems); + + // [electrum] write all instances of the trace + for (int i = 0; i < sol.getTraceLength(); i++) + new A4SolutionWriter(rep, sol, sol.getAllReachableSigs(), sol.getBitwidth(), sol.getMaxSeq(), sol.getMinTrace(), sol.getMaxTrace(), sol.getTraceLength(), sol.getLoopState(), sol.getOriginalCommand(), sol.getOriginalFilename(), out, extraSkolems, i); if (sources != null) for (Map.Entry e : sources.entrySet()) { Util.encodeXMLs(out, "\n\n"); @@ -320,7 +348,7 @@ static void writeInstance(A4Reporter rep, A4Solution sol, PrintWriter out, Itera */ public static void writeMetamodel(ConstList sigs, String originalFilename, PrintWriter out) throws Err { try { - new A4SolutionWriter(null, null, sigs, 4, 4, "show metamodel", originalFilename, out, null); + new A4SolutionWriter(null, null, sigs, 4, 4, 1, 1, 1, 0, "show metamodel", originalFilename, out, null, 0); } catch (Throwable ex) { if (ex instanceof Err) throw (Err) ex; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BookExamples.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BookExamples.java index 777284610..e88571c56 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BookExamples.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BookExamples.java @@ -25,8 +25,9 @@ import kodkod.ast.Expression; import kodkod.ast.Formula; import kodkod.ast.Relation; +import kodkod.engine.AbstractKodkodSolver; import kodkod.engine.Solution; -import kodkod.engine.Solver; +import kodkod.engine.config.Options; import kodkod.engine.satlab.SATFactory; import kodkod.instance.Bounds; import kodkod.instance.Tuple; @@ -37,6 +38,8 @@ * Immutable; this class stores the set of solutions from the book, for teaching * purpose, so that users of the tool will see the same illustration as the book * and not get confused by SAT solver nondeterminism. + * + * @modified [electrum] adapted to extended kodkod solver hierarchy */ final class BookExamples { @@ -59,7 +62,7 @@ private static Sig hasSig(Iterable sigs, String label) { * If one of the solution is a solution to the given problem, return it, else * return null. */ - static Solution trial(A4Reporter rep, A4Solution frame, Formula formula, Solver solver, boolean check) { + static Solution trial(A4Reporter rep, A4Solution frame, Formula formula, AbstractKodkodSolver solver, boolean check) { TupleFactory fac = frame.getFactory(); Solution sol = null; Iterable sigs = frame.getAllReachableSigs(); @@ -207,7 +210,7 @@ static Solution trial(A4Reporter rep, A4Solution frame, Formula formula, Solver } /** This tries a particular solution against the formula. */ - private static Solution trial(A4Reporter rep, TupleFactory fac, Solver solver, Iterable sigs, Formula f, A4Solution frame, Object[] t) { + private static Solution trial(A4Reporter rep, TupleFactory fac, AbstractKodkodSolver solver, Iterable sigs, Formula f, A4Solution frame, Object[] t) { try { frame.kr2typeCLEAR(); Bounds b = null; diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BoundsComputer.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BoundsComputer.java index 10c32d285..5dafae2c4 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BoundsComputer.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/BoundsComputer.java @@ -23,6 +23,7 @@ import edu.mit.csail.sdg.alloy4.A4Reporter; import edu.mit.csail.sdg.alloy4.Err; import edu.mit.csail.sdg.alloy4.Pos; +import edu.mit.csail.sdg.alloy4.Version; import edu.mit.csail.sdg.ast.Expr; import edu.mit.csail.sdg.ast.ExprBinary; import edu.mit.csail.sdg.ast.ExprConstant; @@ -46,6 +47,17 @@ /** * Immutable; this class assigns each sig and field to some Kodkod relation or * expression, then set the bounds. + * + * @modified [electrum] adapted the constraints to enforce the sig hierarchy to + * the temporal context; most relevant: one and lone multiplicities + * are enforced state-wise (but the atom may change between state); + * atoms may not change from one var prim sig to another; + * + * singleton mutable sigs cannot be collapsed for simplification, + * since their value may change over time; also, since the value of + * mutable sigs changes over time it is not possible to quantify over + * their hull (the set of all atoms in all states), so the static + * kodkod univ is used when needed; */ final class BoundsComputer { @@ -137,21 +149,33 @@ private Expression allocatePrimSig(PrimSig sig) throws Err { // Recursively allocate all children expressions, and form the union of // them Expression sum = null; + boolean all_static = true; + List extra_fs = new ArrayList(); + Variable v = Variable.unary("v"); for (PrimSig child : sig.children()) { + if (child.isVariable != null) + all_static = false; Expression childexpr = allocatePrimSig(child); if (sum == null) { sum = childexpr; continue; } // subsigs are disjoint - sol.addFormula(sum.intersection(childexpr).no(), child.isSubsig); + if (!all_static) { // [electrum] disjointness when some variable sig + Expression c = sol.a2k(child); + // eventually v in sig => always v not in parent - sig + Formula ff = (v.in(c).eventually()).implies(((v.in(sum)).not().always())); + extra_fs.add(ff); + } else { + sol.addFormula(sum.intersection(childexpr).no(), child.isSubsig); + } sum = sum.union(childexpr); } TupleSet lower = lb.get(sig).clone(), upper = ub.get(sig).clone(); if (sum == null) { // If sig doesn't have children, then sig should make a fresh // relation for itself - sum = sol.addRel(sig.label, lower, upper); + sum = sol.addRel(sig.label, lower, upper, sig.isVariable != null); } else if (sig.isAbstract == null) { // If sig has children, and sig is not abstract, then create a new // relation to act as the remainder. @@ -167,8 +191,20 @@ private Expression allocatePrimSig(PrimSig sig) throws Err { lower.removeAll(childTS); upper.removeAll(childTS); } - sum = sum.union(sol.addRel(sig.label + " remainder", lower, upper)); + Relation rem = sol.addRel(sig.label + "_remainder", lower, upper, sig.isVariable != null); + if (!all_static) { // [electrum] disjointness when some variable sig + // eventually v in sig-rem => always v not in rem + Formula ff = (v.in(sum).eventually()).implies(((v.in(rem)).not().always())); + extra_fs.add(ff); + } + sum = sum.union(rem); + } + if (!extra_fs.isEmpty()) { // [electrum] add disjointness when some variable sig + // always all v : univ | f (kodkod univ, static) + sol.addFormula(Formula.and(extra_fs).forAll(v.oneOf(Expression.UNIV)), sig.pos); } + if (sig.isVariable == null && !extra_fs.isEmpty()) // [electrum] when the static top relation is omitted + sol.addFormula((sum.prime().eq(sum)).always(), sig.isVariable); sol.addSig(sig, sum); return sum; } @@ -184,7 +220,10 @@ private Expression allocateSubsetSig(SubsetSig sig) throws Err { return sum; // Recursively form the union of all parent expressions TupleSet ts = factory.noneOf(1); + boolean hasVarParent = false; for (Sig parent : sig.parents) { + if (parent.isVariable != null) + hasVarParent = true; Expression p = (parent instanceof PrimSig) ? sol.a2k(parent) : allocateSubsetSig((SubsetSig) parent); ts.addAll(sol.query(true, p, false)); if (sum == null) @@ -199,11 +238,14 @@ private Expression allocateSubsetSig(SubsetSig sig) throws Err { } // Allocate a relation for this subset sig, then bound it rep.bound("Sig " + sig + " in " + ts + "\n"); - Relation r = sol.addRel(sig.label, null, ts); + Relation r = sol.addRel(sig.label, null, ts, sig.isVariable != null); sol.addSig(sig, r); // Add a constraint that it is INDEED a subset of the union of its // parents - sol.addFormula(r.in(sum), sig.isSubset); + if (sig.isVariable != null || hasVarParent) + sol.addFormula(r.in(sum).always(), sig.isSubset); + else + sol.addFormula(r.in(sum), sig.isSubset); return r; } @@ -217,7 +259,7 @@ private Formula size(Sig sig, int n, boolean exact) { Expression a = sol.a2k(sig); if (n <= 0) return a.no(); - if (n == 1) + if (n == 1 && sig.isVariable == null) // [electrum] mutable sigs are never exact return exact ? a.one() : a.lone(); Formula f = exact ? Formula.TRUE : null; Decls d = null; @@ -225,7 +267,7 @@ private Formula size(Sig sig, int n, boolean exact) { while (n > 0) { n--; Variable v = Variable.unary("v" + Integer.toString(TranslateAlloyToKodkod.cnt++)); - kodkod.ast.Decl dd = v.oneOf(a); + kodkod.ast.Decl dd = v.oneOf(sig.isVariable == null ? a : Expression.UNIV); // [electrum] if mutable, quantify over static univ if (d == null) d = dd; else @@ -240,8 +282,10 @@ private Formula size(Sig sig, int n, boolean exact) { } if (f != null) return sum.eq(a).and(f).forSome(d); - else + else if (sig.isVariable == null) return a.no().or(sum.eq(a).forSome(d)); + else // [electrum] if mutable, quantify over static univ + return Expression.UNIV.no().or(a.in(sum).always().forSome(d)); } // ==============================================================================================================// @@ -370,14 +414,15 @@ private BoundsComputer(A4Reporter rep, A4Solution sol, ScopeComputer sc, Iterabl } if (firstTS.size() != (n > 0 ? 1 : 0) || nextTS.size() != n - 1) break; - sol.addField(f1, sol.addRel(s.label + "." + f1.label, firstTS, firstTS)); - sol.addField(f2, sol.addRel(s.label + "." + f2.label, nextTS, nextTS)); + sol.addField(f1, sol.addRel(s.label + "." + f1.label, firstTS, firstTS, f1.isVariable != null)); + sol.addField(f2, sol.addRel(s.label + "." + f2.label, nextTS, nextTS, f2.isVariable != null)); rep.bound("Field " + s.label + "." + f1.label + " == " + firstTS + "\n"); rep.bound("Field " + s.label + "." + f2.label + " == " + nextTS + "\n"); continue again; } for (Field f : s.getFields()) { boolean isOne = s.isOne != null; + boolean isVar = s.isVariable != null; if (isOne && f.decl().expr.mult() == ExprUnary.Op.EXACTLYOF) { Expression sim = sim(f.decl().expr); if (sim != null) { @@ -386,7 +431,8 @@ private BoundsComputer(A4Reporter rep, A4Solution sol, ScopeComputer sc, Iterabl continue; } } - Type t = isOne ? Sig.UNIV.type().join(f.type()) : f.type(); + // [electrum] avoid collapse of mutable singleton sigs + Type t = isOne && !isVar ? Sig.UNIV.type().join(f.type()) : f.type(); TupleSet ub = factory.noneOf(t.arity()); for (List p : t.fold()) { TupleSet upper = null; @@ -399,25 +445,36 @@ private BoundsComputer(A4Reporter rep, A4Solution sol, ScopeComputer sc, Iterabl } ub.addAll(upper); } - Relation r = sol.addRel(s.label + "." + f.label, null, ub); - sol.addField(f, isOne ? sol.a2k(s).product(r) : r); + Relation r = sol.addRel(s.label + "." + f.label, null, ub, f.isVariable != null); + // [electrum] avoid collapse of mutable singleton sigs + sol.addField(f, isOne && !isVar ? sol.a2k(s).product(r) : r); } } + + // [electrum] Add possible symbolic bounds + if (Version.experimental) + for (Sig s : sigs) { + sol.addSymbolicBound(s); + for (Field f : s.getFields()) + sol.addSymbolicBound(f); + } + // Add any additional SIZE constraints for (Sig s : sigs) if (!s.builtin) { Expression exp = sol.a2k(s); TupleSet upper = sol.query(true, exp, false), lower = sol.query(false, exp, false); final int n = sc.sig2scope(s); + // [electrum] enforce multiplities over the trace (always) if (s.isOne != null && (lower.size() != 1 || upper.size() != 1)) { rep.bound("Sig " + s + " in " + upper + " with size==1\n"); - sol.addFormula(exp.one(), s.isOne); + sol.addFormula(s.isVariable != null ? exp.one().always() : exp.one(), s.isOne); continue; } if (s.isSome != null && lower.size() < 1) - sol.addFormula(exp.some(), s.isSome); + sol.addFormula(s.isVariable != null ? exp.some().always() : exp.some(), s.isSome); if (s.isLone != null && upper.size() > 1) - sol.addFormula(exp.lone(), s.isLone); + sol.addFormula(s.isVariable != null ? exp.lone().always() : exp.lone(), s.isLone); if (n < 0) continue; // This means no scope was specified if (lower.size() == n && upper.size() == n && sc.isExact(s)) { diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/ScopeComputer.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/ScopeComputer.java index 48f88d3ed..f03a27b19 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/ScopeComputer.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/ScopeComputer.java @@ -39,6 +39,7 @@ import edu.mit.csail.sdg.ast.CommandScope; import edu.mit.csail.sdg.ast.Sig; import edu.mit.csail.sdg.ast.Sig.PrimSig; +import edu.mit.csail.sdg.parser.CompUtil; /** * Immutable; this class computes the scopes for each sig and computes the @@ -66,6 +67,13 @@ *

* Please see ScopeComputer.java for the exact rules for deriving the missing * scopes. + * + * @modified [electrum] store the trace scope (min and max scope); also, some + * errors on scopes are relaxed: eg, one var sigs may still have a + * scope larger than 1, since the multiplicity is imposed state by + * state, thus the atom may change; also, scopes for such sigs are not + * made exact; new syntax error, setting trace scope for static models + * */ final class ScopeComputer { @@ -96,6 +104,16 @@ final class ScopeComputer { */ private int maxstring = (-1); + /** + * Maximum trace length to be handled by bounded temporal solvers. + */ + private int maxtrace = 10; + + /** + * Minimum trace length to be handled by bounded temporal solvers. + */ + private int mintrace = 1; + /** The scope for each sig. */ private final IdentityHashMap sig2scope = new IdentityHashMap(); @@ -159,7 +177,7 @@ private void makeExact(Pos pos, Sig sig) throws Err { /** * Modifies the integer bitwidth of this solution's model (and sets the max - * sequence length to 0) + * sequence length to 0). */ private void setBitwidth(Pos pos, int newBitwidth) throws ErrorAPI, ErrorSyntax { if (newBitwidth < 0) @@ -172,6 +190,17 @@ private void setBitwidth(Pos pos, int newBitwidth) throws ErrorAPI, ErrorSyntax sig2scope.put(SEQIDX, 0); } + + /** Modifies the maximum trace length of this solution's model. */ + private void setMaxTraceLength(Pos pos, int newTracelength) throws ErrorAPI, ErrorSyntax { + maxtrace = newTracelength; + } + + /** Modifies the minimum trace length of this solution's model. */ + private void setMinTraceLength(Pos pos, int newTracelength) throws ErrorAPI, ErrorSyntax { + mintrace = newTracelength; + } + /** Modifies the maximum sequence length. */ private void setMaxSeq(Pos pos, int newMaxSeq) throws ErrorAPI, ErrorSyntax { if (newMaxSeq > max()) @@ -349,6 +378,7 @@ private ScopeComputer(A4Reporter rep, Iterable sigs, Command cmd) throws Er this.rep = rep; this.cmd = cmd; boolean shouldUseInts = true; // TODO CompUtil.areIntsUsed(sigs, cmd); + // Process each sig listed in the command for (CommandScope entry : cmd.scope) { Sig s = entry.sig; @@ -372,9 +402,12 @@ private ScopeComputer(A4Reporter rep, Iterable sigs, Command cmd) throws Er throw new ErrorSyntax(cmd.pos, "You cannot set a scope on \"none\"."); if (s.isEnum != null) throw new ErrorSyntax(cmd.pos, "You cannot set a scope on the enum \"" + s.label + "\""); - if (s.isOne != null && scope != 1) + // [electrum] rules relaxed if mutable, the atom may change along the trace + if (s.isOne != null && s.isVariable == null && scope != 1) throw new ErrorSyntax(cmd.pos, "Sig \"" + s + "\" has the multiplicity of \"one\", so its scope must be 1, and cannot be " + scope); - if (s.isLone != null && scope > 1) + if (s.isOne != null && s.isVariable != null && scope < 1) + throw new ErrorSyntax(cmd.pos, "Var sig \"" + s + "\" has the multiplicity of \"one\", so its scope must be 1 or above, and cannot be " + scope); + if (s.isLone != null && s.isVariable == null && scope > 1) throw new ErrorSyntax(cmd.pos, "Sig \"" + s + "\" has the multiplicity of \"lone\", so its scope must 0 or 1, and cannot be " + scope); if (s.isSome != null && scope < 1) throw new ErrorSyntax(cmd.pos, "Sig \"" + s + "\" has the multiplicity of \"some\", so its scope must 1 or above, and cannot be " + scope); @@ -383,28 +416,32 @@ private ScopeComputer(A4Reporter rep, Iterable sigs, Command cmd) throws Er makeExact(cmd.pos, s); } // Force "one" sigs to be exactly one, and "lone" to be at most one + // [electrum] except in mutable sigs, where atom may vary for (Sig s : sigs) if (s instanceof PrimSig) { - if (s.isOne != null) { + if (s.isOne != null && s.isVariable == null) { makeExact(cmd.pos, s); sig2scope(s, 1); - } else if (s.isLone != null && sig2scope(s) != 0) + } else if (s.isLone != null && s.isVariable == null && sig2scope(s) != 0) sig2scope(s, 1); } // Derive the implicit scopes while (true) { if (derive_abstract_scope(sigs)) { - do {} + do { + } while (derive_abstract_scope(sigs)); continue; } if (derive_overall_scope(sigs)) { - do {} + do { + } while (derive_overall_scope(sigs)); continue; } if (derive_scope_from_parent(sigs)) { - do {} + do { + } while (derive_scope_from_parent(sigs)); continue; } @@ -434,6 +471,28 @@ private ScopeComputer(A4Reporter rep, Iterable sigs, Command cmd) throws Er if (max >= min) for (int i = min; i <= max; i++) atoms.add("" + i); + // [electrum] handle trace lengths + boolean isVar = CompUtil.isTemporalModel(sigs, cmd); + int tracelength = cmd.maxprefix; + // [electrum] do not allow trace scopes for static models + if (!isVar) { + if (tracelength > 0) + throw new ErrorSyntax(cmd.pos, "You cannot set a scope on \"steps\" in static models."); + tracelength = -1; + } else if (tracelength < 1) + tracelength = 10; + setMaxTraceLength(cmd.pos, tracelength); + tracelength = cmd.minprefix; + if (!isVar) { + if (tracelength > 0) + throw new ErrorSyntax(cmd.pos, "You cannot set a scope on \"steps\" in static models."); + tracelength = -1; + } else if (tracelength > cmd.maxprefix) + tracelength = cmd.maxprefix; + else if (tracelength < 1) + tracelength = 1; + setMinTraceLength(cmd.pos, tracelength); + } // ===========================================================================================================================// @@ -473,7 +532,7 @@ static Pair compute(A4Reporter rep, A4Options opt, Ite for (int i = 0; set.size() < sc.maxstring; i++) set.add("\"String" + i + "\""); sc.atoms.addAll(set); - A4Solution sol = new A4Solution(cmd.toString(), sc.bitwidth, sc.maxseq, set, sc.atoms, rep, opt, cmd.expects); + A4Solution sol = new A4Solution(cmd.toString(), sc.bitwidth, sc.mintrace, sc.maxtrace, sc.maxseq, set, sc.atoms, rep, opt, cmd.expects); return new Pair(sol, sc); } } diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/Simplifier.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/Simplifier.java index 37ffa7f60..854fa6900 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/Simplifier.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/Simplifier.java @@ -28,9 +28,11 @@ import kodkod.ast.Formula; import kodkod.ast.NaryFormula; import kodkod.ast.Relation; +import kodkod.ast.UnaryTempFormula; import kodkod.ast.operator.ExprCompOperator; import kodkod.ast.operator.ExprOperator; import kodkod.ast.operator.FormulaOperator; +import kodkod.ast.operator.TemporalOperator; import kodkod.instance.TupleSet; /** @@ -44,6 +46,9 @@ *

* (2) When it sees "A = B", it will try to simplify A assuming "A in B", and * then simplify B assuming "B in A". + * + * @modified [electrum] allow simplification when inside always temporal + * operator */ public class Simplifier { @@ -55,7 +60,8 @@ public class Simplifier { private A4Solution sol = null; /** Construct a Simplifier object. */ - public Simplifier() {} + public Simplifier() { + } /* Stores the equivalence relation discovered so far. */ // private final IdentityHashMap> equiv = new @@ -162,7 +168,8 @@ private final boolean simplify_equal(Expression a, Expression b) { rep.debug("Comment: Simplify " + b + " " + (b1.size() - b0.size()) + "->" + (a1.size() - b0.size()) + "\n"); sol.shrink((Relation) b, b0, b1 = a1); } - } catch (Exception ex) {} + } catch (Exception ex) { + } } return true; } @@ -258,6 +265,12 @@ private final boolean simplify_in(Expression a, Expression b) { * discover the formula is unsat. */ private final boolean simplify_in(Formula form) { + if (form instanceof UnaryTempFormula) { + UnaryTempFormula f = (UnaryTempFormula) form; + if (f.op() == TemporalOperator.ALWAYS) { + return simplify_in(f.formula()); + } + } if (form instanceof NaryFormula) { NaryFormula f = (NaryFormula) form; if (f.op() == FormulaOperator.AND) { @@ -293,6 +306,12 @@ private final boolean simplify_in(Formula form) { * discover the formula is unsat. */ private final boolean simplify_eq(Formula form) { + if (form instanceof UnaryTempFormula) { + UnaryTempFormula f = (UnaryTempFormula) form; + if (f.op() == TemporalOperator.ALWAYS) { + return simplify_in(f.formula()); + } + } if (form instanceof NaryFormula) { NaryFormula f = (NaryFormula) form; if (f.op() == FormulaOperator.AND) { diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateAlloyToKodkod.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateAlloyToKodkod.java index caef1700b..5f7825f8e 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateAlloyToKodkod.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateAlloyToKodkod.java @@ -69,6 +69,7 @@ import kodkod.ast.operator.ExprOperator; import kodkod.engine.CapacityExceededException; import kodkod.engine.fol2sat.HigherOrderDeclException; +import kodkod.engine.ltl2fol.TemporalTranslator; import kodkod.instance.Tuple; import kodkod.instance.TupleFactory; import kodkod.instance.TupleSet; @@ -76,6 +77,12 @@ /** * Translate an Alloy AST into Kodkod AST then attempt to solve it using Kodkod. + * + * @modified [electrum] added the translation of temporal operators and + * quantifies globally over time constraints over sigs and fields (sig + * facts are also implicitly globally quantified); also, variable + * singleton sigs are not collapsed like static ones; name all + * relations of total order; updated reporting */ public final class TranslateAlloyToKodkod extends VisitReturn { @@ -254,32 +261,49 @@ private void makeFacts(Expr facts) throws Err { Field f = (Field) n; Expr form = s.decl.get().join(f).in(d.expr); form = s.isOne == null ? form.forAll(s.decl) : ExprLet.make(null, (ExprVar) (s.decl.get()), s, form); - frame.addFormula(cform(form), f); + Formula ff = cform(form); + if (TemporalTranslator.isTemporal(ff)) + ff = ff.always(); + frame.addFormula(ff, f); // Given the above, we can be sure that every column is // well-bounded (except possibly the first column). // Thus, we need to add a bound that the first column is a // subset of s. - if (s.isOne == null) { + // [electrum] mutable singletons sigs cannot be simplified + if (s.isOne == null || s.isVariable != null) { Expression sr = a2k(s), fr = a2k(f); for (int i = f.type().arity(); i > 1; i--) fr = fr.join(Expression.UNIV); - frame.addFormula(fr.in(sr), f); + ff = fr.in(sr); + if (TemporalTranslator.isTemporal(ff)) + ff = ff.always(); + frame.addFormula(ff, f); } } if (s.isOne == null && d.disjoint2 != null) for (ExprHasName f : d.names) { Decl that = s.oneOf("that"); Expr formula = s.decl.get().equal(that.get()).not().implies(s.decl.get().join(f).intersect(that.get().join(f)).no()); - frame.addFormula(cform(formula.forAll(that).forAll(s.decl)), d.disjoint2); + Formula ff = cform(formula.forAll(that).forAll(s.decl)); + if (d.isVar != null) + ff = ff.always(); + frame.addFormula(ff, d.disjoint2); } if (d.names.size() > 1 && d.disjoint != null) { - frame.addFormula(cform(ExprList.makeDISJOINT(d.disjoint, null, d.names)), d.disjoint); + Formula ff = cform(ExprList.makeDISJOINT(d.disjoint, null, d.names)); + if (d.isVar != null) + ff = ff.always(); + frame.addFormula(ff, d.disjoint); } } k2pos_enabled = true; for (Expr f : s.getFacts()) { Expr form = s.isOne == null ? f.forAll(s.decl) : ExprLet.make(null, (ExprVar) (s.decl.get()), s, f); - frame.addFormula(cform(form), f); + Formula kdorm = cform(form); + // [electrum] avoid "always" over statics (not only efficiency, total orders would not by detected in SB) + if (TemporalTranslator.isTemporal(kdorm)) + kdorm = kdorm.always(); + frame.addFormula(kdorm, f); } } k2pos_enabled = true; @@ -307,7 +331,8 @@ private static final class GreedySimulator extends Simplifier { private ConstList growableSigs = null; private A4Solution partial = null; - public GreedySimulator() {} + public GreedySimulator() { + } private TupleSet convert(TupleFactory factory, Expr f) throws Err { TupleSet old = ((A4TupleSet) (partial.eval(f))).debugGetKodkodTupleset(); @@ -437,17 +462,19 @@ private static A4Solution execute_greedyCommand(A4Reporter rep, Iterable si private boolean first = true; @Override - public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) { + public void translate(String solver, int bitwidth, int maxseq, int mintrace, int maxtrace, int skolemDepth, int symmetry, String strat) { if (first) - super.translate(solver, bitwidth, maxseq, skolemDepth, symmetry); + super.translate(solver, bitwidth, maxseq, mintrace, maxtrace, skolemDepth, symmetry, strat); first = false; } @Override - public void resultSAT(Object command, long solvingTime, Object solution) {} + public void resultSAT(Object command, long solvingTime, Object solution) { + } @Override - public void resultUNSAT(Object command, long solvingTime, Object solution) {} + public void resultUNSAT(Object command, long solvingTime, Object solution) { + } }; // Form the list of commands List commands = new ArrayList(); @@ -832,6 +859,18 @@ public Object visit(ExprUnary x) throws Err { return visitThis(x.sub); case NOT : return k2pos(cform(x.sub).not(), x); + case AFTER : + return k2pos(cform(x.sub).after(), x); + case ALWAYS : + return k2pos(cform(x.sub).always(), x); + case EVENTUALLY : + return k2pos(cform(x.sub).eventually(), x); + case BEFORE : + return k2pos(cform(x.sub).before(), x); + case HISTORICALLY : + return k2pos(cform(x.sub).historically(), x); + case ONCE : + return k2pos(cform(x.sub).once(), x); case SOME : return k2pos(cset(x.sub).some(), x); case LONE : @@ -840,6 +879,8 @@ public Object visit(ExprUnary x) throws Err { return k2pos(cset(x.sub).one(), x); case NO : return k2pos(cset(x.sub).no(), x); + case PRIME : + return cset(x.sub).prime(); case TRANSPOSE : return cset(x.sub).transpose(); case CARDINALITY : @@ -1013,7 +1054,7 @@ public Object visit(ExprList x) throws Err { if (x.op == ExprList.Op.TOTALORDER) { Expression elem = cset(x.args.get(0)), first = cset(x.args.get(1)), next = cset(x.args.get(2)); if (elem instanceof Relation && first instanceof Relation && next instanceof Relation) { - Relation lst = frame.addRel("", null, frame.query(true, elem, false)); + Relation lst = frame.addRel(((Relation) elem).name() + "_last", null, frame.query(true, elem, false), false); // [electrum] no unnamed rels for electrod totalOrderPredicates.add((Relation) elem); totalOrderPredicates.add((Relation) first); totalOrderPredicates.add(lst); @@ -1082,8 +1123,9 @@ public Object visit(ExprBinary x) throws Err { Formula f; Object objL, objR; switch (x.op) { + // [electrum] changed from !a || b, was it relevant? case IMPLIES : - f = cform(a).not().or(cform(b)); + f = cform(a).implies(cform(b)); return k2pos(f, x); case IN : return k2pos(isIn(cset(a), b), x); @@ -1129,6 +1171,22 @@ public Object visit(ExprBinary x) throws Err { f = cform(a); f = f.or(cform(b)); return k2pos(f, x); + case UNTIL : + f = cform(a); + f = f.until(cform(b)); + return k2pos(f, x); + case RELEASES : + f = cform(a); + f = f.releases(cform(b)); + return k2pos(f, x); + case SINCE : + f = cform(a); + f = f.since(cform(b)); + return k2pos(f, x); + case TRIGGERED : + f = cform(a); + f = f.triggered(cform(b)); + return k2pos(f, x); case IFF : f = cform(a); f = f.iff(cform(b)); diff --git a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateKodkodToJava.java b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateKodkodToJava.java index 85f2965e7..3fe443ecd 100644 --- a/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateKodkodToJava.java +++ b/org.alloytools.alloy.core/src/main/java/edu/mit/csail/sdg/translator/TranslateKodkodToJava.java @@ -27,6 +27,7 @@ import kodkod.ast.BinaryExpression; import kodkod.ast.BinaryFormula; import kodkod.ast.BinaryIntExpression; +import kodkod.ast.BinaryTempFormula; import kodkod.ast.ComparisonFormula; import kodkod.ast.Comprehension; import kodkod.ast.ConstantExpression; @@ -35,7 +36,6 @@ import kodkod.ast.Decls; import kodkod.ast.ExprToIntCast; import kodkod.ast.Expression; -import kodkod.ast.FixFormula; import kodkod.ast.Formula; import kodkod.ast.IfExpression; import kodkod.ast.IfIntExpression; @@ -55,12 +55,14 @@ import kodkod.ast.RelationPredicate; import kodkod.ast.RelationPredicate.Function; import kodkod.ast.SumExpression; +import kodkod.ast.TempExpression; import kodkod.ast.UnaryExpression; import kodkod.ast.UnaryIntExpression; +import kodkod.ast.UnaryTempFormula; import kodkod.ast.Variable; import kodkod.ast.visitor.ReturnVisitor; import kodkod.ast.visitor.VoidVisitor; -import kodkod.instance.Bounds; +import kodkod.instance.PardinusBounds; import kodkod.instance.Tuple; import kodkod.instance.TupleSet; import kodkod.util.ints.IndexedEntry; @@ -72,6 +74,8 @@ *

* Requirements: atoms must be String objects (since we cannot possibly output a * Java source code that can re-generate arbitrary Java objects). + * + * @modified [electrum] added temporal nodes and solving parameters */ public final class TranslateKodkodToJava implements VoidVisitor { @@ -118,6 +122,11 @@ public Integer visit(NotFormula x) { return 1 + x.formula().accept(this); } + @Override + public Integer visit(UnaryTempFormula x) { + return 1 + x.formula().accept(this); + } + @Override public Integer visit(IntToExprCast x) { return 1 + x.intExpr().accept(this); @@ -138,6 +147,11 @@ public Integer visit(UnaryExpression x) { return 1 + x.expression().accept(this); } + @Override + public Integer visit(TempExpression x) { + return 1 + x.expression().accept(this); + } + @Override public Integer visit(UnaryIntExpression x) { return 1 + x.intExpr().accept(this); @@ -163,6 +177,11 @@ public Integer visit(BinaryFormula x) { return 1 + max(x.left().accept(this), x.right().accept(this)); } + @Override + public Integer visit(BinaryTempFormula x) { + return 1 + max(x.left().accept(this), x.right().accept(this)); + } + @Override public Integer visit(BinaryIntExpression x) { return 1 + max(x.left().accept(this), x.right().accept(this)); @@ -193,11 +212,6 @@ public Integer visit(QuantifiedFormula x) { return 1 + max(x.decls().accept(this), x.formula().accept(this)); } - @Override - public Integer visit(FixFormula x) { - return 1 + max(x.condition().accept(this), x.formula().accept(this)); - } - @Override public Integer visit(Comprehension x) { return 1 + max(x.decls().accept(this), x.formula().accept(this)); @@ -281,11 +295,13 @@ public Integer visit(NaryFormula x) { * @param atoms - an iterator over the set of all atoms * @param bounds - the Kodkod bounds object to use * @param atomMap - if nonnull, it is used to map the atom name before printing + * @param mintrace - the minimum trace length + * @param maxtrace - the maximum trace length */ - public static String convert(Formula formula, int bitwidth, Iterable atoms, Bounds bounds, Map atomMap) { + public static String convert(Formula formula, int bitwidth, Iterable atoms, PardinusBounds bounds, Map atomMap, int mintrace, int maxtrace) { StringWriter string = new StringWriter(); PrintWriter file = new PrintWriter(string); - new TranslateKodkodToJava(file, formula, bitwidth, atoms, bounds, atomMap); + new TranslateKodkodToJava(file, formula, bitwidth, atoms, bounds, atomMap, mintrace, maxtrace); if (file.checkError()) { return ""; // shouldn't happen } else { @@ -323,7 +339,7 @@ private String make(Node x) { * Constructor is private, so that the only way to access this class is via the * static convert() method. */ - private TranslateKodkodToJava(PrintWriter pw, Formula x, int bitwidth, Iterable atoms, Bounds bounds, Map atomMap) { + private TranslateKodkodToJava(PrintWriter pw, Formula x, int bitwidth, Iterable atoms, PardinusBounds bounds, Map atomMap, int mintrace, int maxtrace) { file = pw; file.printf("import java.util.Arrays;%n"); file.printf("import java.util.List;%n"); @@ -332,7 +348,7 @@ private TranslateKodkodToJava(PrintWriter pw, Formula x, int bitwidth, Iterable< file.printf("import kodkod.instance.*;%n"); file.printf("import kodkod.engine.*;%n"); file.printf("import kodkod.engine.satlab.SATFactory;%n"); - file.printf("import kodkod.engine.config.Options;%n%n"); + file.printf("import kodkod.engine.config.ExtendedOptions;%n%n"); file.printf("/* %n"); file.printf(" ==================================================%n"); @@ -353,7 +369,9 @@ private TranslateKodkodToJava(PrintWriter pw, Formula x, int bitwidth, Iterable< String name = makename(r); int a = r.arity(); if (a == 1) - file.printf("Relation %s = Relation.unary(\"%s\");%n", name, r.name()); + file.printf("Relation %s = Relation.unary%s(\"%s\");%n", name, r.isVariable() ? "_variable" : "", r.name()); + else if (r.isVariable()) + file.printf("Relation %s = Relation.variable(\"%s\", %d);%n", name, r.name(), a); else file.printf("Relation %s = Relation.nary(\"%s\", %d);%n", name, r.name(), a); } @@ -379,16 +397,31 @@ private TranslateKodkodToJava(PrintWriter pw, Formula x, int bitwidth, Iterable< file.printf("Bounds bounds = new Bounds(universe);%n%n"); for (Relation r : bounds.relations()) { String n = map.get(r); - TupleSet upper = bounds.upperBound(r); - TupleSet lower = bounds.lowerBound(r); - printTupleset(n + "_upper", upper, atomMap); - if (upper.equals(lower)) { - file.printf("bounds.boundExactly(%s, %s_upper);%n%n", n, n); - } else if (lower.size() == 0) { - file.printf("bounds.bound(%s, %s_upper);%n%n", n, n); + // [electrum] print symbolic bounds + if (bounds.lowerSymbBound(r) != null) { + Expression upper = bounds.upperSymbBound(r); + Expression lower = bounds.lowerSymbBound(r); + file.printf("Expression %s_upper = %s;%n%n", n, upper); + if (upper.equals(lower)) { + file.printf("bounds.boundExactly(%s, %s_upper);%n%n", n, n); + // } else if (lower.size() == 0) { + // file.printf("bounds.bound(%s, %s_upper);%n%n", n, n); + } else { + file.printf("Expression %s_lower = %s;%n%n", n, lower); + file.printf("bounds.bound(%s, %s_lower, %s_upper);%n%n", n, n, n); + } } else { - printTupleset(n + "_lower", lower, atomMap); - file.printf("bounds.bound(%s, %s_lower, %s_upper);%n%n", n, n, n); + TupleSet upper = bounds.upperBound(r); + TupleSet lower = bounds.lowerBound(r); + printTupleset(n + "_upper", upper, atomMap); + if (upper.equals(lower)) { + file.printf("bounds.boundExactly(%s, %s_upper);%n%n", n, n); + } else if (lower.size() == 0) { + file.printf("bounds.bound(%s, %s_upper);%n%n", n, n); + } else { + printTupleset(n + "_lower", lower, atomMap); + file.printf("bounds.bound(%s, %s_lower, %s_upper);%n%n", n, n, n); + } } } for (IndexedEntry i : bounds.intBounds()) { @@ -401,13 +434,16 @@ private TranslateKodkodToJava(PrintWriter pw, Formula x, int bitwidth, Iterable< } file.printf("%n"); String result = make(x); - file.printf("%nSolver solver = new Solver();"); - file.printf("%nsolver.options().setSolver(SATFactory.DefaultSAT4J);"); - file.printf("%nsolver.options().setBitwidth(%d);", bitwidth != 0 ? bitwidth : 1); - file.printf("%nsolver.options().setFlatten(false);"); - file.printf("%nsolver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);"); - file.printf("%nsolver.options().setSymmetryBreaking(20);"); - file.printf("%nsolver.options().setSkolemDepth(0);"); + file.printf("%nExtendedOptions opt = new ExtendedOptions();"); + file.printf("%nopt.setSolver(SATFactory.DefaultSAT4J);"); + file.printf("%nopt.setBitwidth(%d);", bitwidth != 0 ? bitwidth : 1); + file.printf("%nopt.setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);"); + file.printf("%nopt.setSymmetryBreaking(20);"); + file.printf("%nopt.setSkolemDepth(0);"); + file.printf("%nopt.setMinTraceLength(%d);", mintrace); + file.printf("%nopt.setMaxTraceLength(%d);", maxtrace); + file.printf("%nopt.setRunUnbounded(%b);", maxtrace == Integer.MAX_VALUE); + file.printf("%nPardinusSolver solver = new PardinusSolver(opt);"); file.printf("%nSystem.out.println(\"Solving...\");"); file.printf("%nSystem.out.flush();"); file.printf("%nSolution sol = solver.solve(%s,bounds);", result); @@ -572,6 +608,31 @@ public void visit(BinaryFormula x) { } } + /** {@inheritDoc} */ + public void visit(BinaryTempFormula temporalFormula) { + String newname = makename(temporalFormula); + if (newname == null) + return; + String left = make(temporalFormula.left()); + String right = make(temporalFormula.right()); + switch (temporalFormula.op()) { + case RELEASES : + file.printf("Expression %s=%s.releases(%s);%n", newname, left, right); + break; + case UNTIL : + file.printf("Expression %s=%s.until(%s);%n", newname, left, right); + break; + case SINCE : + file.printf("Expression %s=%s.since(%s);%n", newname, left, right); + break; + case TRIGGERED : + file.printf("Expression %s=%s.triggered(%s);%n", newname, left, right); + break; + default : + throw new RuntimeException("Unknown temporal kodkod operator \"" + temporalFormula.op() + "\" encountered"); + } + } + /** {@inheritDoc} */ @Override public void visit(BinaryIntExpression x) { @@ -666,6 +727,21 @@ public void visit(UnaryExpression x) { } } + /** {@inheritDoc} */ + public void visit(TempExpression temporalExpr) { + String newname = makename(temporalExpr); + if (newname == null) + return; + String sub = make(temporalExpr.expression()); + switch (temporalExpr.op()) { + case PRIME : + file.printf("Expression %s=%s.prime();%n", newname, sub); + break; + default : + throw new RuntimeException("Unknown temporal kodkod operator \"" + temporalExpr.op() + "\" encountered"); + } + } + /** {@inheritDoc} */ @Override public void visit(IfExpression x) { @@ -700,6 +776,36 @@ public void visit(NotFormula x) { file.printf("Formula %s=%s.not();%n", newname, sub); } + /** {@inheritDoc} */ + public void visit(UnaryTempFormula temporalFormula) { + String newname = makename(temporalFormula); + if (newname == null) + return; + String sub = make(temporalFormula.formula()); + switch (temporalFormula.op()) { + case ALWAYS : + file.printf("Formula %s=%s.always();%n", newname, sub); + break; + case EVENTUALLY : + file.printf("Formula %s=%s.eventually();%n", newname, sub); + break; + case HISTORICALLY : + file.printf("Formula %s=%s.historically();%n", newname, sub); + break; + case ONCE : + file.printf("Formula %s=%s.once();%n", newname, sub); + break; + case BEFORE : + file.printf("Formula %s=%s.previously();%n", newname, sub); + break; + case AFTER : + file.printf("Formula %s=%s.after();%n", newname, sub); + break; + default : + throw new RuntimeException("Unknown temporal kodkod operator \"" + temporalFormula.op() + "\" encountered"); + } + } + /** {@inheritDoc} */ @Override public void visit(IntToExprCast x) { @@ -819,17 +925,6 @@ public void visit(QuantifiedFormula x) { } } - /** {@inheritDoc} */ - @Override - public void visit(FixFormula x) { - String newname = makename(x); - if (newname == null) - return; - String f = make(x.formula()); - String c = make(x.condition()); - file.printf("Formula %s=%s.fix(%s);%n", newname, f, c); - } - /** {@inheritDoc} */ @Override public void visit(SumExpression x) { diff --git a/org.alloytools.alloy.core/src/main/java/java_cup/runtime/lr_parser.java b/org.alloytools.alloy.core/src/main/java/java_cup/runtime/lr_parser.java index 78cea091f..3429b6ee5 100644 --- a/org.alloytools.alloy.core/src/main/java/java_cup/runtime/lr_parser.java +++ b/org.alloytools.alloy.core/src/main/java/java_cup/runtime/lr_parser.java @@ -363,7 +363,7 @@ public Scanner getScanner() { * @param stack the parse stack of that object. * @param top the index of the top element of the parse stack. */ - public abstract Symbol do_action(int act_num, lr_parser parser, Stack stack, int top) throws java.lang.Exception; + public abstract Symbol do_action(int act_num, lr_parser parser, Stack stack, int top) throws java.lang.Exception; /* * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . diff --git a/org.alloytools.alloy.core/src/main/resources/models/util/seqrel.als b/org.alloytools.alloy.core/src/main/resources/models/util/seqrel.als index 1fe3802df..1a24c06d6 100644 --- a/org.alloytools.alloy.core/src/main/resources/models/util/seqrel.als +++ b/org.alloytools.alloy.core/src/main/resources/models/util/seqrel.als @@ -93,13 +93,13 @@ fun delete[s: SeqIdx -> elem, i: SeqIdx] : SeqIdx -> elem { /** appended is the result of appending s2 to s1 */ fun append [s1, s2: SeqIdx -> elem] : SeqIdx -> elem { - let shift = {i', i: SeqIdx | #ord/prevs[i'] = add[#ord/prevs[i], add[#ord/prevs[lastIdx[s1]], 1]] } | + let shift = {i", i: SeqIdx | #ord/prevs[i"] = add[#ord/prevs[i], add[#ord/prevs[lastIdx[s1]], 1]] } | s1 + shift.s2 } /** returns the subsequence of s between from and to, inclusive */ fun subseq [s: SeqIdx -> elem, from, to: SeqIdx] : SeqIdx -> elem { - let shift = {i', i: SeqIdx | #ord/prevs[i'] = sub[#ord/prevs[i], #ord/prevs[from]] } | + let shift = {i", i: SeqIdx | #ord/prevs[i"] = sub[#ord/prevs[i], #ord/prevs[from]] } | shift.((SeqIdx - ord/nexts[to]) <: s) } diff --git a/org.alloytools.alloy.core/src/main/resources/models/util/sequence.als b/org.alloytools.alloy.core/src/main/resources/models/util/sequence.als index 524e3cf7e..c51282ccb 100644 --- a/org.alloytools.alloy.core/src/main/resources/models/util/sequence.als +++ b/org.alloytools.alloy.core/src/main/resources/models/util/sequence.als @@ -50,7 +50,7 @@ pred noDuplicates { /** invoke if you want all sequences within scope to exist */ pred allExist { (some s: Seq | s.isEmpty) && - (all s: Seq | SeqIdx !in s.inds => (all e: elem | some s': Seq | s.add[e, s'])) + (all s: Seq | SeqIdx !in s.inds => (all e: elem | some s": Seq | s.add[e, s"])) } /** invoke if you want all sequences within scope with no duplicates */ @@ -58,7 +58,7 @@ pred allExistNoDuplicates { some s: Seq | s.isEmpty all s: Seq { !s.hasDups - SeqIdx !in s.inds => (all e: elem - s.elems | some s': Seq | s.add[e, s']) + SeqIdx !in s.inds => (all e: elem - s.elems | some s": Seq | s.add[e, s"]) } } diff --git a/org.alloytools.alloy.core/src/main/resources/models/util/sequniv.als b/org.alloytools.alloy.core/src/main/resources/models/util/sequniv.als index efa8bf428..cd2a3cba5 100644 --- a/org.alloytools.alloy.core/src/main/resources/models/util/sequniv.als +++ b/org.alloytools.alloy.core/src/main/resources/models/util/sequniv.als @@ -123,7 +123,7 @@ fun delete[s: Int -> univ, i: Int] : s { * (If the resulting sequence is too long, it will be truncated) */ fun append [s1, s2: Int -> univ] : s1+s2 { - let shift = {i', i: seq/Int | int[i'] = ui/add[int[i], ui/add[int[lastIdx[s1]], 1]] } | + let shift = {i", i: seq/Int | int[i"] = ui/add[int[i], ui/add[int[lastIdx[s1]], 1]] } | no s1 => s2 else (s1 + shift.s2) } @@ -132,6 +132,6 @@ fun append [s1, s2: Int -> univ] : s1+s2 { * Precondition: 0 <= from <= to < #s */ fun subseq [s: Int -> univ, from, to: Int] : s { - let shift = {i', i: seq/Int | int[i'] = ui/sub[int[i], int[from]] } | + let shift = {i", i: seq/Int | int[i"] = ui/sub[int[i], int[from]] } | shift.((seq/Int - ui/nexts[to]) <: s) } diff --git a/org.alloytools.alloy.core/src/main/resources/models/util/time.als b/org.alloytools.alloy.core/src/main/resources/models/util/time.als index b6f9d8cad..e950dd192 100644 --- a/org.alloytools.alloy.core/src/main/resources/models/util/time.als +++ b/org.alloytools.alloy.core/src/main/resources/models/util/time.als @@ -6,48 +6,48 @@ let dynamic[x] = x one-> Time let dynamicSet[x] = x -> Time -let then [a, b, t, t'] { - some x:Time | a[t,x] && b[x,t'] +let then [a, b, t, t"] { + some x:Time | a[t,x] && b[x,t"] } let while = while3 -let while9 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while8[cond,body,x,t'] +let while9 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while8[cond,body,x,t"] } -let while8 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while7[cond,body,x,t'] +let while8 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while7[cond,body,x,t"] } -let while7 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while6[cond,body,x,t'] +let while7 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while6[cond,body,x,t"] } -let while6 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while5[cond,body,x,t'] +let while6 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while5[cond,body,x,t"] } -let while5 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while4[cond,body,x,t'] +let while5 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while4[cond,body,x,t"] } -let while4 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while3[cond,body,x,t'] +let while4 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while3[cond,body,x,t"] } -let while3 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while2[cond,body,x,t'] +let while3 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while2[cond,body,x,t"] } -let while2 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while1[cond,body,x,t'] +let while2 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while1[cond,body,x,t"] } -let while1 [cond, body, t, t'] { - some x:Time | (cond[t] => body[t,x] else t=x) && while0[cond,body,x,t'] +let while1 [cond, body, t, t"] { + some x:Time | (cond[t] => body[t,x] else t=x) && while0[cond,body,x,t"] } -let while0 [cond, body, t, t'] { - !cond[t] && t=t' +let while0 [cond, body, t, t"] { + !cond[t] && t=t" } diff --git a/org.alloytools.alloy.core/src/test/java/org/alloytools/alloy/core/TestReporter.java b/org.alloytools.alloy.core/src/test/java/org/alloytools/alloy/core/TestReporter.java index 2eb3c43bd..5ed1ca5fa 100644 --- a/org.alloytools.alloy.core/src/test/java/org/alloytools/alloy/core/TestReporter.java +++ b/org.alloytools.alloy.core/src/test/java/org/alloytools/alloy/core/TestReporter.java @@ -5,6 +5,9 @@ import edu.mit.csail.sdg.alloy4.A4Reporter; import edu.mit.csail.sdg.alloy4.ErrorWarning; +/** + * @modified [electrum] updated reporting + */ public class TestReporter extends A4Reporter { PrintStream out = System.out; @@ -63,13 +66,15 @@ public void bound(String msg) { * @param solver - the solver chosen by the user (eg. SAT4J, MiniSat...) * @param bitwidth - the integer bitwidth chosen by the user * @param maxseq - the scope on seq/Int chosen by the user + * @param mintrace - the minimum trace length + * @param maxtrace - the maximum trace length * @param skolemDepth - the skolem function depth chosen by the user (0, 1, * 2...) * @param symmetry - the amount of symmetry breaking chosen by the user (0...) */ @Override - public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) { - out.printf("TRNS %s bitwidth=%s maxseq=%s skolem=%s symmetry=%s%n", solver, bitwidth, maxseq, skolemDepth, symmetry); + public void translate(String solver, int bitwidth, int maxseq, int mintrace, int maxtrace, int skolemDepth, int symmetry, String strat) { + out.printf("TRNS %s steps=%s..%s bitwidth=%s maxseq=%s skolem=%s symmetry=%s mode=%s%n", solver, mintrace, maxtrace, bitwidth, maxseq, skolemDepth, symmetry, strat); } /** @@ -81,7 +86,7 @@ public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, * @param clauses - the total number of clauses */ @Override - public void solve(int primaryVars, int totalVars, int clauses) { + public void solve(int step, int primaryVars, int totalVars, int clauses) { out.printf("SOLV primary=%s total=%s clauses=%s%n", primaryVars, totalVars, clauses); } diff --git a/org.alloytools.alloy.dist/.classpath b/org.alloytools.alloy.dist/.classpath index 08abc6d26..bcafe71e5 100644 --- a/org.alloytools.alloy.dist/.classpath +++ b/org.alloytools.alloy.dist/.classpath @@ -1,8 +1,12 @@ - - - + + + + + + + diff --git a/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.core.prefs b/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.core.prefs index 581b9f158..6f9e91618 100644 --- a/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.core.prefs +++ b/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.core.prefs @@ -137,8 +137,11 @@ org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=4 org.eclipse.jdt.core.formatter.align_type_members_on_columns=true +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=2 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=51 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=50 @@ -148,6 +151,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_e org.eclipse.jdt.core.formatter.alignment_for_assignment=2 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=2 org.eclipse.jdt.core.formatter.alignment_for_compact_if=2 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=2 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=2 @@ -191,6 +195,8 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true @@ -242,13 +248,13 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert @@ -415,6 +421,9 @@ org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false diff --git a/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.ui.prefs b/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.ui.prefs index dcee2a4d2..4282c280f 100644 --- a/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.ui.prefs +++ b/org.alloytools.alloy.dist/.settings/org.eclipse.jdt.ui.prefs @@ -60,7 +60,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Alloy -formatter_settings_version=13 +formatter_settings_version=14 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true diff --git a/org.alloytools.alloy.dist/bnd.bnd b/org.alloytools.alloy.dist/bnd.bnd index a3decd456..35289c047 100644 --- a/org.alloytools.alloy.dist/bnd.bnd +++ b/org.alloytools.alloy.dist/bnd.bnd @@ -1,29 +1,30 @@ - Main-Class: edu.mit.csail.sdg.alloy4whole.Alloy -buildpath: \ org.alloytools.alloy.application,\ org.alloytools.alloy.core,\ org.alloytools.alloy.extra,\ - org.alloytools.kodkod.core;version=latest,\ + org.alloytools.pardinus;version=latest,\ org.alloytools.kodkod.nativesat.x86-windows;version=latest,\ org.alloytools.kodkod.nativesat.amd64-linux;version=latest,\ org.alloytools.kodkod.nativesat.util;version=latest,\ org.alloytools.kodkod.nativesat.x86-linux;version=latest,\ - org.alloytools.kodkod.nativesat.x86-mac;version=latest - + org.alloytools.kodkod.nativesat.x86-mac;version=latest,\ + slf4j.api,\ -sources: false -includeresource: \ @${repo;org.alloytools.alloy.application}, \ - @${repo;org.alloytools.alloy.core}, \ + @${repo;org.alloytools.alloy.core}, \ @${repo;org.alloytools.alloy.extra}, \ - @${repo;org.alloytools.kodkod.core}, \ + @${repo;org.alloytools.pardinus}, \ @${repo;org.alloytools.kodkod.nativesat.util}, \ @${repo;org.alloytools.kodkod.nativesat.amd64-linux}, \ @${repo;org.alloytools.kodkod.nativesat.x86-linux}, \ @${repo;org.alloytools.kodkod.nativesat.x86-mac}, \ @${repo;org.alloytools.kodkod.nativesat.x86-windows}, \ @${repo;org.sat4j.core}, \ + @${repo;org.sat4j.maxsat}, \ + @${repo;org.sat4j.pb}, \ LICENSES diff --git a/org.alloytools.alloy.extra/.classpath b/org.alloytools.alloy.extra/.classpath index 08abc6d26..bcafe71e5 100644 --- a/org.alloytools.alloy.extra/.classpath +++ b/org.alloytools.alloy.extra/.classpath @@ -1,8 +1,12 @@ - - - + + + + + + + diff --git a/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.core.prefs b/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.core.prefs index 581b9f158..6f9e91618 100644 --- a/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.core.prefs +++ b/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.core.prefs @@ -137,8 +137,11 @@ org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=4 org.eclipse.jdt.core.formatter.align_type_members_on_columns=true +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=2 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=51 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=50 @@ -148,6 +151,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_e org.eclipse.jdt.core.formatter.alignment_for_assignment=2 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=2 org.eclipse.jdt.core.formatter.alignment_for_compact_if=2 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=2 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=2 @@ -191,6 +195,8 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true @@ -242,13 +248,13 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert @@ -415,6 +421,9 @@ org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false diff --git a/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.ui.prefs b/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.ui.prefs index dcee2a4d2..4282c280f 100644 --- a/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.ui.prefs +++ b/org.alloytools.alloy.extra/.settings/org.eclipse.jdt.ui.prefs @@ -60,7 +60,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Alloy -formatter_settings_version=13 +formatter_settings_version=14 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true diff --git a/org.alloytools.alloy.extra/extra/models/book/appendixA/addressBook2.als b/org.alloytools.alloy.extra/extra/models/book/appendixA/addressBook2.als index 02ba63732..717e68c3c 100644 --- a/org.alloytools.alloy.extra/extra/models/book/appendixA/addressBook2.als +++ b/org.alloytools.alloy.extra/extra/models/book/appendixA/addressBook2.als @@ -14,12 +14,12 @@ pred inv [b: Book] { } } -pred add [b, b': Book, n: Name, t: Name+Addr] { - b'.addr = b.addr + n->t +pred add [b, b": Book, n: Name, t: Name+Addr] { + b".addr = b.addr + n->t } -pred del [b, b': Book, n: Name, t: Name+Addr] { - b'.addr = b.addr - n->t +pred del [b, b": Book, n: Name, t: Name+Addr] { + b".addr = b.addr - n->t } fun lookup [b: Book, n: Name] : set Addr { diff --git a/org.alloytools.alloy.extra/extra/models/book/appendixE/p300-hotel.als b/org.alloytools.alloy.extra/extra/models/book/appendixE/p300-hotel.als index 813846b2a..0354fc3c1 100644 --- a/org.alloytools.alloy.extra/extra/models/book/appendixE/p300-hotel.als +++ b/org.alloytools.alloy.extra/extra/models/book/appendixE/p300-hotel.als @@ -26,25 +26,25 @@ pred init [t: Time] { no issued.t and no cards.t ------ bug! (see page 303) } -pred checkin [t,t': Time, r: Room, g: Guest] { +pred checkin [t,t": Time, r: Room, g: Guest] { some c: Card { c.fst = r.(Desk.prev.t) c.snd not in Desk.issued.t - cards.t' = cards.t + g->c ------------- bug! (see page 306) - Desk.issued.t' = Desk.issued.t + c.snd - Desk.prev.t' = Desk.prev.t ++ r->c.snd + cards.t" = cards.t + g->c ------------- bug! (see page 306) + Desk.issued.t" = Desk.issued.t + c.snd + Desk.prev.t" = Desk.prev.t ++ r->c.snd } - key.t = key.t' + key.t = key.t" } -pred enter [t,t': Time, r: Room, g: Guest] { +pred enter [t,t": Time, r: Room, g: Guest] { some c: g.cards.t | let k = r.key.t { - c.snd = k and key.t' = key.t - or c.fst = k and key.t' = key.t ++ r->c.snd + c.snd = k and key.t" = key.t + or c.fst = k and key.t" = key.t ++ r->c.snd } - issued.t = issued.t' and (Desk<:prev).t = prev.t' - cards.t = cards.t' + issued.t = issued.t" and (Desk<:prev).t = prev.t" + cards.t = cards.t" } fact Traces { @@ -54,10 +54,10 @@ fact Traces { } assert NoIntruder { - no t1: Time, g: Guest, g': Guest-g, r: Room | + no t1: Time, g: Guest, g": Guest-g, r: Room | let t2=t1.next, t3=t2.next, t4=t3.next { enter [t1, t2, r, g] - enter [t2, t3, r, g'] + enter [t2, t3, r, g"] enter [t3, t4, r, g] } } diff --git a/org.alloytools.alloy.extra/extra/models/book/appendixE/p303-hotel.als b/org.alloytools.alloy.extra/extra/models/book/appendixE/p303-hotel.als index 652de3d81..7db2f8ba9 100644 --- a/org.alloytools.alloy.extra/extra/models/book/appendixE/p303-hotel.als +++ b/org.alloytools.alloy.extra/extra/models/book/appendixE/p303-hotel.als @@ -26,25 +26,25 @@ pred init [t: Time] { Desk.issued.t = Room.key.t and no cards.t } -pred checkin [t,t': Time, r: Room, g: Guest] { +pred checkin [t,t": Time, r: Room, g: Guest] { some c: Card { c.fst = r.(Desk.prev.t) c.snd not in Desk.issued.t - cards.t' = cards.t + g->c ------------- bug! (see page 306) - Desk.issued.t' = Desk.issued.t + c.snd - Desk.prev.t' = Desk.prev.t ++ r->c.snd + cards.t" = cards.t + g->c ------------- bug! (see page 306) + Desk.issued.t" = Desk.issued.t + c.snd + Desk.prev.t" = Desk.prev.t ++ r->c.snd } - key.t = key.t' + key.t = key.t" } -pred enter [t,t': Time, r: Room, g: Guest] { +pred enter [t,t": Time, r: Room, g: Guest] { some c: g.cards.t | let k = r.key.t { - c.snd = k and key.t' = key.t - or c.fst = k and key.t' = key.t ++ r->c.snd + c.snd = k and key.t" = key.t + or c.fst = k and key.t" = key.t ++ r->c.snd } - issued.t = issued.t' and (Desk<:prev).t = prev.t' - cards.t = cards.t' + issued.t = issued.t" and (Desk<:prev).t = prev.t" + cards.t = cards.t" } fact Traces { @@ -54,10 +54,10 @@ fact Traces { } assert NoIntruder { - no t1: Time, g: Guest, g': Guest-g, r: Room | + no t1: Time, g: Guest, g": Guest-g, r: Room | let t2=t1.next, t3=t2.next, t4=t3.next { enter [t1, t2, r, g] - enter [t2, t3, r, g'] + enter [t2, t3, r, g"] enter [t3, t4, r, g] } } diff --git a/org.alloytools.alloy.extra/extra/models/book/appendixE/p306-hotel.als b/org.alloytools.alloy.extra/extra/models/book/appendixE/p306-hotel.als index efcd7e7d8..b22443c14 100644 --- a/org.alloytools.alloy.extra/extra/models/book/appendixE/p306-hotel.als +++ b/org.alloytools.alloy.extra/extra/models/book/appendixE/p306-hotel.als @@ -26,25 +26,25 @@ pred init [t: Time] { Desk.issued.t = Room.key.t and no cards.t } -pred checkin [t,t': Time, r: Room, g: Guest] { +pred checkin [t,t": Time, r: Room, g: Guest] { some c: Card { c.fst = r.(Desk.prev.t) c.snd not in Desk.issued.t - cards.t' = cards.t ++ g->c - Desk.issued.t' = Desk.issued.t + c.snd - Desk.prev.t' = Desk.prev.t ++ r->c.snd + cards.t" = cards.t ++ g->c + Desk.issued.t" = Desk.issued.t + c.snd + Desk.prev.t" = Desk.prev.t ++ r->c.snd } - key.t = key.t' + key.t = key.t" } -pred enter [t,t': Time, r: Room, g: Guest] { +pred enter [t,t": Time, r: Room, g: Guest] { some c: g.cards.t | let k = r.key.t { - c.snd = k and key.t' = key.t - or c.fst = k and key.t' = key.t ++ r->c.snd + c.snd = k and key.t" = key.t + or c.fst = k and key.t" = key.t ++ r->c.snd } - issued.t = issued.t' and (Desk<:prev).t = prev.t' - cards.t = cards.t' + issued.t = issued.t" and (Desk<:prev).t = prev.t" + cards.t = cards.t" } fact Traces { @@ -54,10 +54,10 @@ fact Traces { } assert NoIntruder { - no t1: Time, g: Guest, g': Guest-g, r: Room | + no t1: Time, g: Guest, g": Guest-g, r: Room | let t2=t1.next, t3=t2.next, t4=t3.next { enter [t1, t2, r, g] - enter [t2, t3, r, g'] + enter [t2, t3, r, g"] enter [t3, t4, r, g] } } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1e.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1e.als index 18165f341..310c700bb 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1e.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1e.als @@ -6,8 +6,8 @@ sig Book { addr: Name -> lone Addr } -pred add [b, b': Book, n: Name, a: Addr] { - b'.addr = b.addr + n->a +pred add [b, b": Book, n: Name, a: Addr] { + b".addr = b.addr + n->a } // This command generates an instance similar to Fig 2.4 diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1f.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1f.als index 8774cd7b8..6c9acc8ad 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1f.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1f.als @@ -6,13 +6,13 @@ sig Book { addr: Name -> lone Addr } -pred add [b, b': Book, n: Name, a: Addr] { - b'.addr = b.addr + n->a +pred add [b, b": Book, n: Name, a: Addr] { + b".addr = b.addr + n->a } -pred showAdd [b, b': Book, n: Name, a: Addr] { - add [b, b', n, a] - #Name.(b'.addr) > 1 +pred showAdd [b, b": Book, n: Name, a: Addr] { + add [b, b", n, a] + #Name.(b".addr) > 1 } // This command generates an instance similar to Fig 2.5 diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1g.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1g.als index 4eeac73ad..407a8f875 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1g.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1g.als @@ -6,12 +6,12 @@ sig Book { addr: Name -> lone Addr } -pred add [b, b': Book, n: Name, a: Addr] { - b'.addr = b.addr + n->a +pred add [b, b": Book, n: Name, a: Addr] { + b".addr = b.addr + n->a } -pred del [b, b': Book, n: Name] { - b'.addr = b.addr - n->Addr +pred del [b, b": Book, n: Name] { + b".addr = b.addr - n->Addr } fun lookup [b: Book, n: Name] : set Addr { @@ -19,10 +19,10 @@ fun lookup [b: Book, n: Name] : set Addr { } assert delUndoesAdd { - all b, b', b'': Book, n: Name, a: Addr | - add [b, b', n, a] and del [b', b'', n] + all b, b", b"": Book, n: Name, a: Addr | + add [b, b", n, a] and del [b", b"", n] implies - b.addr = b''.addr + b.addr = b"".addr } // This command generates an instance similar to Fig 2.6 diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1h.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1h.als index 115eab78f..3fae21946 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1h.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook1h.als @@ -12,43 +12,43 @@ pred show [b: Book] { } run show for 3 but 1 Book -pred add [b, b': Book, n: Name, a: Addr] { - b'.addr = b.addr + n->a +pred add [b, b": Book, n: Name, a: Addr] { + b".addr = b.addr + n->a } -pred del [b, b': Book, n: Name] { - b'.addr = b.addr - n->Addr +pred del [b, b": Book, n: Name] { + b".addr = b.addr - n->Addr } fun lookup [b: Book, n: Name] : set Addr { n.(b.addr) } -pred showAdd [b, b': Book, n: Name, a: Addr] { - add [b, b', n, a] - #Name.(b'.addr) > 1 +pred showAdd [b, b": Book, n: Name, a: Addr] { + add [b, b", n, a] + #Name.(b".addr) > 1 } run showAdd for 3 but 2 Book assert delUndoesAdd { - all b, b', b'': Book, n: Name, a: Addr | - no n.(b.addr) and add [b, b', n, a] and del [b', b'', n] + all b, b", b"": Book, n: Name, a: Addr | + no n.(b.addr) and add [b, b", n, a] and del [b", b"", n] implies - b.addr = b''.addr + b.addr = b"".addr } assert addIdempotent { - all b, b', b'': Book, n: Name, a: Addr | - add [b, b', n, a] and add [b', b'', n, a] + all b, b", b"": Book, n: Name, a: Addr | + add [b, b", n, a] and add [b", b"", n, a] implies - b'.addr = b''.addr + b".addr = b"".addr } assert addLocal { - all b, b': Book, n, n': Name, a: Addr | - add [b, b', n, a] and n != n' + all b, b": Book, n, n": Name, a: Addr | + add [b, b", n, a] and n != n" implies - lookup [b, n'] = lookup [b', n'] + lookup [b, n"] = lookup [b", n"] } // This command should not find any counterexample. diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook2e.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook2e.als index 3baea5ace..116cae11a 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook2e.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook2e.als @@ -14,35 +14,35 @@ sig Book { all a: Alias | lone a.addr } -pred add [b, b': Book, n: Name, t: Target] { b'.addr = b.addr + n->t } -pred del [b, b': Book, n: Name, t: Target] { b'.addr = b.addr - n->t } +pred add [b, b": Book, n: Name, t: Target] { b".addr = b.addr + n->t } +pred del [b, b": Book, n: Name, t: Target] { b".addr = b.addr - n->t } fun lookup [b: Book, n: Name] : set Addr { n.^(b.addr) & Addr } assert delUndoesAdd { - all b, b', b'': Book, n: Name, t: Target | - no n.(b.addr) and add [b, b', n, t] and del [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + no n.(b.addr) and add [b, b", n, t] and del [b", b"", n, t] implies - b.addr = b''.addr + b.addr = b"".addr } // This should not find any counterexample. check delUndoesAdd for 3 assert addIdempotent { - all b, b', b'': Book, n: Name, t: Target | - add [b, b', n, t] and add [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + add [b, b", n, t] and add [b", b"", n, t] implies - b'.addr = b''.addr + b".addr = b"".addr } // This should not find any counterexample. check addIdempotent for 3 assert addLocal { - all b, b': Book, n, n': Name, t: Target | - add [b, b', n, t] and n != n' + all b, b": Book, n, n": Name, t: Target | + add [b, b", n, t] and n != n" implies - lookup [b, n'] = lookup [b', n'] + lookup [b, n"] = lookup [b", n"] } // This shows a counterexample similar to Fig 2.13 diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3a.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3a.als index 5ff9eee08..a6bffc121 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3a.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3a.als @@ -16,8 +16,8 @@ sig Book { all a: Alias | lone a.addr } -pred add [b, b': Book, n: Name, t: Target] { b'.addr = b.addr + n->t } -pred del [b, b': Book, n: Name, t: Target] { b'.addr = b.addr - n->t } +pred add [b, b": Book, n: Name, t: Target] { b".addr = b.addr + n->t } +pred del [b, b": Book, n: Name, t: Target] { b".addr = b.addr - n->t } fun lookup [b: Book, n: Name] : set Addr { n.^(b.addr) & Addr } pred init [b: Book] { no b.addr } @@ -25,9 +25,9 @@ pred init [b: Book] { no b.addr } fact traces { init [first] all b: Book-last | - let b' = b.next | + let b" = b.next | some n: Name, t: Target | - add [b, b', n, t] or del [b, b', n, t] + add [b, b", n, t] or del [b, b", n, t] } ------------------------------------------------------ diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3b.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3b.als index 5c4b835df..ee2651329 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3b.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3b.als @@ -16,8 +16,8 @@ sig Book { all a: Alias | lone a.addr } -pred add [b, b': Book, n: Name, t: Target] { b'.addr = b.addr + n->t } -pred del [b, b': Book, n: Name, t: Target] { b'.addr = b.addr - n->t } +pred add [b, b": Book, n: Name, t: Target] { b".addr = b.addr + n->t } +pred del [b, b": Book, n: Name, t: Target] { b".addr = b.addr - n->t } fun lookup [b: Book, n: Name] : set Addr { n.^(b.addr) & Addr } pred init [b: Book] { no b.addr } @@ -25,18 +25,18 @@ pred init [b: Book] { no b.addr } fact traces { init [first] all b: Book-last | - let b' = b.next | + let b" = b.next | some n: Name, t: Target | - add [b, b', n, t] or del [b, b', n, t] + add [b, b", n, t] or del [b, b", n, t] } ------------------------------------------------------ assert delUndoesAdd { - all b, b', b'': Book, n: Name, t: Target | - no n.(b.addr) and add [b, b', n, t] and del [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + no n.(b.addr) and add [b, b", n, t] and del [b", b"", n, t] implies - b.addr = b''.addr + b.addr = b"".addr } // This should not find any counterexample. @@ -45,10 +45,10 @@ check delUndoesAdd for 3 ------------------------------------------------------ assert addIdempotent { - all b, b', b'': Book, n: Name, t: Target | - add [b, b', n, t] and add [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + add [b, b", n, t] and add [b", b"", n, t] implies - b'.addr = b''.addr + b".addr = b"".addr } // This should not find any counterexample. @@ -57,10 +57,10 @@ check addIdempotent for 3 ------------------------------------------------------ assert addLocal { - all b, b': Book, n, n': Name, t: Target | - add [b, b', n, t] and n != n' + all b, b": Book, n, n": Name, t: Target | + add [b, b", n, t] and n != n" implies - lookup [b, n'] = lookup [b', n'] + lookup [b, n"] = lookup [b", n"] } // This should not find any counterexample. diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3c.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3c.als index 284f8c365..50b9bb68e 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3c.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3c.als @@ -16,12 +16,12 @@ sig Book { all a: Alias | lone a.addr } -pred add [b, b': Book, n: Name, t: Target] { +pred add [b, b": Book, n: Name, t: Target] { t in Addr or some lookup [b, Name&t] - b'.addr = b.addr + n->t + b".addr = b.addr + n->t } -pred del [b, b': Book, n: Name, t: Target] { b'.addr = b.addr - n->t } +pred del [b, b": Book, n: Name, t: Target] { b".addr = b.addr - n->t } fun lookup [b: Book, n: Name] : set Addr { n.^(b.addr) & Addr } @@ -30,18 +30,18 @@ pred init [b: Book] { no b.addr } fact traces { init [first] all b: Book-last | - let b' = b.next | + let b" = b.next | some n: Name, t: Target | - add [b, b', n, t] or del [b, b', n, t] + add [b, b", n, t] or del [b, b", n, t] } ------------------------------------------------------ assert delUndoesAdd { - all b, b', b'': Book, n: Name, t: Target | - no n.(b.addr) and add [b, b', n, t] and del [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + no n.(b.addr) and add [b, b", n, t] and del [b", b"", n, t] implies - b.addr = b''.addr + b.addr = b"".addr } // This should not find any counterexample. @@ -50,10 +50,10 @@ check delUndoesAdd for 3 ------------------------------------------------------ assert addIdempotent { - all b, b', b'': Book, n: Name, t: Target | - add [b, b', n, t] and add [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + add [b, b", n, t] and add [b", b"", n, t] implies - b'.addr = b''.addr + b".addr = b"".addr } // This should not find any counterexample. @@ -62,10 +62,10 @@ check addIdempotent for 3 ------------------------------------------------------ assert addLocal { - all b, b': Book, n, n': Name, t: Target | - add [b, b', n, t] and n != n' + all b, b": Book, n, n": Name, t: Target | + add [b, b", n, t] and n != n" implies - lookup [b, n'] = lookup [b', n'] + lookup [b, n"] = lookup [b", n"] } // This should not find any counterexample. diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3d.als b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3d.als index aceac5148..4905ec172 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3d.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter2/addressBook3d.als @@ -16,14 +16,14 @@ sig Book { all a: Alias | lone a.addr } -pred add [b, b': Book, n: Name, t: Target] { +pred add [b, b": Book, n: Name, t: Target] { t in Addr or some lookup [b, Name&t] - b'.addr = b.addr + n->t + b".addr = b.addr + n->t } -pred del [b, b': Book, n: Name, t: Target] { +pred del [b, b": Book, n: Name, t: Target] { no b.addr.n or some n.(b.addr) - t - b'.addr = b.addr - n->t + b".addr = b.addr - n->t } fun lookup [b: Book, n: Name] : set Addr { n.^(b.addr) & Addr } @@ -33,18 +33,18 @@ pred init [b: Book] { no b.addr } fact traces { init [first] all b: Book-last | - let b' = b.next | + let b" = b.next | some n: Name, t: Target | - add [b, b', n, t] or del [b, b', n, t] + add [b, b", n, t] or del [b, b", n, t] } ------------------------------------------------------ assert delUndoesAdd { - all b, b', b'': Book, n: Name, t: Target | - no n.(b.addr) and add [b, b', n, t] and del [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + no n.(b.addr) and add [b, b", n, t] and del [b", b"", n, t] implies - b.addr = b''.addr + b.addr = b"".addr } // This should not find any counterexample. @@ -53,10 +53,10 @@ check delUndoesAdd for 3 ------------------------------------------------------ assert addIdempotent { - all b, b', b'': Book, n: Name, t: Target | - add [b, b', n, t] and add [b', b'', n, t] + all b, b", b"": Book, n: Name, t: Target | + add [b, b", n, t] and add [b", b"", n, t] implies - b'.addr = b''.addr + b".addr = b"".addr } // This should not find any counterexample. @@ -65,10 +65,10 @@ check addIdempotent for 3 ------------------------------------------------------ assert addLocal { - all b, b': Book, n, n': Name, t: Target | - add [b, b', n, t] and n != n' + all b, b": Book, n, n": Name, t: Target | + add [b, b", n, t] and n != n" implies - lookup [b, n'] = lookup [b', n'] + lookup [b, n"] = lookup [b", n"] } // This should not find any counterexample. diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter4/lights.als b/org.alloytools.alloy.extra/extra/models/book/chapter4/lights.als index 24997705b..532ae6528 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter4/lights.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter4/lights.als @@ -18,18 +18,18 @@ pred mostlyRed [s: LightState, j: Junction] { lone j.lights - redLights[s] } -pred trans [s, s': LightState, j: Junction] { - lone x: j.lights | s.color[x] != s'.color[x] +pred trans [s, s": LightState, j: Junction] { + lone x: j.lights | s.color[x] != s".color[x] all x: j.lights | - let step = s.color[x] -> s'.color[x] { - step in colorSequence - step in Red->(Color-Red) => j.lights in redLights[s] + let step" = s.color[x] -> s".color[x] { + step" in colorSequence + step" in Red->(Color-Red) => j.lights in redLights[s] } } assert Safe { - all s, s': LightState, j: Junction | - mostlyRed [s, j] and trans [s, s', j] => mostlyRed [s', j] + all s, s": LightState, j: Junction | + mostlyRed [s, j] and trans [s, s", j] => mostlyRed [s", j] } check Safe for 3 but 1 Junction diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter5/addressBook.als b/org.alloytools.alloy.extra/extra/models/book/chapter5/addressBook.als index 5d7dee568..dcec5293c 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter5/addressBook.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter5/addressBook.als @@ -8,8 +8,8 @@ sig Book {addr: Name -> Target} fact Acyclic {all b: Book | no n: Name | n in n.^(b.addr)} -pred add [b, b': Book, n: Name, t: Target] { - b'.addr = b.addr + n -> t +pred add [b, b": Book, n: Name, t: Target] { + b".addr = b.addr + n -> t } // This command should produce an instance similar to Fig 5.2 @@ -18,8 +18,8 @@ run add for 3 but 2 Book fun lookup [b: Book, n: Name]: set Addr {n.^(b.addr) & Addr} assert addLocal { - all b,b': Book, n,n': Name, t: Target | - add [b,b',n,t] and n != n' => lookup [b,n'] = lookup [b',n'] + all b,b": Book, n,n": Name, t: Target | + add [b,b",n,t] and n != n" => lookup [b,n"] = lookup [b",n"] } // This command should produce a counterexample similar to Fig 5.3 diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter5/lists.als b/org.alloytools.alloy.extra/extra/models/book/chapter5/lists.als index 79cbd0da5..bf70170fa 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter5/lists.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter5/lists.als @@ -11,7 +11,7 @@ sig NonEmptyList extends List { fact ListGenerator { all list: List, e: Element | - some list': List | list'.rest = list and list'.element = e + some list": List | list".rest = list and list".element = e } assert FalseAssertion { diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter5/sets2.als b/org.alloytools.alloy.extra/extra/models/book/chapter5/sets2.als index 265a1e64f..1d4c2b199 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter5/sets2.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter5/sets2.als @@ -14,7 +14,7 @@ assert Closed { fact SetGenerator { some s: Set | no s.elements - all s: Set, e: Element | some s': Set | s'.elements = s.elements + e + all s: Set, e: Element | some s": Set | s".elements = s.elements + e } // This check should not produce a counterexample diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel1.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel1.als index 22610689a..1368cf091 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel1.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel1.als @@ -35,66 +35,66 @@ pred init [t: Time] { all r: Room | FrontDesk.lastKey.t [r] = r.currentKey.t } -pred entry [t, t': Time, g: Guest, r: Room, k: Key] { +pred entry [t, t": Time, g: Guest, r: Room, k: Key] { k in g.keys.t let ck = r.currentKey | - (k = ck.t and ck.t' = ck.t) or - (k = nextKey[ck.t, r.keys] and ck.t' = k) - noRoomChangeExcept [t, t', r] - noGuestChangeExcept [t, t', none] - noFrontDeskChange [t, t'] + (k = ck.t and ck.t" = ck.t) or + (k = nextKey[ck.t, r.keys] and ck.t" = k) + noRoomChangeExcept [t, t", r] + noGuestChangeExcept [t, t", none] + noFrontDeskChange [t, t"] } -pred noFrontDeskChange [t, t': Time] { - FrontDesk.lastKey.t = FrontDesk.lastKey.t' - FrontDesk.occupant.t = FrontDesk.occupant.t' +pred noFrontDeskChange [t, t": Time] { + FrontDesk.lastKey.t = FrontDesk.lastKey.t" + FrontDesk.occupant.t = FrontDesk.occupant.t" } -pred noRoomChangeExcept [t, t': Time, rs: set Room] { - all r: Room - rs | r.currentKey.t = r.currentKey.t' +pred noRoomChangeExcept [t, t": Time, rs: set Room] { + all r: Room - rs | r.currentKey.t = r.currentKey.t" } -pred noGuestChangeExcept [t, t': Time, gs: set Guest] { - all g: Guest - gs | g.keys.t = g.keys.t' +pred noGuestChangeExcept [t, t": Time, gs: set Guest] { + all g: Guest - gs | g.keys.t = g.keys.t" } -pred checkout [t, t': Time, g: Guest] { +pred checkout [t, t": Time, g: Guest] { let occ = FrontDesk.occupant { some occ.t.g - occ.t' = occ.t - Room ->g + occ.t" = occ.t - Room ->g } - FrontDesk.lastKey.t = FrontDesk.lastKey.t' - noRoomChangeExcept [t, t', none] - noGuestChangeExcept [t, t', none] + FrontDesk.lastKey.t = FrontDesk.lastKey.t" + noRoomChangeExcept [t, t", none] + noGuestChangeExcept [t, t", none] } -pred checkin [t, t': Time, g: Guest, r: Room, k: Key] { - g.keys.t' = g.keys.t + k +pred checkin [t, t": Time, g: Guest, r: Room, k: Key] { + g.keys.t" = g.keys.t + k let occ = FrontDesk.occupant { no occ.t [r] - occ.t' = occ.t + r -> g + occ.t" = occ.t + r -> g } let lk = FrontDesk.lastKey { - lk.t' = lk.t ++ r -> k + lk.t" = lk.t ++ r -> k k = nextKey [lk.t [r], r.keys] } - noRoomChangeExcept [t, t', none] - noGuestChangeExcept [t, t', g] + noRoomChangeExcept [t, t", none] + noGuestChangeExcept [t, t", g] } fact traces { init [first] - all t: Time-last | let t' = t.next | + all t: Time-last | let t" = t.next | some g: Guest, r: Room, k: Key | - entry [t, t', g, r, k] - or checkin [t, t', g, r, k] - or checkout [t, t', g] + entry [t, t", g, r, k] + or checkin [t, t", g, r, k] + or checkout [t, t", g] } assert NoBadEntry { all t: Time, r: Room, g: Guest, k: Key | - let t' = t.next, o = FrontDesk.occupant.t[r] | - entry [t, t', g, r, k] and some o => g in o + let t" = t.next, o = FrontDesk.occupant.t[r] | + entry [t, t", g, r, k] and some o => g in o } // This generates a counterexample similar to Fig 6.6 diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel2.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel2.als index 09378f2e0..159ae962b 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel2.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel2.als @@ -35,72 +35,72 @@ pred init [t: Time] { all r: Room | FrontDesk.lastKey.t [r] = r.currentKey.t } -pred entry [t, t': Time, g: Guest, r: Room, k: Key] { +pred entry [t, t": Time, g: Guest, r: Room, k: Key] { k in g.keys.t let ck = r.currentKey | - (k = ck.t and ck.t' = ck.t) or - (k = nextKey[ck.t, r.keys] and ck.t' = k) - noRoomChangeExcept [t, t', r] - noGuestChangeExcept [t, t', none] - noFrontDeskChange [t, t'] + (k = ck.t and ck.t" = ck.t) or + (k = nextKey[ck.t, r.keys] and ck.t" = k) + noRoomChangeExcept [t, t", r] + noGuestChangeExcept [t, t", none] + noFrontDeskChange [t, t"] } -pred noFrontDeskChange [t, t': Time] { - FrontDesk.lastKey.t = FrontDesk.lastKey.t' - FrontDesk.occupant.t = FrontDesk.occupant.t' +pred noFrontDeskChange [t, t": Time] { + FrontDesk.lastKey.t = FrontDesk.lastKey.t" + FrontDesk.occupant.t = FrontDesk.occupant.t" } -pred noRoomChangeExcept [t, t': Time, rs: set Room] { - all r: Room - rs | r.currentKey.t = r.currentKey.t' +pred noRoomChangeExcept [t, t": Time, rs: set Room] { + all r: Room - rs | r.currentKey.t = r.currentKey.t" } -pred noGuestChangeExcept [t, t': Time, gs: set Guest] { - all g: Guest - gs | g.keys.t = g.keys.t' +pred noGuestChangeExcept [t, t": Time, gs: set Guest] { + all g: Guest - gs | g.keys.t = g.keys.t" } -pred checkout [t, t': Time, g: Guest] { +pred checkout [t, t": Time, g: Guest] { let occ = FrontDesk.occupant { some occ.t.g - occ.t' = occ.t - Room ->g + occ.t" = occ.t - Room ->g } - FrontDesk.lastKey.t = FrontDesk.lastKey.t' - noRoomChangeExcept [t, t', none] - noGuestChangeExcept [t, t', none] + FrontDesk.lastKey.t = FrontDesk.lastKey.t" + noRoomChangeExcept [t, t", none] + noGuestChangeExcept [t, t", none] } -pred checkin [t, t': Time, g: Guest, r: Room, k: Key] { - g.keys.t' = g.keys.t + k +pred checkin [t, t": Time, g: Guest, r: Room, k: Key] { + g.keys.t" = g.keys.t + k let occ = FrontDesk.occupant { no occ.t [r] - occ.t' = occ.t + r -> g + occ.t" = occ.t + r -> g } let lk = FrontDesk.lastKey { - lk.t' = lk.t ++ r -> k + lk.t" = lk.t ++ r -> k k = nextKey [lk.t [r], r.keys] } - noRoomChangeExcept [t, t', none] - noGuestChangeExcept [t, t', g] + noRoomChangeExcept [t, t", none] + noGuestChangeExcept [t, t", g] } fact traces { init [first] - all t: Time-last | let t' = t.next | + all t: Time-last | let t" = t.next | some g: Guest, r: Room, k: Key | - entry [t, t', g, r, k] - or checkin [t, t', g, r, k] - or checkout [t, t', g] + entry [t, t", g, r, k] + or checkin [t, t", g, r, k] + or checkout [t, t", g] } fact NoIntervening { - all t: Time-last | let t' = t.next, t" = t'.next | + all t: Time-last | let t" = t.next, t"" = t".next | all g: Guest, r: Room, k: Key | - checkin [t, t', g, r, k] => (entry [t', t", g, r, k] or no t") + checkin [t, t", g, r, k] => (entry [t", t"", g, r, k] or no t"") } assert NoBadEntry { all t: Time, r: Room, g: Guest, k: Key | - let t' = t.next, o = FrontDesk.occupant.t[r] | - entry [t, t', g, r, k] and some o => g in o + let t" = t.next, o = FrontDesk.occupant.t[r] | + entry [t, t", g, r, k] and some o => g in o } // After adding the NoIntervening fact, diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel3.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel3.als index b3ad4b499..dac205cbd 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel3.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel3.als @@ -73,12 +73,12 @@ sig Checkout extends Event { } { fact Traces { init [first] all t: Time-last | - let t' = t.next | + let t" = t.next | some e: Event { - e.pre = t and e.post = t' - currentKey.t != currentKey.t' => e in Entry - occupant.t != occupant.t' => e in Checkin + Checkout - (lastKey.t != lastKey.t' or keys.t != keys.t') => e in Checkin + e.pre = t and e.post = t" + currentKey.t != currentKey.t" => e in Entry + occupant.t != occupant.t" => e in Checkin + Checkout + (lastKey.t != lastKey.t" or keys.t != keys.t") => e in Checkin } } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel4.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel4.als index 35f3566b6..d860850fd 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel4.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/hotel4.als @@ -73,12 +73,12 @@ sig Checkout extends Event { } { fact Traces { init [first] all t: Time-last | - let t' = t.next | + let t" = t.next | some e: Event { - e.pre = t and e.post = t' - currentKey.t != currentKey.t' => e in Entry - occupant.t != occupant.t' => e in Checkin + Checkout - (lastKey.t != lastKey.t' or keys.t != keys.t') => e in Checkin + e.pre = t and e.post = t" + currentKey.t != currentKey.t" => e in Entry + occupant.t != occupant.t" => e in Checkin + Checkout + (lastKey.t != lastKey.t" or keys.t != keys.t") => e in Checkin } } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/mediaAssets.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/mediaAssets.als index 668b31303..89a85eb2d 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/mediaAssets.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/mediaAssets.als @@ -27,90 +27,90 @@ pred appInv [xs: ApplicationState] { all cs: xs.catalogs | catalogInv [xs.catalogState[cs]] } -pred showSelected [cs, cs': CatalogState] { +pred showSelected [cs, cs": CatalogState] { cs.selection != Undefined - cs'.showing = cs.selection - cs'.selection = cs.selection - cs'.assets = cs.assets + cs".showing = cs.selection + cs".selection = cs.selection + cs".assets = cs.assets } -pred hideSelected [cs, cs': CatalogState] { +pred hideSelected [cs, cs": CatalogState] { cs.selection != Undefined - cs'.hidden = cs.hidden + cs.selection - cs'.selection = Undefined - cs'.assets = cs.assets + cs".hidden = cs.hidden + cs.selection + cs".selection = Undefined + cs".assets = cs.assets } -pred cut [xs, xs': ApplicationState] { +pred cut [xs, xs": ApplicationState] { let cs = xs.currentCatalog.(xs.catalogState), sel = cs.selection { sel != Undefined - xs'.buffer = sel - some cs': CatalogState { - cs'.assets = cs.assets - sel - cs'.showing = cs.showing - sel - cs'.selection = Undefined - xs'.catalogState = xs.catalogState ++ xs.currentCatalog -> cs' + xs".buffer = sel + some cs": CatalogState { + cs".assets = cs.assets - sel + cs".showing = cs.showing - sel + cs".selection = Undefined + xs".catalogState = xs.catalogState ++ xs.currentCatalog -> cs" } } - xs'.catalogs = xs.catalogs - xs'.currentCatalog = xs.currentCatalog + xs".catalogs = xs.catalogs + xs".currentCatalog = xs.currentCatalog } -pred paste [xs, xs': ApplicationState] { +pred paste [xs, xs": ApplicationState] { let cs = xs.currentCatalog.(xs.catalogState), buf = xs.buffer { - xs'.buffer = buf - some cs': CatalogState { - cs'.assets = cs.assets + buf - cs'.showing = cs.showing + (buf - cs.assets) - cs'.selection = buf - cs.assets - xs'.catalogState = xs.catalogState ++ xs.currentCatalog -> cs' + xs".buffer = buf + some cs": CatalogState { + cs".assets = cs.assets + buf + cs".showing = cs.showing + (buf - cs.assets) + cs".selection = buf - cs.assets + xs".catalogState = xs.catalogState ++ xs.currentCatalog -> cs" } } - xs'.catalogs = xs.catalogs - xs'.currentCatalog = xs.currentCatalog + xs".catalogs = xs.catalogs + xs".currentCatalog = xs.currentCatalog } assert HidePreservesInv { - all cs, cs': CatalogState | - catalogInv [cs] and hideSelected [cs, cs'] => catalogInv [cs'] + all cs, cs": CatalogState | + catalogInv [cs] and hideSelected [cs, cs"] => catalogInv [cs"] } // This check should not find any counterexample check HidePreservesInv -pred sameApplicationState [xs, xs': ApplicationState] { - xs'.catalogs = xs.catalogs - all c: xs.catalogs | sameCatalogState [c.(xs.catalogState), c.(xs'.catalogState)] - xs'.currentCatalog = xs.currentCatalog - xs'.buffer = xs.buffer +pred sameApplicationState [xs, xs": ApplicationState] { + xs".catalogs = xs.catalogs + all c: xs.catalogs | sameCatalogState [c.(xs.catalogState), c.(xs".catalogState)] + xs".currentCatalog = xs.currentCatalog + xs".buffer = xs.buffer } -pred sameCatalogState [cs, cs': CatalogState] { - cs'.assets = cs.assets - cs'.showing = cs.showing - cs'.selection = cs.selection +pred sameCatalogState [cs, cs": CatalogState] { + cs".assets = cs.assets + cs".showing = cs.showing + cs".selection = cs.selection } assert CutPaste { - all xs, xs', xs": ApplicationState | - (appInv [xs] and cut [xs, xs'] and paste [xs', xs"]) => sameApplicationState [xs, xs"] + all xs, xs", xs"": ApplicationState | + (appInv [xs] and cut [xs, xs"] and paste [xs", xs""]) => sameApplicationState [xs, xs""] } // This check should find a counterexample check CutPaste assert PasteCut { - all xs, xs', xs": ApplicationState | - (appInv [xs] and paste [xs, xs'] and cut [xs', xs"]) => sameApplicationState [xs, xs"] + all xs, xs", xs"": ApplicationState | + (appInv [xs] and paste [xs, xs"] and cut [xs", xs""]) => sameApplicationState [xs, xs""] } // This check should find a counterexample check PasteCut assert PasteNotAffectHidden { - all xs, xs': ApplicationState | - (appInv [xs] and paste [xs, xs']) => - let c = xs.currentCatalog | xs'.catalogState[c].hidden = xs.catalogState[c].hidden + all xs, xs": ApplicationState | + (appInv [xs] and paste [xs, xs"]) => + let c = xs.currentCatalog | xs".catalogState[c].hidden = xs.catalogState[c].hidden } // This check should not find any counterexample diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/abstractMemory.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/abstractMemory.als index 3d676d507..b0495c7e3 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/abstractMemory.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/abstractMemory.als @@ -8,26 +8,26 @@ pred init [m: Memory] { no m.data } -pred write [m, m': Memory, a: Addr, d: Data] { - m'.data = m.data ++ a -> d +pred write [m, m": Memory, a: Addr, d: Data] { + m".data = m.data ++ a -> d } pred read [m: Memory, a: Addr, d: Data] { - let d' = m.data [a] | some d' implies d = d' + let d" = m.data [a] | some d" implies d = d" } fact Canonicalize { - no disj m, m': Memory | m.data = m'.data + no disj m, m": Memory | m.data = m".data } // This command should not find any counterexample WriteRead: check { - all m, m': Memory, a: Addr, d1, d2: Data | - write [m, m', a, d1] and read [m', a, d2] => d1 = d2 + all m, m": Memory, a: Addr, d1, d2: Data | + write [m, m", a, d1] and read [m", a, d2] => d1 = d2 } // This command should not find any counterexample WriteIdempotent: check { - all m, m', m": Memory, a: Addr, d: Data | - write [m, m', a, d] and write [m', m", a, d] => m' = m" + all m, m", m"": Memory, a: Addr, d: Data | + write [m, m", a, d] and write [m", m"", a, d] => m" = m"" } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/cacheMemory.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/cacheMemory.als index c95fe22b6..05bf77d7f 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/cacheMemory.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/cacheMemory.als @@ -8,9 +8,9 @@ pred init [c: CacheSystem] { no c.main + c.cache } -pred write [c, c': CacheSystem, a: Addr, d: Data] { - c'.main = c.main - c'.cache = c.cache ++ a -> d +pred write [c, c": CacheSystem, a: Addr, d: Data] { + c".main = c.main + c".cache = c.cache ++ a -> d } pred read [c: CacheSystem, a: Addr, d: Data] { @@ -18,26 +18,26 @@ pred read [c: CacheSystem, a: Addr, d: Data] { d = c.cache [a] } -pred load [c, c': CacheSystem] { +pred load [c, c": CacheSystem] { some addrs: set c.main.Data - c.cache.Data | - c'.cache = c.cache ++ addrs <: c.main - c'.main = c.main + c".cache = c.cache ++ addrs <: c.main + c".main = c.main } -pred flush [c, c': CacheSystem] { +pred flush [c, c": CacheSystem] { some addrs: some c.cache.Data { - c'.main = c.main ++ addrs <: c.cache - c'.cache = c.cache - addrs -> Data + c".main = c.main ++ addrs <: c.cache + c".cache = c.cache - addrs -> Data } } // This command should not find any counterexample LoadNotObservable: check { - all c, c', c": CacheSystem, a1, a2: Addr, d1, d2, d3: Data | + all c, c", c"": CacheSystem, a1, a2: Addr, d1, d2, d3: Data | { read [c, a2, d2] - write [c, c', a1, d1] - load [c', c"] - read [c", a2, d3] + write [c, c", a1, d1] + load [c", c""] + read [c"", a2, d3] } implies d3 = (a1=a2 => d1 else d2) } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkCache.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkCache.als index 8214389ba..6d01eb0b9 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkCache.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkCache.als @@ -9,26 +9,26 @@ fun alpha [c: CacheSystem]: Memory { // This check should not produce a counterexample ReadOK: check { - // introduction of m, m' ensures that they exist, and gives witnesses if counterexample + // introduction of m, m" ensures that they exist, and gives witnesses if counterexample all c: CacheSystem, a: Addr, d: Data, m: Memory | cache/read [c, a, d] and m = alpha [c] => amemory/read [m, a, d] } // This check should not produce a counterexample WriteOK: check { - all c, c': CacheSystem, a: Addr, d: Data, m, m': Memory | - cache/write [c, c', a, d] and m = alpha [c] and m' = alpha [c'] - => amemory/write [m, m', a, d] + all c, c": CacheSystem, a: Addr, d: Data, m, m": Memory | + cache/write [c, c", a, d] and m = alpha [c] and m" = alpha [c"] + => amemory/write [m, m", a, d] } // This check should not produce a counterexample LoadOK: check { - all c, c': CacheSystem, m, m': Memory | - cache/load [c, c'] and m = alpha [c] and m' = alpha [c'] => m = m' + all c, c": CacheSystem, m, m": Memory | + cache/load [c, c"] and m = alpha [c] and m" = alpha [c"] => m = m" } // This check should not produce a counterexample FlushOK: check { - all c, c': CacheSystem, m, m': Memory | - cache/flush [c, c'] and m = alpha [c] and m' = alpha [c'] => m = m' + all c, c": CacheSystem, m, m": Memory | + cache/flush [c, c"] and m = alpha [c] and m" = alpha [c"] => m = m" } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkFixedSize.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkFixedSize.als index 20d291d16..a21216bda 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkFixedSize.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/checkFixedSize.als @@ -22,7 +22,7 @@ readOk: check { // This check should not find a counterexample writeOk: check { - all fm, fm': fmemory/Memory_H, a: Addr, d: Data, am, am': amemory/Memory | - fmemory/write [fm, fm', a, d] and alpha [fm, am] and alpha [fm', am'] - implies amemory/write [am, am', a, d] + all fm, fm": fmemory/Memory_H, a: Addr, d: Data, am, am": amemory/Memory | + fmemory/write [fm, fm", a, d] and alpha [fm, am] and alpha [fm", am"] + implies amemory/write [am, am", a, d] } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory.als index df6ab2a93..bc93da3b0 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory.als @@ -8,8 +8,8 @@ pred init [m: Memory] { // This predicate is empty in order to allow non-deterministic initialization } -pred write [m, m': Memory, a: Addr, d: Data] { - m'.data = m.data ++ a -> d +pred write [m, m": Memory, a: Addr, d: Data] { + m".data = m.data ++ a -> d } pred read [m: Memory, a: Addr, d: Data] { @@ -17,5 +17,5 @@ pred read [m: Memory, a: Addr, d: Data] { } fact Canonicalize { - no disj m, m': Memory | m.data = m'.data + no disj m, m": Memory | m.data = m".data } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory_H.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory_H.als index 157859918..231f84f0a 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory_H.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/memory/fixedSizeMemory_H.als @@ -15,7 +15,7 @@ pred read [m: Memory_H, a: Addr, d: Data] { memory/read [m, a, d] } -pred write [m, m': Memory_H, a: Addr, d: Data] { - memory/write [m, m', a, d] - m'.unwritten = m.unwritten - a +pred write [m, m": Memory_H, a: Addr, d: Data] { + memory/write [m, m", a, d] + m".unwritten = m.unwritten - a } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection1.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection1.als index 043b6a072..6b8c07570 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection1.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection1.als @@ -19,11 +19,11 @@ pred init [t: Time] { all p: Process | p.toSend.t = p } -pred step [t, t': Time, p: Process] { +pred step" [t, t": Time, p: Process] { let from = p.toSend, to = p.succ.toSend | some id: from.t { - from.t' = from.t - id - to.t' = to.t + (id - p.succ.prevs) + from.t" = from.t - id + to.t" = to.t + (id - p.succ.prevs) } } @@ -35,13 +35,13 @@ fact defineElected { fact traces { init [first] all t: Time-last | - let t' = t.next | + let t" = t.next | all p: Process | - step [t, t', p] or step [t, t', succ.p] or skip [t, t', p] + step" [t, t", p] or step" [t, t", succ.p] or skip [t, t", p] } -pred skip [t, t': Time, p: Process] { - p.toSend.t = p.toSend.t' +pred skip [t, t": Time, p: Process] { + p.toSend.t = p.toSend.t" } pred show { some elected } diff --git a/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection2.als b/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection2.als index 16bee928c..00c667a33 100644 --- a/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection2.als +++ b/org.alloytools.alloy.extra/extra/models/book/chapter6/ringElection2.als @@ -19,11 +19,11 @@ pred init [t: Time] { all p: Process | p.toSend.t = p } -pred step [t, t': Time, p: Process] { +pred step" [t, t": Time, p: Process] { let from = p.toSend, to = p.succ.toSend | some id: from.t { - from.t' = from.t - id - to.t' = to.t + (id - p.succ.prevs) + from.t" = from.t - id + to.t" = to.t + (id - p.succ.prevs) } } @@ -35,13 +35,13 @@ fact defineElected { fact traces { init [first] all t: Time-last | - let t' = t.next | + let t" = t.next | all p: Process | - step [t, t', p] or step [t, t', succ.p] or skip [t, t', p] + step" [t, t", p] or step" [t, t", succ.p] or skip [t, t", p] } -pred skip [t, t': Time, p: Process] { - p.toSend.t = p.toSend.t' +pred skip [t, t": Time, p: Process] { + p.toSend.t = p.toSend.t" } pred show { some elected } @@ -54,15 +54,15 @@ check AtMostOneElected for 3 Process, 7 Time pred progress { all t: Time - TO/last | - let t' = TO/next [t] | - some Process.toSend.t => some p: Process | not skip [t, t', p] + let t" = TO/next [t] | + some Process.toSend.t => some p: Process | not skip [t, t", p] } assert AtLeastOneElected { progress => some elected.Time } check AtLeastOneElected for 3 Process, 7 Time // This should not find any counterexample -pred looplessPath { no disj t, t': Time | toSend.t = toSend.t' } +pred looplessPath { no disj t, t": Time | toSend.t = toSend.t" } // This produces an instance run looplessPath for 3 Process, 12 Time diff --git a/org.alloytools.alloy.extra/extra/models/examples/algorithms/dijkstra.als b/org.alloytools.alloy.extra/extra/models/examples/algorithms/dijkstra.als index 01f82c8c9..b6c129852 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/algorithms/dijkstra.als +++ b/org.alloytools.alloy.extra/extra/models/examples/algorithms/dijkstra.als @@ -34,50 +34,50 @@ pred IsFree [s: State, m: Mutex] { pred IsStalled [s: State, p: Process] { some p.(s.waits) } -pred GrabMutex [s: State, p: Process, m: Mutex, s': State] { +pred GrabMutex [s: State, p: Process, m: Mutex, s": State] { // a process can only act if it is not // waiting for a mutex !s.IsStalled[p] // can only grab a mutex we do not yet hold m !in p.(s.holds) // mutexes are grabbed in order - all m': p.(s.holds) | mo/lt[m',m] + all m": p.(s.holds) | mo/lt[m",m] s.IsFree[m] => { // if the mutex is free, we now hold it, // and do not become stalled - p.(s'.holds) = p.(s.holds) + m - no p.(s'.waits) + p.(s".holds) = p.(s.holds) + m + no p.(s".waits) } else { // if the mutex was not free, // we still hold the same mutexes we held, // and are now waiting on the mutex // that we tried to grab. - p.(s'.holds) = p.(s.holds) - p.(s'.waits) = m + p.(s".holds) = p.(s.holds) + p.(s".waits) = m } all otherProc: Process - p | { - otherProc.(s'.holds) = otherProc.(s.holds) - otherProc.(s'.waits) = otherProc.(s.waits) + otherProc.(s".holds) = otherProc.(s.holds) + otherProc.(s".waits) = otherProc.(s.waits) } } -pred ReleaseMutex [s: State, p: Process, m: Mutex, s': State] { +pred ReleaseMutex [s: State, p: Process, m: Mutex, s": State] { !s.IsStalled[p] m in p.(s.holds) - p.(s'.holds) = p.(s.holds) - m - no p.(s'.waits) + p.(s".holds) = p.(s.holds) - m + no p.(s".waits) no m.~(s.waits) => { - no m.~(s'.holds) - no m.~(s'.waits) + no m.~(s".holds) + no m.~(s".waits) } else { some lucky: m.~(s.waits) | { - m.~(s'.waits) = m.~(s.waits) - lucky - m.~(s'.holds) = lucky + m.~(s".waits) = m.~(s.waits) - lucky + m.~(s".holds) = lucky } } all mu: Mutex - m { - mu.~(s'.waits) = mu.~(s.waits) - mu.~(s'.holds)= mu.~(s.holds) + mu.~(s".waits) = mu.~(s.waits) + mu.~(s".holds)= mu.~(s.holds) } } diff --git a/org.alloytools.alloy.extra/extra/models/examples/algorithms/opt_spantree.als b/org.alloytools.alloy.extra/extra/models/examples/algorithms/opt_spantree.als index 2217df1ad..e7e44ceb3 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/algorithms/opt_spantree.als +++ b/org.alloytools.alloy.extra/extra/models/examples/algorithms/opt_spantree.als @@ -126,14 +126,14 @@ fact TransIfPossible { fact LegalTrans { Init all s : State - so/last | - let s' = so/next[s] | { + let s" = so/next[s] | { all p : Process | - p in s.runs => Trans[p, s, s'] else TRNop[p,s,s'] + p in s.runs => Trans[p, s, s"] else TRNop[p,s,s"] } } -pred PossTrans[s, s' : State] { - all p : Process | Trans[p,s,s'] +pred PossTrans[s, s" : State] { + all p : Process | Trans[p,s,s"] } pred SpanTreeAtState[s : State] { @@ -155,23 +155,23 @@ pred SuccessfulRun { // show a trace without a loop pred TraceWithoutLoop { - all s, s' : State | s!=s' => { - !EquivStates[s, s'] - (s' in so/nexts[s] && (s' != so/next[s])) => !PossTrans[s,s'] + all s, s" : State | s!=s" => { + !EquivStates[s, s"] + (s" in so/nexts[s] && (s" != so/next[s])) => !PossTrans[s,s"] } all s: State | !SpanTreeAtState[s] } // defines equivalent states -pred EquivStates[s, s' : State] { - s.lvl = s'.lvl - s.parent = s'.parent +pred EquivStates[s, s" : State] { + s.lvl = s".lvl + s.parent = s".parent } // show a trace that violates liveness pred BadLivenessTrace { // two different states equivalent (loop) - some s, s' : State | s!=s' && EquivStates[s, s'] + some s, s" : State | s!=s" && EquivStates[s, s"] all s : State | !SpanTreeAtState[s] } diff --git a/org.alloytools.alloy.extra/extra/models/examples/algorithms/s_ringlead.als b/org.alloytools.alloy.extra/extra/models/examples/algorithms/s_ringlead.als index 8f96b477d..a9650a25c 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/algorithms/s_ringlead.als +++ b/org.alloytools.alloy.extra/extra/models/examples/algorithms/s_ringlead.als @@ -46,54 +46,54 @@ fact CleanupLast { no ls.runs } -pred ValidTrans2[s, s': State] { - all p : s.runs | VT2Helper[p,s,s'] - all p : Process - s.runs | NOP2[p,s,s'] - NoMagicMsg[s,s'] +pred ValidTrans2[s, s": State] { + all p : s.runs | VT2Helper[p,s,s"] + all p : Process - s.runs | NOP2[p,s,s"] + NoMagicMsg[s,s"] } -pred NoMagicMsg[s, s' : State] { +pred NoMagicMsg[s, s" : State] { // no magically appearing messages - all p : Process, m : s'.buffer[p] | - m in s.buffer[p] || (!NOP2[p,s,s'] && + all p : Process, m : s".buffer[p] | + m in s.buffer[p] || (!NOP2[p,s,s"] && ((s = so/first && m = p) || (s != so/first && m in s.buffer[p.~rightNeighbor] - && m !in s'.buffer[p.~rightNeighbor] && po/gt[m,p]))) + && m !in s".buffer[p.~rightNeighbor] && po/gt[m,p]))) } -pred PossTrans[s, s' : State] { - all p : Process | VT2Helper[p,s,s'] || NOP2[p,s,s'] - NoMagicMsg[s,s'] +pred PossTrans[s, s" : State] { + all p : Process | VT2Helper[p,s,s"] || NOP2[p,s,s"] + NoMagicMsg[s,s"] } -pred VT2Helper[p : Process, s, s' : State] { +pred VT2Helper[p : Process, s, s" : State] { ( let readable=s.buffer[p.~rightNeighbor] | (s = so/first) => { - p = s'.buffer[p] - readable in s'.buffer[p.~rightNeighbor] - p !in s'.leader + p = s".buffer[p] + readable in s".buffer[p.~rightNeighbor] + p !in s".leader } else { (some readable) => { some m : set readable | { - m !in s'.buffer[p.~rightNeighbor] + m !in s".buffer[p.~rightNeighbor] // nothing else gets deleted - readable - m in s'.buffer[p.~rightNeighbor] - { m': m | po/gt[m',p] } /*m & nexts(p)*/ in s'.buffer[p] - p in s'.leader iff (p in s.leader || p in m) + readable - m in s".buffer[p.~rightNeighbor] + { m": m | po/gt[m",p] } /*m & nexts(p)*/ in s".buffer[p] + p in s".leader iff (p in s.leader || p in m) } - } else NOP2[p,s,s'] + } else NOP2[p,s,s"] } ) } -pred NOP2[p : Process, s,s': State] { - p in s'.leader iff p in s.leader +pred NOP2[p : Process, s,s": State] { + p in s".leader iff p in s.leader // no reads - s.buffer[p.~rightNeighbor] in s'.buffer[p.~rightNeighbor] + s.buffer[p.~rightNeighbor] in s".buffer[p.~rightNeighbor] // no sends - s'.buffer[p] in s.buffer[p] + s".buffer[p] in s.buffer[p] } pred Preconds[p : Process, s : State] { @@ -108,13 +108,13 @@ fact TransIfPossible { fact LegalTrans { all s : State - so/last | - let s' = so/next[s] | - ValidTrans2[s,s'] + let s" = so/next[s] | + ValidTrans2[s,s"] } -pred EquivStates[s, s': State] { - s.buffer = s'.buffer - s.leader = s'.leader +pred EquivStates[s, s": State] { + s.buffer = s".buffer + s.leader = s".leader } assert Safety { @@ -136,7 +136,7 @@ pred BadLivenessTrace { pred TraceWithoutLoop { all t1, t2 : State | t1!=t2 => !EquivStates[t1,t2] - all s, s' : State | (s' in (so/nexts[s] - so/next[s])) => !PossTrans[s,s'] + all s, s" : State | (s" in (so/nexts[s] - so/next[s])) => !PossTrans[s,s"] all s : State | !Legit[s] } diff --git a/org.alloytools.alloy.extra/extra/models/examples/algorithms/stable_ringlead.als b/org.alloytools.alloy.extra/extra/models/examples/algorithms/stable_ringlead.als index 577257f86..afba272c0 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/algorithms/stable_ringlead.als +++ b/org.alloytools.alloy.extra/extra/models/examples/algorithms/stable_ringlead.als @@ -102,9 +102,9 @@ pred TransHelper[p : Process, tp, tn : State] { } -pred StateTrans[s, s' : State] { +pred StateTrans[s, s" : State] { all p : Process | - TransHelper[p, s, s'] || ValAtState[p,s] = ValAtState[p,s'] + TransHelper[p, s, s"] || ValAtState[p,s] = ValAtState[p,s"] } @@ -131,14 +131,14 @@ pred BadLivenessHelper { pred CTraceWithoutLoop { OneAtATimeTrans - all t, t' : State | t!=t' => t.val != t'.val + all t, t" : State | t!=t" => t.val != t".val } pred DTraceWithoutLoop { DDaemonTrans - all t, t' : State | t!=t' => { - t.val != t'.val - (t' in so/nexts[t] && t' != so/next[t]) => !StateTrans[t,t'] + all t, t" : State | t!=t" => { + t.val != t".val + (t" in so/nexts[t] && t" != so/next[t]) => !StateTrans[t,t"] } all t : State | !Legit[t] } @@ -151,9 +151,9 @@ pred ConvergingRun { pred OnlyFairLoops { OneAtATimeTrans - all s, s' : State | - (s' in so/nexts[s] && s'.val = s.val) => - (let loopStates = (so/nexts[s] & so/prevs[s']) + s + s' | Process in loopStates.running) + all s, s" : State | + (s" in so/nexts[s] && s".val = s.val) => + (let loopStates = (so/nexts[s] & so/prevs[s"]) + s + s" | Process in loopStates.running) } assert CMustConverge { @@ -166,9 +166,9 @@ pred Legit [s : State] { int XAtState[p,s] < # Val int YAtState[p,s] < # Val } - all p, p' : Process | { - int XAtState[p,s] = int XAtState[p',s] - int YAtState[p,s] = int YAtState[p',s] + all p, p" : Process | { + int XAtState[p,s] = int XAtState[p",s] + int YAtState[p,s] = int YAtState[p",s] } } diff --git a/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord.als b/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord.als index 5769d0a03..c2de1296e 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord.als +++ b/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord.als @@ -17,10 +17,10 @@ fact {all i: Id | Id in i.*next} * true iff i precedes j in the order starting at from */ pred less_than [from, i,j: Id] { - let next' = Id<:next - (Id->from) | j in i.^next' // if from=j, returns true if # nodes > 1 + let next" = Id<:next - (Id->from) | j in i.^next" // if from=j, returns true if # nodes > 1 } pred less_than_eq [from, i,j: Id] { - let next' = Id<:next - (Id->from) | j in i.*next' + let next" = Id<:next - (Id->from) | j in i.*next" } sig Node {id: Id} @@ -50,7 +50,7 @@ fact {all s: State | all n: s.active | n.(s.data).next = n.(s.data).finger[n.id. pred NextCorrect [s: State] { all n: s.active { -- no intervening node (ie, close enough) - no n': s.active - n | less_than [n.id, n'.id, n.(s.data).next.id] + no n": s.active - n | less_than [n.id, n".id, n.(s.data).next.id] -- can reach all other active nodes (ie, far enough) -- need this because can't rule out case of next being node itself (because of 1-node ring) -- s.active in n.*(s.data.next) @@ -58,20 +58,20 @@ pred NextCorrect [s: State] { } } -pred NextCorrect' [s: State] { +pred NextCorrect" [s: State] { -- next seems to be correct for 1,2,3 nodes all n: s.active | let nd = (s.data)[n] { - let next' = Id<:next - (Id -> nd.next.id) { - no n' : s.active { n'.id in n.id.^next' } + let next" = Id<:next - (Id -> nd.next.id) { + no n" : s.active { n".id in n.id.^next" } }} } // valid -assert Same1 {all s: State | NextCorrect[s] => NextCorrect'[s]} +assert Same1 {all s: State | NextCorrect[s] => NextCorrect"[s]} check Same1 for 3 but 1 State expect 0 // valid unless active condition removed -assert Same2 {all s: State | s.active = Node => (NextCorrect'[s] => NextCorrect[s])} +assert Same2 {all s: State | s.active = Node => (NextCorrect"[s] => NextCorrect[s])} check Same2 for 3 but 1 State expect 0 -- assert NextInFinger {all s: State | all n: s.active | some n.s.data.finger[n.id.next] } @@ -82,23 +82,23 @@ check Same2 for 3 but 1 State expect 0 pred FingersCorrect [s: State] { all nd: s.active.(s.data) | all start:nd.finger.univ | nd.finger[start] in s.active && - (no n' : s.active | less_than [start, n'.id, nd.finger[start].id]) + (no n" : s.active | less_than [start, n".id, nd.finger[start].id]) } -pred FingersCorrect' [s: State] { +pred FingersCorrect" [s: State] { all n: s.active | let nd = (s.data)[n] | all start: Node.~(nd.finger) { nd.finger[start] in s.active && - (let next' = Id<:next - (nd.finger[start].id -> Id) { - no n' : s.active - nd.finger[start] { - n'.id in start.*next' + (let next" = Id<:next - (nd.finger[start].id -> Id) { + no n" : s.active - nd.finger[start] { + n".id in start.*next" } }) } } -assert SameFC {all s: State | FingersCorrect [s] iff FingersCorrect'[s]} +assert SameFC {all s: State | FingersCorrect [s] iff FingersCorrect"[s]} check SameFC for 3 but 1 State expect 0 @@ -111,7 +111,7 @@ run ShowMeFC for 2 but 1 State expect 1 pred ClosestPrecedingFinger[s: State] { all n: s.active | let nd = n.(s.data) | all i: Id | let cpf = nd.closest_preceding_finger[i] { - no n': nd.finger[Id] + n - cpf | less_than [cpf.id, n'.id, i] + no n": nd.finger[Id] + n - cpf | less_than [cpf.id, n".id, i] cpf in nd.finger[Id] + n cpf.id != i || # s.active = 1 //less_than (n.id, cpf.id, i) @@ -119,26 +119,26 @@ pred ClosestPrecedingFinger[s: State] { } -pred ClosestPrecedingFinger'[s: State] { +pred ClosestPrecedingFinger"[s: State] { all n: s.active | let nd = (s.data)[n] | all i: Id { - let next' = Id<:next - (Id -> i) { - nd.next.id in n.id.^next' => + let next" = Id<:next - (Id -> i) { + nd.next.id in n.id.^next" => // nd.closest_preceding_finger[i] = nd.next, (some n1: nd.finger[Id] { nd.closest_preceding_finger[i] = n1 //n1 in nd.finger[Id] - n1.id in n.id.^next' - no n2: nd.finger[Id] | n2.id in n1.id.^next' + n1.id in n.id.^next" + no n2: nd.finger[Id] | n2.id in n1.id.^next" }) else nd.closest_preceding_finger[i] = n }} } -assert SameCPF {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] iff ClosestPrecedingFinger' [s])} -assert SameCPF1 {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] => ClosestPrecedingFinger' [s])} +assert SameCPF {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] iff ClosestPrecedingFinger" [s])} +assert SameCPF1 {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] => ClosestPrecedingFinger" [s])} assert SameCPF2 { - all s: State | ((s.active = Node && FingersCorrect[s] && ClosestPrecedingFinger' [s]) + all s: State | ((s.active = Node && FingersCorrect[s] && ClosestPrecedingFinger" [s]) => ClosestPrecedingFinger [s]) } check SameCPF for 3 but 1 State expect 0 @@ -148,7 +148,7 @@ check SameCPF2 for 3 but 1 State expect 0 pred ShowMeCPF { all s : State | s.active = Node && FingersCorrect[s] && - // not ClosestPrecedingFinger(s) && ClosestPrecedingFinger'(s) + // not ClosestPrecedingFinger(s) && ClosestPrecedingFinger"(s) ClosestPrecedingFinger[s] //all s : State | all nd : s.active.s.data | nd.finger[Id] = Node # Node = 2 @@ -175,10 +175,10 @@ assert FPisActive { check FPisActive for 3 but 1 State expect 1 -pred FindPredecessor'[s: State] { +pred FindPredecessor"[s: State] { all n: s.active | let nd = (s.data)[n] | all i: Id { - let next' = Id<:next - (nd.next.id -> Id) { - one s.active or i in n.id.^next' => // *next' -> ^next' 1/8/02 + let next" = Id<:next - (nd.next.id -> Id) { + one s.active or i in n.id.^next" => // *next" -> ^next" 1/8/02 nd.find_predecessor[i] = n else nd.find_predecessor[i] = ((s.data)[nd.closest_preceding_finger[i]]).find_predecessor[i] @@ -187,14 +187,14 @@ pred FindPredecessor'[s: State] { assert SameFP {all s: State | FingersCorrect[s] // && s.active = Node - => (FindPredecessor [s] iff FindPredecessor' [s])} + => (FindPredecessor [s] iff FindPredecessor" [s])} assert SameFP1 { all s: State | FingersCorrect[s] && s.active = Node - => (FindPredecessor [s] => FindPredecessor' [s])} + => (FindPredecessor [s] => FindPredecessor" [s])} assert SameFP2 { all s: State | FingersCorrect[s] && s.active = Node - => (FindPredecessor' [s] => FindPredecessor [s])} + => (FindPredecessor" [s] => FindPredecessor [s])} check SameFP for 3 but 1 State expect 1 check SameFP1 for 3 but 1 State expect 0 @@ -256,6 +256,6 @@ assert FindSuccessorWorks { let nd = s.active.(s.data) | let succ = nd.find_successor [i] | FingersCorrect [s] // && s.active = Node - => (no n': s.active | less_than [i, n'.id, succ.id]) + => (no n": s.active | less_than [i, n".id, succ.id]) } check FindSuccessorWorks for 3 but 1 State expect 1 diff --git a/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord2.als b/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord2.als index ea7c3429d..078688bfb 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord2.als +++ b/org.alloytools.alloy.extra/extra/models/examples/case_studies/chord2.als @@ -16,10 +16,10 @@ fact {all i: Id | Id in i.*next} * true iff i precedes j in the order starting at from */ pred less_than [from, i,j: Id] { - let next' = Id<:next - (Id->from) | j in i.^next' // if from=j, returns true if # nodes > 1 + let next" = Id<:next - (Id->from) | j in i.^next" // if from=j, returns true if # nodes > 1 } pred less_than_eq [from, i,j: Id] { - let next' = Id<:next - (Id->from) | j in i.*next' + let next" = Id<:next - (Id->from) | j in i.*next" } sig Node {id: Id} @@ -48,7 +48,7 @@ fact {all s: State | all n: s.active | n.(s.data).next = n.(s.data).finger[n.id. pred NextCorrect [s: State] { all n: s.active { -- no intervening node (ie, close enough) - no n': s.active - n | less_than [n.id, n'.id, n.(s.data).next.id] + no n": s.active - n | less_than [n.id, n".id, n.(s.data).next.id] -- can reach all other active nodes (ie, far enough) -- need this because can't rule out case of next being node itself (because of 1-node ring) -- s.active in n.*(s.data.next) @@ -58,7 +58,7 @@ pred NextCorrect [s: State] { /* -- abortive attempt at simplifying next condition -fun NextCorrect" (s: State) { +fun NextCorrect"" (s: State) { all n: s.active | let nx = s.data.next { s.active in n.*nx less_than (n.id, n.id, n.nx.id) @@ -66,17 +66,17 @@ fun NextCorrect" (s: State) { } */ -pred NextCorrect' [s: State] { +pred NextCorrect" [s: State] { -- next seems to be correct for 1,2,3 nodes all n: s.active | let nd = (s.data)[n] { - let next' = Id<:next - (Id -> nd.next.id) { - no n' : s.active { n'.id in n.id.^next' } + let next" = Id<:next - (Id -> nd.next.id) { + no n" : s.active { n".id in n.id.^next" } }} } -assert Same1 {all s: State | NextCorrect[s] => NextCorrect'[s]} +assert Same1 {all s: State | NextCorrect[s] => NextCorrect"[s]} //check Same1 for 3 but 1 State -- valid -assert Same2 {all s: State | s.active = Node => (NextCorrect'[s] => NextCorrect[s])} +assert Same2 {all s: State | s.active = Node => (NextCorrect"[s] => NextCorrect[s])} //check Same2 for 3 but 1 State -- invalid if active condition removed -- assert NextInFinger {all s: State | all n: s.active | some n.s.data.finger[n.id.next] } @@ -88,19 +88,19 @@ assert Same2 {all s: State | s.active = Node => (NextCorrect'[s] => NextCorrect[ pred FingersCorrect [s: State] { all nd: s.active.(s.data) | all start:nd.finger.univ | nd.finger[start] in s.active && - (no n' : s.active | less_than [start, n'.id, nd.finger[start].id]) + (no n" : s.active | less_than [start, n".id, nd.finger[start].id]) } -pred FingersCorrect' [s: State] { +pred FingersCorrect" [s: State] { all n: s.active | let nd = (s.data)[n] | all start: Node.~(nd.finger) { nd.finger[start] in s.active && - (let next' = Id<:next - (nd.finger[start].id -> Id) { - no n' : s.active - nd.finger[start] { - n'.id in start.*next' + (let next" = Id<:next - (nd.finger[start].id -> Id) { + no n" : s.active - nd.finger[start] { + n".id in start.*next" }})} } -assert SameFC {all s: State | FingersCorrect [s] iff FingersCorrect'[s]} +assert SameFC {all s: State | FingersCorrect [s] iff FingersCorrect"[s]} //check SameFC for 3 but 1 State pred ShowMeFC { @@ -113,7 +113,7 @@ pred ShowMeFC { fun ClosestPrecedingFinger(s: State) { all n: s.active | let nd = n.s.data | all i: Id | let cpf = nd.closest_preceding_finger[i] { - no n': nd.finger[Id] | less_than (cpf.id, n'.id, i) + no n": nd.finger[Id] | less_than (cpf.id, n".id, i) cpf in nd.finger[Id] + n less_than (n.id, cpf.id, i) } @@ -123,7 +123,7 @@ fun ClosestPrecedingFinger(s: State) { pred ClosestPrecedingFinger_SAVE [s: State] { all n: s.active | let nd = n.(s.data) | all i: Id | let cpf = nd.closest_preceding_finger[i] { - no n': (nd.finger[Id] + n) - cpf | less_than [cpf.id, n'.id, i] + no n": (nd.finger[Id] + n) - cpf | less_than [cpf.id, n".id, i] cpf in nd.finger[Id] + n cpf.id != i || # s.active = 1 //less_than (n.id, cpf.id, i) @@ -131,7 +131,7 @@ pred ClosestPrecedingFinger_SAVE [s: State] { } pred CPFBody [s: State, n: Node, nd: NodeData, i: Id, cpf: Node] { - no n': (nd.finger[Id] + n) - cpf | less_than [cpf.id, n'.id, i] + no n": (nd.finger[Id] + n) - cpf | less_than [cpf.id, n".id, i] cpf in nd.finger[Id] + n cpf.id != i || # s.active = 1 } @@ -141,25 +141,25 @@ pred ClosestPrecedingFinger[s: State] { some cpf: Node | CPFBody [s,n,nd,i,cpf] => CPFBody [s,n,nd,i,nd.closest_preceding_finger[i]] } -pred ClosestPrecedingFinger'[s: State] { +pred ClosestPrecedingFinger"[s: State] { all n: s.active | let nd = (s.data)[n] | all i: Id { - let next' = Id<:next - (Id -> i) { - nd.next.id in n.id.^next' => + let next" = Id<:next - (Id -> i) { + nd.next.id in n.id.^next" => // nd.closest_preceding_finger[i] = nd.next, (some n1: nd.finger[Id] { nd.closest_preceding_finger[i] = n1 //n1 in nd.finger[Id] - n1.id in n.id.^next' - no n2: nd.finger[Id] | n2.id in n1.id.^next' + n1.id in n.id.^next" + no n2: nd.finger[Id] | n2.id in n1.id.^next" }) else nd.closest_preceding_finger[i] = n }} } -assert SameCPF {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] iff ClosestPrecedingFinger' [s])} -assert SameCPF1 {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] => ClosestPrecedingFinger' [s])} +assert SameCPF {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] iff ClosestPrecedingFinger" [s])} +assert SameCPF1 {all s: State | FingersCorrect[s] => (ClosestPrecedingFinger [s] => ClosestPrecedingFinger" [s])} assert SameCPF2 { - all s: State | ((s.active = Node && FingersCorrect[s] && ClosestPrecedingFinger' [s]) + all s: State | ((s.active = Node && FingersCorrect[s] && ClosestPrecedingFinger" [s]) => ClosestPrecedingFinger [s]) } //check SameCPF for 3 but 1 State //check SameCPF1 for 2 but 1 State @@ -167,7 +167,7 @@ assert SameCPF2 { pred ShowMeCPF { all s : State | s.active = Node && FingersCorrect[s] && - // not ClosestPrecedingFinger(s) && ClosestPrecedingFinger'(s) + // not ClosestPrecedingFinger(s) && ClosestPrecedingFinger"(s) ClosestPrecedingFinger[s] //all s : State | all nd : s.active.s.data | nd.finger[Id] = Node # Node = 2 @@ -193,10 +193,10 @@ assert FPisActive { //check FPisActive for 3 but 1 State -pred FindPredecessor'[s: State] { +pred FindPredecessor"[s: State] { all n: s.active | let nd = (s.data)[n] | all i: Id { - let next' = Id<:next - (nd.next.id -> Id) { - one s.active or i in n.id.^next' => + let next" = Id<:next - (nd.next.id -> Id) { + one s.active or i in n.id.^next" => nd.find_predecessor[i] = n else nd.find_predecessor[i] = ((s.data)[nd.closest_preceding_finger[i]]).find_predecessor[i] @@ -204,13 +204,13 @@ pred FindPredecessor'[s: State] { } assert SameFP {all s: State | FingersCorrect[s] && s.active = Node - => (FindPredecessor [s] iff FindPredecessor' [s])} + => (FindPredecessor [s] iff FindPredecessor" [s])} assert SameFP1 { all s: State | FingersCorrect[s] && s.active = Node - => (FindPredecessor [s] => FindPredecessor' [s])} + => (FindPredecessor [s] => FindPredecessor" [s])} assert SameFP2 { all s: State | FingersCorrect[s] && s.active = Node - => (FindPredecessor' [s] => FindPredecessor [s])} + => (FindPredecessor" [s] => FindPredecessor [s])} //check SameFP for 3 but 1 State //check SameFP1 for 3 but 1 State //check SameFP2 for 3 but 1 State @@ -266,7 +266,7 @@ assert FindSuccessorWorks { let succ = nd.find_successor [i] | FingersCorrect [s] => { - no n': s.active | less_than [i, n'.id, succ.id] + no n": s.active | less_than [i, n".id, succ.id] succ in s.active } } diff --git a/org.alloytools.alloy.extra/extra/models/examples/case_studies/chordbugmodel.als b/org.alloytools.alloy.extra/extra/models/examples/case_studies/chordbugmodel.als index de6c36bbb..586338339 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/case_studies/chordbugmodel.als +++ b/org.alloytools.alloy.extra/extra/models/examples/case_studies/chordbugmodel.als @@ -11,11 +11,11 @@ sig Id {next: Id} fact {all i: Id | Id in i.*next} pred less_than [from, i,j: Id] { - let next' = Id<:next - (Id->from) | j in i.^next' + let next" = Id<:next - (Id->from) | j in i.^next" } pred less_than_eq [from, i,j: Id] { - let next' = Id<:next - (Id->from) | j in i.*next' + let next" = Id<:next - (Id->from) | j in i.*next" } sig Node {id: Id} @@ -40,7 +40,7 @@ fact { pred NextCorrect [s: State] { all n: s.active | let succ = n.(s.data).next { - no n': s.active - n | less_than [n.id, n'.id, succ.id] + no n": s.active - n | less_than [n.id, n".id, succ.id] succ != n || #s.active = 1 succ in s.active } @@ -49,13 +49,13 @@ pred NextCorrect [s: State] { pred FingersCorrect [s: State] { all nd: s.active.(s.data) | all start: (nd.finger).Node | nd.finger[start] in s.active && - (no n' : s.active | less_than [start, n'.id, nd.finger[start].id]) + (no n" : s.active | less_than [start, n".id, nd.finger[start].id]) } pred save_ClosestPrecedingFinger [s: State] { all n: s.active | let nd = n.(s.data) | all i: Id | let cpf = nd.closest_preceding_finger[i] { - no n': (nd.finger[Id] + n) - cpf | less_than [cpf.id, n'.id, i] + no n": (nd.finger[Id] + n) - cpf | less_than [cpf.id, n".id, i] cpf in nd.finger[Id] + n cpf.id != i || # s.active = 1 } @@ -98,7 +98,7 @@ pred FindSuccessorIsCorrect[s: State] { all i: Id | all n: s.active | let succ = (n.(s.data)).find_successor [i] { succ in s.active - no n': s.active | less_than [i, n'.id, succ.id] + no n": s.active | less_than [i, n".id, succ.id] } } @@ -158,7 +158,7 @@ Suppose we change \tt as follows: pred ClosestPrecedingFinger [s: State] { all n: s.active | let nd = n.(s.data) | all i: Id | let cpf = nd.closest_preceding_finger[i] { - no n': (nd.finger[Id] + n) - cpf | less_than [cpf.id, n'.id, i] + no n": (nd.finger[Id] + n) - cpf | less_than [cpf.id, n".id, i] cpf in nd.finger[Id] + n cpf.id != i } @@ -185,8 +185,8 @@ n.find_successor(id) if (id in (n, n.successor]) return n.successor; else - n' = closest_preceding_finger(id); - return n'.find_successor(id); + n" = closest_preceding_finger(id); + return n".find_successor(id); In the buggy scenario with a single node, the \tt loop always terminates at \cite{if-condition1}, leading to an diff --git a/org.alloytools.alloy.extra/extra/models/examples/case_studies/firewire.als b/org.alloytools.alloy.extra/extra/models/examples/case_studies/firewire.als index 5de1afafa..2ed1c6ab7 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/case_studies/firewire.als +++ b/org.alloytools.alloy.extra/extra/models/examples/case_studies/firewire.als @@ -100,7 +100,7 @@ module examples/case_studies/firewire * skolemized away by the analyzer. * * The {\em functions} of the model are parameterized formulas. The function {\em - * Trans} relates a pre-state {\tt s} to a post-state {\tt s'}. It has a case for + * Trans} relates a pre-state {\tt s} to a post-state {\tt s"}. It has a case for * each operation. Look at the clause for the operation {\em WriteReqOrAck}, for * example. If this operation is deemed to have occurred, each of the constraints * in the curly braces must hold. The first says that the labelling of links as @@ -118,8 +118,8 @@ module examples/case_studies/firewire * new queue in the post-state (given the local name {\tt q}) contains the message * {\tt m} in its slot, and has no message in its overflow. Otherwise, some * message is placed arbitrarily in the overflow, and the slot is - * unconstrained. In {\em WriteReqOrAck}, the arguments {\tt s} and {\tt s'} are - * bound to the {\tt s} and {\tt s'} of {\em Trans}; {\tt x} is bound to one of + * unconstrained. In {\em WriteReqOrAck}, the arguments {\tt s} and {\tt s"} are + * bound to the {\tt s} and {\tt s"} of {\em Trans}; {\tt x} is bound to one of * the outgoing links from the set {\tt n.from}; and {\tt msg} is bound either to * the acknowledgment or request message. * @@ -208,99 +208,99 @@ sig State { waiting + active + contending + elected = Node } -pred SameState [s, s': State] { - s.waiting = s'.waiting - s.active = s'.active - s.contending = s'.contending - s.elected = s'.elected - s.parentLinks = s'.parentLinks - all x: Link | SameQueue [s.queue[x], s'.queue[x]] +pred SameState [s, s": State] { + s.waiting = s".waiting + s.active = s".active + s.contending = s".contending + s.elected = s".elected + s.parentLinks = s".parentLinks + all x: Link | SameQueue [s.queue[x], s".queue[x]] } -pred Trans [s, s': State] { - s'.op != Init - s'.op = Stutter => SameState [s, s'] - s'.op = AssignParent => { +pred Trans [s, s": State] { + s".op != Init + s".op = Stutter => SameState [s, s"] + s".op = AssignParent => { some x: Link { - x.target in s.waiting & s'.waiting - NoChangeExceptAt [s, s', x.target] + x.target in s.waiting & s".waiting + NoChangeExceptAt [s, s", x.target] ! IsEmptyQueue [s, x] - s'.parentLinks = s.parentLinks + x - ReadQueue [s, s', x] + s".parentLinks = s.parentLinks + x + ReadQueue [s, s", x] }} - s'.op = ReadReqOrAck => { - s'.parentLinks = s.parentLinks + s".op = ReadReqOrAck => { + s".parentLinks = s.parentLinks some x: Link { - x.target in s.(active + contending) & (PeekQueue [s, x, Ack] => s'.contending else s'.active) - NoChangeExceptAt [s, s', x.target] + x.target in s.(active + contending) & (PeekQueue [s, x, Ack] => s".contending else s".active) + NoChangeExceptAt [s, s", x.target] ! IsEmptyQueue [s, x] - ReadQueue [s', s, x] + ReadQueue [s", s, x] }} - s'.op = Elect => { - s'.parentLinks = s.parentLinks + s".op = Elect => { + s".parentLinks = s.parentLinks some n: Node { - n in s.active & s'.elected - NoChangeExceptAt [s, s', n] + n in s.active & s".elected + NoChangeExceptAt [s, s", n] n.to in s.parentLinks - QueuesUnchanged [s, s', Link] + QueuesUnchanged [s, s", Link] }} - s'.op = WriteReqOrAck => { + s".op = WriteReqOrAck => { -- note how this requires access to child ptr - s'.parentLinks = s.parentLinks + s".parentLinks = s.parentLinks some n: Node { - n in s.waiting & s'.active + n in s.waiting & s".active lone n.to - s.parentLinks - NoChangeExceptAt [s, s', n] + NoChangeExceptAt [s, s", n] all x: n.from | let msg = (x.reverse in s.parentLinks => Ack else Req) | - WriteQueue [s, s', x, msg] - QueuesUnchanged [s, s', Link - n.from] + WriteQueue [s, s", x, msg] + QueuesUnchanged [s, s", Link - n.from] }} - s'.op = ResolveContention => { + s".op = ResolveContention => { some x: Link { let contenders = x.(source + target) { - contenders in s.contending & s'.active - NoChangeExceptAt [s, s', contenders] + contenders in s.contending & s".active + NoChangeExceptAt [s, s", contenders] } - s'.parentLinks = s.parentLinks + x + s".parentLinks = s.parentLinks + x } - QueuesUnchanged [s, s', Link] + QueuesUnchanged [s, s", Link] } } -pred NoChangeExceptAt [s, s': State, nodes: set Node] { +pred NoChangeExceptAt [s, s": State, nodes: set Node] { let ns = Node - nodes { - ns & s.waiting = ns & s'.waiting - ns & s.active = ns & s'.active - ns & s.contending = ns & s'.contending - ns & s.elected = ns & s'.elected + ns & s.waiting = ns & s".waiting + ns & s.active = ns & s".active + ns & s.contending = ns & s".contending + ns & s.elected = ns & s".elected }} sig Queue {slot: lone Msg, overflow: lone Msg} -pred SameQueue [q, q': Queue] { - q.slot = q'.slot && q.overflow = q'.overflow +pred SameQueue [q, q": Queue] { + q.slot = q".slot && q.overflow = q".overflow } -pred ReadQueue [s, s': State, x: Link] { --- let q = s'.queue[x] | no q.(slot + overflow) - no s'.queue[x].(slot + overflow) - all x': Link - x | s'.queue[x'] = s.queue[x'] +pred ReadQueue [s, s": State, x: Link] { +-- let q = s".queue[x] | no q.(slot + overflow) + no s".queue[x].(slot + overflow) + all x": Link - x | s".queue[x"] = s.queue[x"] } pred PeekQueue [s: State, x: Link, m: Msg] { m = s.queue[x].slot } -pred WriteQueue [s, s': State, x: Link, m: Msg] { - let q = s'.queue[x] | +pred WriteQueue [s, s": State, x: Link, m: Msg] { + let q = s".queue[x] | no s.queue[x].slot => ( q.slot = m && no q.overflow) else some q.overflow } -pred QueuesUnchanged [s, s': State, xs: set Link] { - all x: xs | s'.queue[x] = s.queue[x] +pred QueuesUnchanged [s, s": State, xs: set Link] { + all x: xs | s".queue[x] = s.queue[x] } pred IsEmptyQueue [s: State, x: Link] { @@ -317,7 +317,7 @@ pred Initialization [s: State] { pred Execution { Initialization [ord/first] - all s: State - ord/last | let s' = ord/next[s] | Trans [s, s'] + all s: State - ord/last | let s" = ord/next[s] | Trans [s, s"] } pred ElectionHappens { @@ -328,7 +328,7 @@ pred ElectionHappens { pred NoRepeats { Execution - no s, s': State | s!=s' && SameState [s, s'] + no s, s": State | s!=s" && SameState [s, s"] no s: State | s.op = Stutter } diff --git a/org.alloytools.alloy.extra/extra/models/examples/case_studies/ins.als b/org.alloytools.alloy.extra/extra/models/examples/case_studies/ins.als index e5596229f..74a9e9309 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/case_studies/ins.als +++ b/org.alloytools.alloy.extra/extra/models/examples/case_studies/ins.als @@ -110,6 +110,6 @@ pred RemoveWildCard[me: Query, q: Query] { } assert MissingAttributeAsWildcard { - all db : DB, q, q' : Query, found: set Record | - db.Lookup[q, found] && q.RemoveWildCard[q'] => db.Lookup[q', found] + all db : DB, q, q" : Query, found: set Record | + db.Lookup[q, found] && q.RemoveWildCard[q"] => db.Lookup[q", found] } diff --git a/org.alloytools.alloy.extra/extra/models/examples/systems/javatypes_soundness.als b/org.alloytools.alloy.extra/extra/models/examples/systems/javatypes_soundness.als index 6bf50ed7c..b2c57057b 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/systems/javatypes_soundness.als +++ b/org.alloytools.alloy.extra/extra/models/examples/systems/javatypes_soundness.als @@ -39,7 +39,7 @@ sig Slot {} abstract sig Statement {} sig Assignment extends Statement { - var: Variable, + var": Variable, expr: Expr } sig Setter extends Statement { @@ -81,19 +81,19 @@ sig State { pred RuntimeTypesOK [s: State] { all o: s.objects, f: o.type.fields | let v = s.holds [o.slot [f]] | HasType [v, f.declType] - all var: s.vars | - let v = s.holds [var] | HasType [v, var.declType] + all var": s.vars | + let v = s.holds [var"] | HasType [v, var".declType] } pred HasType [v: Value, t: Type] { v in Null or Subtype [v.type, t] } -pred Subtype [t, t': Type] { +pred Subtype [t, t": Type] { t in Class => (let supers = (t & Class).*(Class<:xtends) | - t' in (supers + supers.implements.*(Interface<:xtends))) - t in Interface => t' in (t & Interface).*(Interface<:xtends) + t" in (supers + supers.implements.*(Interface<:xtends))) + t in Interface => t" in (t & Interface).*(Interface<:xtends) } pred TypeChecksSetter [stmt: Setter] { @@ -102,24 +102,24 @@ pred TypeChecksSetter [stmt: Setter] { Subtype [stmt.rexpr.type, stmt.field.declType] } -pred ExecuteSetter [s, s': State, stmt: Setter] { +pred ExecuteSetter [s, s": State, stmt: Setter] { stmt.(rexpr+lexpr).subexprs & Variable in s.vars - s'.objects = s.objects and s'.vars = s.vars + s".objects = s.objects and s".vars = s.vars let rval = s.val [stmt.rexpr], lval = s.val [stmt.lexpr] { no lval & Null - s'.holds = s.holds ++ (lval.slot[stmt.field] -> rval) + s".holds = s.holds ++ (lval.slot[stmt.field] -> rval) } } assert TypeSoundness { - all s, s': State, stmt: Setter | + all s, s": State, stmt: Setter | {RuntimeTypesOK[s] - ExecuteSetter [s, s', stmt] + ExecuteSetter [s, s", stmt] TypeChecksSetter[stmt] - } => RuntimeTypesOK[s'] + } => RuntimeTypesOK[s"] } -fact {all o, o': Object | some o.slot[Field] & o'.slot[Field] => o = o'} +fact {all o, o": Object | some o.slot[Field] & o".slot[Field] => o = o"} fact {all g: Getter | no g & g.^subexprs} fact ScopeFact { diff --git a/org.alloytools.alloy.extra/extra/models/examples/systems/marksweepgc.als b/org.alloytools.alloy.extra/extra/models/examples/systems/marksweepgc.als index b8081e3f1..9912e07fc 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/systems/marksweepgc.als +++ b/org.alloytools.alloy.extra/extra/models/examples/systems/marksweepgc.als @@ -13,12 +13,12 @@ sig HeapState { freeList : lone Node } -pred clearMarks[hs, hs' : HeapState] { +pred clearMarks[hs, hs" : HeapState] { // clear marked set - no hs'.marked + no hs".marked // left and right fields are unchanged - hs'.left = hs.left - hs'.right = hs.right + hs".left = hs.left + hs".right = hs.right } /** @@ -28,54 +28,54 @@ fun reachable[hs: HeapState, n: Node] : set Node { n + n.^(hs.left + hs.right) } -pred mark[hs: HeapState, from : Node, hs': HeapState] { - hs'.marked = hs.reachable[from] - hs'.left = hs.left - hs'.right = hs.right +pred mark[hs: HeapState, from : Node, hs": HeapState] { + hs".marked = hs.reachable[from] + hs".left = hs.left + hs".right = hs.right } /** * complete hack to simulate behavior of code to set freeList */ -pred setFreeList[hs, hs': HeapState] { +pred setFreeList[hs, hs": HeapState] { // especially hackish - hs'.freeList.*(hs'.left) in (Node - hs.marked) + hs".freeList.*(hs".left) in (Node - hs.marked) all n: Node | (n !in hs.marked) => { - no hs'.right[n] - hs'.left[n] in (hs'.freeList.*(hs'.left)) - n in hs'.freeList.*(hs'.left) + no hs".right[n] + hs".left[n] in (hs".freeList.*(hs".left)) + n in hs".freeList.*(hs".left) } else { - hs'.left[n] = hs.left[n] - hs'.right[n] = hs.right[n] + hs".left[n] = hs.left[n] + hs".right[n] = hs.right[n] } - hs'.marked = hs.marked + hs".marked = hs.marked } -pred GC[hs: HeapState, root : Node, hs': HeapState] { +pred GC[hs: HeapState, root : Node, hs": HeapState] { some hs1, hs2: HeapState | - hs.clearMarks[hs1] && hs1.mark[root, hs2] && hs2.setFreeList[hs'] + hs.clearMarks[hs1] && hs1.mark[root, hs2] && hs2.setFreeList[hs"] } assert Soundness1 { - all h, h' : HeapState, root : Node | - h.GC[root, h'] => + all h, h" : HeapState, root : Node | + h.GC[root, h"] => (all live : h.reachable[root] | { - h'.left[live] = h.left[live] - h'.right[live] = h.right[live] + h".left[live] = h.left[live] + h".right[live] = h.right[live] }) } assert Soundness2 { - all h, h' : HeapState, root : Node | - h.GC[root, h'] => - no h'.reachable[root] & h'.reachable[h'.freeList] + all h, h" : HeapState, root : Node | + h.GC[root, h"] => + no h".reachable[root] & h".reachable[h".freeList] } assert Completeness { - all h, h' : HeapState, root : Node | - h.GC[root, h'] => - (Node - h'.reachable[root]) in h'.reachable[h'.freeList] + all h, h" : HeapState, root : Node | + h.GC[root, h"] => + (Node - h".reachable[root]) in h".reachable[h".freeList] } check Soundness1 for 3 expect 0 diff --git a/org.alloytools.alloy.extra/extra/models/examples/systems/views.als b/org.alloytools.alloy.extra/extra/models/examples/systems/views.als index 3a5ab82bf..c1a6d27e2 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/systems/views.als +++ b/org.alloytools.alloy.extra/extra/models/examples/systems/views.als @@ -32,8 +32,8 @@ module examples/systems/views * * As a terminological convention, when there are two * complementary view relationships, we will give them types - * t and t'. For example, KeySetView propagates from map to - * set, and KeySetView' propagates from set to map. + * t and t". For example, KeySetView propagates from map to + * set, and KeySetView" propagates from set to map. * * author: Daniel Jackson */ @@ -76,12 +76,12 @@ sig SetRef extends Ref {} fact {State.obj[SetRef] in Set} abstract sig ViewType {} -one sig KeySetView, KeySetView', IteratorView extends ViewType {} +one sig KeySetView, KeySetView", IteratorView extends ViewType {} fact ViewTypes { State.views[KeySetView] in MapRef -> SetRef - State.views[KeySetView'] in SetRef -> MapRef + State.views[KeySetView"] in SetRef -> MapRef State.views[IteratorView] in IteratorRef -> SetRef - all s: State | s.views[KeySetView] = ~(s.views[KeySetView']) + all s: State | s.views[KeySetView] = ~(s.views[KeySetView"]) } /** @@ -107,20 +107,20 @@ pred allocates [pre, post: State, rs: set Ref] { } /** - * models frame condition that limits change to view object from v to v' when backing object changes to b' + * models frame condition that limits change to view object from v to v" when backing object changes to b" */ -pred viewFrame [t: ViewType, v, v', b': Object] { - t in KeySetView => v'.elts = dom [b'.map] - t in KeySetView' => b'.elts = dom [v'.map] - t in KeySetView' => (b'.elts) <: (v.map) = (b'.elts) <: (v'.map) - t in IteratorView => v'.elts = b'.left + b'.done +pred viewFrame [t: ViewType, v, v", b": Object] { + t in KeySetView => v".elts = dom [b".map] + t in KeySetView" => b".elts = dom [v".map] + t in KeySetView" => (b".elts) <: (v.map) = (b".elts) <: (v".map) + t in IteratorView => v".elts = b".left + b".done } pred MapRef.keySet [pre, post: State, setRefs: SetRef] { post.obj[setRefs].elts = dom [pre.obj[this].map] modifies [pre, post, none] allocates [pre, post, setRefs] - post.views = pre.views + KeySetView->this->setRefs + KeySetView'->setRefs->this + post.views = pre.views + KeySetView->this->setRefs + KeySetView"->setRefs->this } pred MapRef.put [pre, post: State, k, v: Ref] { @@ -141,10 +141,10 @@ pred SetRef.iterator [pre, post: State, iterRef: IteratorRef] { } pred IteratorRef.remove [pre, post: State] { - let i = pre.obj[this], i' = post.obj[this] { - i'.left = i.left - i'.done = i.done - i.lastRef - no i'.lastRef + let i = pre.obj[this], i" = post.obj[this] { + i".left = i.left + i".done = i.done - i.lastRef + no i".lastRef } modifies [pre,post,this] allocates [pre, post, none] @@ -152,11 +152,11 @@ pred IteratorRef.remove [pre, post: State] { } pred IteratorRef.next [pre, post: State, ref: Ref] { - let i = pre.obj[this], i' = post.obj[this] { + let i = pre.obj[this], i" = post.obj[this] { ref in i.left - i'.left = i.left - ref - i'.done = i.done + ref - i'.lastRef = ref + i".left = i.left - ref + i".done = i.done + ref + i".lastRef = ref } modifies [pre, post, this] allocates [pre, post, none] diff --git a/org.alloytools.alloy.extra/extra/models/examples/temporal/buffer.als b/org.alloytools.alloy.extra/extra/models/examples/temporal/buffer.als new file mode 100644 index 000000000..03fee08c8 --- /dev/null +++ b/org.alloytools.alloy.extra/extra/models/examples/temporal/buffer.als @@ -0,0 +1,75 @@ +sig Value {} + +sig Buffer { + succ : one Buffer, + var content : lone Value +} + +var one sig read, write in Buffer {} + +fact circular { + all b : Buffer | Buffer in b.^succ +} + +fact init { + read = write + no content +} + +pred send [v : Value] { + no write.content + + content' = content + write -> v + write' = write.succ + read' = read +} + +pred receive [v : Value] { + some read.content + v = read.content + + content' = content - read -> v + write' = write + read' = read.succ +} + +pred stutter { + content' = content + write' = write + read' = read +} + +fact transitions { + always (stutter or some v : Value | send[v] or receive[v]) +} + +run {} + +assert everyReceivedValueWasSent { + all v : Value | always (receive[v] implies once send[v]) +} +check everyReceivedValueWasSent for 4 + +assert orderIsPreserved { + all x, y : Value | always ((receive[x] and once receive[y]) implies once (send[x] and once send[y])) +} + +check orderIsPreserved for 3 + +pred receiveEnabled[v : Value] { + some read.content + read.content = v +} + +pred receiveWeakFairness { all v : Value | + (eventually always receiveEnabled[v]) implies + (always eventually receive[v]) +} + +run receiveWeakFairness + +assert everySentValueWillBeReceived { + receiveWeakFairness implies + all v : Value | always (send[v] implies eventually receive[v]) +} +check everySentValueWillBeReceived for 3 diff --git a/org.alloytools.alloy.extra/extra/models/examples/temporal/leader.als b/org.alloytools.alloy.extra/extra/models/examples/temporal/leader.als new file mode 100644 index 000000000..36d4edd2a --- /dev/null +++ b/org.alloytools.alloy.extra/extra/models/examples/temporal/leader.als @@ -0,0 +1,82 @@ +open util/ordering[Id] + +sig Node { + id : one Id, + succ : one Node, + var inbox : set Id, + var outbox : set Id +} + +sig Id {} + +fact ring { + all i : Id | lone id.i + all n : Node | Node in n.^succ +} + +fun elected : set Node { + {n : Node | once (n.id in n.inbox)} +} + +pred send [n : Node] { + some i : n.outbox { + n.outbox' = n.outbox - i + n.succ.inbox' = n.succ.inbox + i + } + all m : Node - n.succ | m.inbox' = m.inbox + all m : Node - n | m.outbox' = m.outbox +} + +pred compute [n : Node] { + some i : n.inbox { + n.inbox' = n.inbox - i + n.outbox' = n.outbox + (i - n.id.*(~next)) + } + all m : Node - n | m.inbox' = m.inbox + all m : Node - n | m.outbox' = m.outbox +} + +pred skip { + inbox' = inbox + outbox' = outbox +} + +fact init { + no inbox + outbox = id +} + +fact transitions { + always (skip or some n : Node | send[n] or compute[n]) +} + +run {} for 4 but exactly 4 Node, 10 steps +run example {eventually some elected} for 3 but exactly 3 Node, 6 steps + +assert safety { + always lone elected +} +check safety for 3 but 15 steps + + +pred sendEnabled [n : Node] { + some n.outbox +} + +pred computeEnabled [n : Node] { + some n.inbox +} + +pred fairness { + all n : Node { + (eventually always sendEnabled[n] implies (always eventually send[n])) + (eventually always computeEnabled[n] implies (always eventually compute[n])) + } +} + +assert liveness { + eventually some elected +// fairness implies eventually some elected +// fairness and some Node implies eventually some elected +} +check liveness for 3 diff --git a/org.alloytools.alloy.extra/extra/models/examples/temporal/leader_events.als b/org.alloytools.alloy.extra/extra/models/examples/temporal/leader_events.als new file mode 100644 index 000000000..ab5789417 --- /dev/null +++ b/org.alloytools.alloy.extra/extra/models/examples/temporal/leader_events.als @@ -0,0 +1,99 @@ +open util/ordering[Id] + +sig Node { + id : one Id, + succ : one Node, + var inbox : set Id, + var outbox : set Id +} + +sig Id {} + +fact ring { + all i : Id | lone id.i + all n : Node | Node in n.^succ +} + +var sig elected in Node {} + +fact elected { + always { + elected = {n : Node | once (n.id in n.inbox)} + } +} + +enum Event { Send, Compute } + +pred send [n : Node] { + some i : n.outbox { + n.outbox' = n.outbox - i + n.succ.inbox' = n.succ.inbox + i + } + all m : Node - n.succ | m.inbox' = m.inbox + all m : Node - n | m.outbox' = m.outbox +} + +fun send : Event -> Node { + Send -> { n : Node | send[n] } +} + +pred compute [n : Node] { + some i : n.inbox { + n.inbox' = n.inbox - i + n.outbox' = n.outbox + (i - n.id.*(~next)) + } + all m : Node - n | m.inbox' = m.inbox + all m : Node - n | m.outbox' = m.outbox +} + +fun compute : Event -> Node { + Compute -> { n : Node | compute[n] } +} + +fun events : set Event { + (send+compute).Node +} + +pred skip { + inbox' = inbox + outbox' = outbox +} + +fact init { + no inbox + outbox = id +} + +fact behaviour { + always (skip or some n : Node | send[n] or compute[n]) +} + + +run {} for 4 but exactly 4 Node, 10 steps +run example {eventually some elected} for 3 but exactly 3 Node, 6 steps + +assert safety { + always lone elected +} +check safety for 3 but 15 steps + + +pred sendEnabled [n : Node] { + some n.outbox +} + +pred computeEnabled [n : Node] { + some n.inbox +} + +pred fairness { + always (all n : Node | (always sendEnabled[n] implies eventually send[n])) + always (all n : Node | (always computeEnabled[n] implies eventually compute[n])) +} + +assert liveness { +// eventually some elected +// fairness implies eventually some elected + fairness and some Node implies eventually some elected +} +check liveness for 3 diff --git a/org.alloytools.alloy.extra/extra/models/examples/temporal/trash.als b/org.alloytools.alloy.extra/extra/models/examples/temporal/trash.als new file mode 100644 index 000000000..89568df55 --- /dev/null +++ b/org.alloytools.alloy.extra/extra/models/examples/temporal/trash.als @@ -0,0 +1,82 @@ +var sig File {} +var sig Trash in File {} + +pred delete [f: File] { + f not in Trash + Trash' = Trash + f + File' = File +} + +pred restore [f: File] { + f in Trash + Trash' = Trash - f + File' = File +} + +pred empty { + some Trash + no Trash' + File' = File - Trash +} + +pred do_nothing { + File' = File + Trash' = Trash +} + +pred restoreEnabled [f:File] { + f in Trash +} + +fact Behaviour { + no Trash + always { +// (some f: File | delete[f] or restore[f]) or empty + (some f: File | delete[f] or restore[f]) or empty or do_nothing + } +} + +example: run {} + +assert restoreAfterDelete { + always (all f : File | restore[f] implies once delete[f]) +} + +check restoreAfterDelete for 10 steps +check restoreAfterDelete for 1.. steps + +assert deleteAll { +// always ((File in Trash and empty) implies always no File) + always ((File in Trash and empty) implies after always no File) +} + +check deleteAll + +check Exercise1 { + -- The set of files never increases + always (File' in File) +} + + +check Exercise2 { + -- The set of files only changes when empty is performed + always (File' != File implies empty) +} + +check Exercise3 { + (always all f : File | not delete[f]) implies always not empty +} + +check Exercise4 { + -- Once you have no files you never have files again + always (no File implies always no File) +} + +assert restoreIsPossibleBeforeEmpty { + -- a deleted file can still be restored if the trash is not emptied + -- always (all f:File | delete[f] implies (empty releases restoreEnabled[f])) + -- always (all f:File | delete[f] implies ((empty or restore[f]) releases restoreEnabled[f])) + always (all f:File | delete[f] implies after ((empty or restore[f]) releases restoreEnabled[f])) +} + +check restoreIsPossibleBeforeEmpty for 3 but 1.. steps diff --git a/org.alloytools.alloy.extra/extra/models/examples/toys/ceilingsAndFloors.als b/org.alloytools.alloy.extra/extra/models/examples/toys/ceilingsAndFloors.als index e02fe438b..32c03e21b 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/toys/ceilingsAndFloors.als +++ b/org.alloytools.alloy.extra/extra/models/examples/toys/ceilingsAndFloors.als @@ -7,12 +7,12 @@ module models/examples/toys/CeilingsAndFloors * To see why not, check the assertion BelowToo. * * Perhaps simply preventing man's own floor from being his ceiling is enough, - * as is done in the Geometry constraint. BelowToo' shows that there are still + * as is done in the Geometry constraint. BelowToo" shows that there are still * cases where Geometry holds but the implication does not, although now * the smallest solution has 3 Men and 3 Platforms instead of just 2 of each. * * What if we instead prevent floors and ceilings from being shared, - * as is done in the NoSharing constraint? The assertion BelowToo'' + * as is done in the NoSharing constraint? The assertion BelowToo"" * has no counterexamples, demonstrating that the implication now * holds for all small examples. * @@ -33,14 +33,14 @@ check BelowToo for 2 expect 1 pred Geometry {no m: Man | m.floor = m.ceiling} -assert BelowToo' { Geometry => (all m: Man | some n: Man | m.Above[n]) } -check BelowToo' for 2 expect 0 -check BelowToo' for 3 expect 1 +assert BelowToo" { Geometry => (all m: Man | some n: Man | m.Above[n]) } +check BelowToo" for 2 expect 0 +check BelowToo" for 3 expect 1 pred NoSharing { no m,n: Man | m!=n && (m.floor = n.floor || m.ceiling = n.ceiling) } -assert BelowToo'' { NoSharing => (all m: Man | some n: Man | m.Above[n]) } -check BelowToo'' for 6 expect 0 -check BelowToo'' for 10 expect 0 +assert BelowToo"" { NoSharing => (all m: Man | some n: Man | m.Above[n]) } +check BelowToo"" for 6 expect 0 +check BelowToo"" for 10 expect 0 diff --git a/org.alloytools.alloy.extra/extra/models/examples/toys/numbering.als b/org.alloytools.alloy.extra/extra/models/examples/toys/numbering.als index f8c9b5f33..77f6c91c7 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/toys/numbering.als +++ b/org.alloytools.alloy.extra/extra/models/examples/toys/numbering.als @@ -85,14 +85,14 @@ pred Forest [s: State] { all x: Style | lone x.replaces & s.context } -pred AddStyleToContext [s, s': State, style: Style] { +pred AddStyleToContext [s, s": State, style: Style] { all x: style.^parents | some x.replaces & s.context - s'.context = s.context - style.replaces + style + s".context = s.context - style.replaces + style } assert PreserveForest { - all s,s': State, z: Style | - Forest[s] && AddStyleToContext [s,s',z] => Forest[s'] + all s,s": State, z: Style | + Forest[s] && AddStyleToContext [s,s",z] => Forest[s"] } check PreserveForest for 4 expect 0 @@ -107,22 +107,22 @@ sig NumberedState extends State { fact {Style = NumberedStyle} fact {State = NumberedState} -pred AddStyleToNumbering [s, s': State, style: Style] { - s'.value[style] = (style in s.context => s.value[style].next else style.initial) - s'.context = s.context - style.replaces + style +pred AddStyleToNumbering [s, s": State, style: Style] { + s".value[style] = (style in s.context => s.value[style].next else style.initial) + s".context = s.context - style.replaces + style all x: Style - style | - s'.value[x] = (style in x.^parents => x.initial else s.value[x]) + s".value[x] = (style in x.^parents => x.initial else s.value[x]) } -pred AddStyle [s, s': State, style: Style] { - AddStyleToContext [s,s',style] - AddStyleToNumbering [s,s',style] +pred AddStyle [s, s": State, style: Style] { + AddStyleToContext [s,s",style] + AddStyleToNumbering [s,s",style] } assert AddNeverReduces { - all s,s': State, z: Style | - Forest[s] && AddStyle [s,s',z] => - (all y: s'.context | s'.value[y] in s.value[y].*next) + all s,s": State, z: Style | + Forest[s] && AddStyle [s,s",z] => + (all y: s".context | s".value[y] in s.value[y].*next) } check AddNeverReduces for 5 expect 1 diff --git a/org.alloytools.alloy.extra/extra/models/examples/tutorial/farmer.als b/org.alloytools.alloy.extra/extra/models/examples/tutorial/farmer.als index 94ea0d5d8..f08b3539c 100644 --- a/org.alloytools.alloy.extra/extra/models/examples/tutorial/farmer.als +++ b/org.alloytools.alloy.extra/extra/models/examples/tutorial/farmer.als @@ -51,24 +51,24 @@ fact initialState { * Constrains at most one item to move from 'from' to 'to'. * Also constrains which objects get eaten. */ -pred crossRiver [from, from', to, to': set Object] { +pred crossRiver [from, from", to, to": set Object] { // either the Farmer takes no items - (from' = from - Farmer - from'.eats and - to' = to + Farmer) or + (from" = from - Farmer - from".eats and + to" = to + Farmer) or // or the Farmer takes one item (one x : from - Farmer | { - from' = from - Farmer - x - from'.eats - to' = to + Farmer + x }) + from" = from - Farmer - x - from".eats + to" = to + Farmer + x }) } /** * crossRiver transitions between states */ fact stateTransition { - all s: State, s': ord/next[s] { + all s: State, s": ord/next[s] { Farmer in s.near => - crossRiver[s.near, s'.near, s.far, s'.far] else - crossRiver[s.far, s'.far, s.near, s'.near] + crossRiver[s.near, s".near, s.far, s".far] else + crossRiver[s.far, s".far, s.near, s".near] } } diff --git a/org.alloytools.alloy.java/.project b/org.alloytools.alloy.java/.project index a534a1b62..6d93d0d97 100644 --- a/org.alloytools.alloy.java/.project +++ b/org.alloytools.alloy.java/.project @@ -20,4 +20,4 @@ org.eclipse.jdt.core.javanature bndtools.core.bndnature - + \ No newline at end of file diff --git a/org.alloytools.kodkod.core/.classpath b/org.alloytools.kodkod.core/.classpath deleted file mode 100644 index 08abc6d26..000000000 --- a/org.alloytools.kodkod.core/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/org.alloytools.kodkod.core/.gitignore b/org.alloytools.kodkod.core/.gitignore deleted file mode 100644 index 5e9256798..000000000 --- a/org.alloytools.kodkod.core/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/bin/ -/generated/ -/bin_test/ diff --git a/org.alloytools.kodkod.core/.project b/org.alloytools.kodkod.core/.project deleted file mode 100644 index 131928198..000000000 --- a/org.alloytools.kodkod.core/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - org.alloytools.kodkod.core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - bndtools.core.bndbuilder - - - - - - org.eclipse.jdt.core.javanature - bndtools.core.bndnature - - diff --git a/org.alloytools.kodkod.core/.settings/org.eclipse.core.resources.prefs b/org.alloytools.kodkod.core/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/org.alloytools.kodkod.core/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/org.alloytools.kodkod.core/.settings/org.eclipse.core.runtime.prefs b/org.alloytools.kodkod.core/.settings/org.eclipse.core.runtime.prefs deleted file mode 100644 index 5a0ad22d2..000000000 --- a/org.alloytools.kodkod.core/.settings/org.eclipse.core.runtime.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -line.separator=\n diff --git a/org.alloytools.kodkod.core/.settings/org.eclipse.jdt.core.prefs b/org.alloytools.kodkod.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 581b9f158..000000000 --- a/org.alloytools.kodkod.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,446 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.circularClasspath=error -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.processAnnotations=disabled -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled -org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL -org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME -org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=4 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=true -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=2 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=51 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=50 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=2 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=2 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=2 -org.eclipse.jdt.core.formatter.alignment_for_assignment=2 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=2 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=2 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=2 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=2 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=2 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=2 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=2 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=50 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=2 -org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 -org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=2 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=false -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=4 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=4 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=false -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=140 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 -org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=true -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true -org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.alloytools.kodkod.core/.settings/org.eclipse.jdt.ui.prefs b/org.alloytools.kodkod.core/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index dcee2a4d2..000000000 --- a/org.alloytools.kodkod.core/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,131 +0,0 @@ -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_functional_interfaces=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false -cleanup.format_source_code=false -cleanup.format_source_code_changes_only=false -cleanup.insert_inferred_type_arguments=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=false -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true -cleanup.remove_trailing_whitespaces=false -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_anonymous_class_creation=false -cleanup.use_blocks=false -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_lambda=true -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=false -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=false -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup.use_type_arguments=false -cleanup_profile=org.eclipse.jdt.ui.default.eclipse_clean_up_profile -cleanup_settings_version=2 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_Alloy -formatter_settings_version=13 -org.eclipse.jdt.ui.exception.name=e -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=java;javax;org;com; -org.eclipse.jdt.ui.javadoc=false -org.eclipse.jdt.ui.keywordthis=false -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.overrideannotation=true -org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates= -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=false -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_functional_interfaces=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.insert_inferred_type_arguments=false -sp_cleanup.make_local_variable_final=false -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_redundant_type_arguments=false -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_anonymous_class_creation=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_lambda=false -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true -sp_cleanup.use_type_arguments=false diff --git a/org.alloytools.kodkod.core/LICENSE b/org.alloytools.kodkod.core/LICENSE deleted file mode 100644 index f28680ae4..000000000 --- a/org.alloytools.kodkod.core/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ - -Kodkod -- Copyright (c) 2005-present, Emina Torlak - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/org.alloytools.kodkod.core/README.md b/org.alloytools.kodkod.core/README.md deleted file mode 100644 index 1f5b5ee49..000000000 --- a/org.alloytools.kodkod.core/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# kodkod-star - -Kodkod with arithmetic overflow prevention and higher-order solving extensions diff --git a/org.alloytools.kodkod.core/bnd.bnd b/org.alloytools.kodkod.core/bnd.bnd deleted file mode 100644 index eb0b8ad61..000000000 --- a/org.alloytools.kodkod.core/bnd.bnd +++ /dev/null @@ -1,38 +0,0 @@ - -Specification-Title: Kodkod API (with arithmetic overflow prevention and higher-order solving extensions) -Specification-Version: 2.0.1 -Specification-Vendor: Emina Torlak -Implementation-Title: Kodkod API -Implementation-Version: 2.0 -Implementation-Vendor: Emina Torlak - -Export-Package: \ - kodkod.ast,\ - kodkod.ast.operator,\ - kodkod.ast.visitor,\ - kodkod.engine,\ - kodkod.engine.bool,\ - kodkod.engine.config,\ - kodkod.engine.fol2sat,\ - kodkod.engine.hol,\ - kodkod.engine.satlab,\ - kodkod.engine.ucore,\ - kodkod.instance,\ - kodkod.util.collections,\ - kodkod.util.ints,\ - kodkod.util.nodes - --buildpath: \ - org.sat4j.core,\ - org.alloytools.kodkod.nativesat.util;version=latest,\ - org.alloytools.kodkod.nativesat.amd64-linux;version=latest,\ - org.alloytools.kodkod.nativesat.x86-linux;version=latest,\ - org.alloytools.kodkod.nativesat.x86-mac;version=latest,\ - org.alloytools.kodkod.nativesat.x86-windows;version=latest - --testpath: \ - osgi.enroute.junit.wrapper, \ - osgi.enroute.hamcrest.wrapper - --includeresource: LICENSE - diff --git a/org.alloytools.kodkod.core/release.properties b/org.alloytools.kodkod.core/release.properties deleted file mode 100644 index 5ff049083..000000000 --- a/org.alloytools.kodkod.core/release.properties +++ /dev/null @@ -1,7 +0,0 @@ -kodkod.specification.version=2.0 -kodkod.specification.title=Kodkod -kodkod.implementation.version=2.0 -kodkod.author=Emina Torlak -kodkod.platform.darwin=darwin_x86_64 -kodkod.platform.linux=linux_x86_64 -kodkod.platform.windows=windows_x86_64 \ No newline at end of file diff --git a/org.alloytools.kodkod.core/release.xml b/org.alloytools.kodkod.core/release.xml deleted file mode 100644 index 346005dbc..000000000 --- a/org.alloytools.kodkod.core/release.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryExpression.java deleted file mode 100644 index cfdd7bfa3..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryExpression.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A relational {@link kodkod.ast.Expression expression} with two children. - * - * @specfield left: Expression - * @specfield right: Expression - * @specfield op: ExprOperator - * @specfield op.binary() - * @invariant children = 0->left + 1->right - * @author Emina Torlak - */ -public final class BinaryExpression extends Expression { - - private final ExprOperator op; - private final Expression left; - private final Expression right; - private final int arity; - - /** - * Constructs a new binary expression: left op right - * - * @ensures this.left' = left && this.right' = right && this.op' = op - * @throws NullPointerException left = null || right = null || op = null - * @throws IllegalArgumentException left and right cannot be combined with the - * specified operator. - */ - BinaryExpression(final Expression left, final ExprOperator op, final Expression right) { - switch (op) { - case UNION : - case INTERSECTION : - case DIFFERENCE : - case OVERRIDE : - this.arity = left.arity(); - if (arity != right.arity()) - throw new IllegalArgumentException("Incompatible arities: " + left + " and " + right); - break; - case JOIN : - this.arity = left.arity() + right.arity() - 2; - if (arity < 1) - throw new IllegalArgumentException("Incompatible arities: " + left + " and " + right); - break; - case PRODUCT : - this.arity = left.arity() + right.arity(); - break; - default : - throw new IllegalArgumentException("Not a binary operator: " + op); - } - - this.op = op; - this.left = left; - this.right = right; - - } - - /** - * Returns the arity of this binary expression. - * - * @return this.arity - * @see kodkod.ast.Expression#arity() - */ - @Override - public int arity() { - return arity; - } - - /** - * Returns this.op. - * - * @return this.op - */ - public ExprOperator op() { - return op; - } - - /** - * Returns the left child of this. - * - * @return this.left - */ - public Expression left() { - return left; - } - - /** - * Returns the right child of this. - * - * @return this.right - */ - public Expression right() { - return right; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(" + left + " " + op + " " + right + ")"; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryFormula.java deleted file mode 100644 index 2f56c3c0e..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryFormula.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A {@link kodkod.ast.Formula formula} with two children. - * - * @specfield left: Formula - * @specfield right: Formula - * @specfield op: FormulaOperator - * @invariant children = 0->left + 1->right - * @author Emina Torlak - */ -public final class BinaryFormula extends Formula { - - private final Formula left; - private final Formula right; - private final FormulaOperator op; - - /** - * Constructs a new binary formula: left op right - * - * @ensures this.left' = left && this.right' = right && this.op' = op - * @throws NullPointerException left = null || right = null || op = null - */ - BinaryFormula(Formula left, FormulaOperator op, Formula right) { - this.left = left; - this.right = right; - this.op = op; - } - - /** - * Returns the left child of this. - * - * @return this.left - */ - public Formula left() { - return left; - } - - /** - * Returns the right child of this. - * - * @return this.right - */ - public Formula right() { - return right; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public FormulaOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(" + left + " " + op + " " + right + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryIntExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryIntExpression.java deleted file mode 100644 index 8412d51c4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/BinaryIntExpression.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.IntOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A binary integer expression such as x + y. - * - * @specfield left: IntExpression - * @specfield right: IntExpression - * @specfield op: IntOperator - * @specfield op.binary() - * @invariant children = 0->left + 1->right - * @author Emina Torlak - */ -public final class BinaryIntExpression extends IntExpression { - - private final IntOperator op; - private final IntExpression left, right; - - /** - * Constructs a new binary int formula: left op right - * - * @ensures this.left' = left && this.right' = right && this.op' = op - * @throws NullPointerException left = null || right = null || op = null - */ - public BinaryIntExpression(final IntExpression left, final IntOperator op, final IntExpression right) { - if (!op.binary()) - throw new IllegalArgumentException("Not a binary operator: " + op); - this.left = left; - this.right = right; - this.op = op; - } - - /** - * Returns the left child of this. - * - * @return this.left - */ - public IntExpression left() { - return left; - } - - /** - * Returns the right child of this. - * - * @return this.right - */ - public IntExpression right() { - return right; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public IntOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(" + left + " " + op + " " + right + ")"; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ComparisonFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ComparisonFormula.java deleted file mode 100644 index 836fb2336..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ComparisonFormula.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.ExprCompOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A formula that compares two expressions, e.g. x = y - * - * @specfield left: Expression - * @specfield right: Expression - * @specfield op: ExprCompOperator - * @invariant children = 0->left + 1->right - * @author Emina Torlak - */ -public final class ComparisonFormula extends Formula { - - private final Expression left; - private final Expression right; - private final ExprCompOperator op; - - /** - * Constructs a new comparison formula: left op right - * - * @ensures this.left' = left && this.right' = right && this.op' = op * @throws - * NullPointerException left = null || right = null || op = null - * @throws IllegalArgumentException left.arity != right.arity - */ - ComparisonFormula(Expression left, ExprCompOperator op, Expression right) { - if (left.arity() != right.arity()) { - throw new IllegalArgumentException("Arity mismatch: " + left + "::" + left.arity() + " and " + right + "::" + right.arity()); - } - this.left = left; - this.right = right; - this.op = op; - } - - /** - * Returns the left child of this. - * - * @return this.left - */ - public Expression left() { - return left; - } - - /** - * Returns the right child of this. - * - * @return this.right - */ - public Expression right() { - return right; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public ExprCompOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(" + left + " " + op + " " + right + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Comprehension.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Comprehension.java deleted file mode 100644 index 07f3549d9..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Comprehension.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A comprehension expression, e.g. { a: A, b: B | a.r = b } - * - * @specfield decls: Declarations - * @specfield formula: Formula - * @invariant arity = sum(decls.declarations().arity) - * @invariant children = 0->decls + 1->formula - * @author Emina Torlak - */ -public final class Comprehension extends Expression { - - private final Decls decls; - private final Formula formula; - private final int arity; - - /** - * Constructs a comprehension expression with the specified decls and formula - * - * @ensures this.decls' = decls && this.formula' = formula - * @throws NullPointerException decls = null || formula = null - */ - Comprehension(Decls declarations, Formula formula) { - if (formula == null) - throw new NullPointerException("null formula"); - // for(Decl decl : declarations) { - // if (decl.variable().arity()>1 || - // decl.multiplicity()!=Multiplicity.ONE) - // throw new IllegalArgumentException("Cannot have a higher order - // declaration in a comprehension: "+decl); - // } - this.decls = declarations; - this.formula = formula; - int arity = 0; - for (Decl d : decls) - arity += d.variable().arity(); - this.arity = arity; - } - - /** - * @return this.formula - */ - public Formula formula() { - return formula; - } - - /** - * @return this.decls - */ - public Decls decls() { - return decls; - } - - /** - * Returns the arity of this comprehension expression, which is the sum of the - * arities of declared variables - * - * @return #this.decls - */ - @Override - public int arity() { - return arity; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "{ " + decls().toString() + " | " + formula().toString() + " }"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ConstantExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ConstantExpression.java deleted file mode 100644 index 156b286d0..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ConstantExpression.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A constant valued expression. - * - * @invariant no children - * @author Emina Torlak - */ -public final class ConstantExpression extends LeafExpression { - - /** - * Constructs a constant expression with the given arity. - */ - ConstantExpression(String name, int arity) { - super(name, arity); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ConstantFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ConstantFormula.java deleted file mode 100644 index ddf4dd094..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ConstantFormula.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A constant {@link kodkod.ast.Formula formula}, true or false. - * - * @invariant no children - * @author Emina Torlak - */ -public abstract class ConstantFormula extends Formula { - - private final boolean value; - - /** - * Constructs a constant formula with the given value. - */ - ConstantFormula(boolean value) { - this.value = value; - } - - /** - * Returns the boolean value that corresponds to this constant formula. - * - * @return this=TRUE => true, false - */ - public final boolean booleanValue() { - return value; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return String.valueOf(booleanValue()); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Decl.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Decl.java deleted file mode 100644 index 6c7a49791..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Decl.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A variable declaration, such as 'x : lone X'. Declarations are used with - * quantified formulas and comprehension expressions. - * - * @specfield variable: Variable - * @specfield expression: Expression - * @specfield multiplicity: LONE + ONE + SOME + SET - * @invariant variable.arity = expression.arity - * @invariant children = 0->variable + 1->expression - * @author Emina Torlak - */ -public final class Decl extends Decls { - - private final Variable variable; - private final Multiplicity mult; - private final Expression expression; - - /** - * Constructs a new declaration from the specified variable and expression, with - * the specified order. - * - * @ensures this.variable' = variable && this.expression' = expression && - * this.multiplicity' = mult - * @throws NullPointerException variable = null || expression = null || mult = - * null - * @throws IllegalArgumentException variable.arity != expression.arity - */ - Decl(Variable variable, Multiplicity mult, Expression expression) { - if (mult == Multiplicity.NO) - throw new IllegalArgumentException("NO is not a valid multiplicity in a declaration."); - if (variable.arity() != expression.arity()) - throw new IllegalArgumentException("Unmatched arities in a declaration: " + variable + " and " + expression); - if (mult != Multiplicity.SET && expression.arity() > 1) - throw new IllegalArgumentException("Cannot use multiplicity " + mult + " with an expression of arity > 1."); - this.variable = variable; - this.mult = mult; - this.expression = expression; - } - - /** - * Returns the variable in this declaration. - * - * @return this.variable - */ - public Variable variable() { - return variable; - } - - /** - * Returns the multiplicity in this declaration. - * - * @return this.multiplicity - */ - public Multiplicity multiplicity() { - return mult; - } - - /** - * Returns the expression in this declaration. - * - * @return this.exresssion - */ - public Expression expression() { - return expression; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public D accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return variable + ": " + mult + " " + expression; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Decls.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Decls.java deleted file mode 100644 index ecfbcaeda..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Decls.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import java.util.Arrays; -import java.util.Iterator; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; - -/** - * A sequence of decls. - * - * @specfield size: int - * @specfield decls: [0..size) -> one Decl - * @invariant size > 0 - * @invariant children = decls - * @author Emina Torlak - */ -public class Decls extends Node implements Iterable { - - private final Decl[] decls; - - /** - * Constructs a Decls object with itself as its sole declaration. This - * constructor can only be called from inside the Decl constructor; otherwise it - * will throw a ClassCastException. - * - * @ensures this.declarations' = 0->this - * @throws ClassCastException this !in Decl - */ - Decls() { - this.decls = new Decl[] { - (Decl) this - }; - } - - /** - * Constructs a new Decls with the specified head and tail. - * - * @requires head.size > 0 && tail.size > 0 - * @ensures this.size' = head.size + tail.size && (all i: [0..head.size) | - * this.decls[i] = head.decls[i]) && (all i: [head.size..this.size') | - * this.decls[i] = tail.decls[i]) - * @throws NullPointerException head = null || tail is null - */ - private Decls(Decls head, Decls tail) { - this.decls = new Decl[head.size() + tail.size()]; - System.arraycopy(head.decls, 0, decls, 0, head.size()); - System.arraycopy(tail.decls, 0, decls, head.size(), tail.size()); - } - - /** - * Returns the number of decls in this Decls object. - * - * @return this.size - */ - public int size() { - return decls.length; - } - - /** - * Returns the ith declaration in this Decls sequence. - * - * @requires 0 <= i < this.size - * @return this.decls[i] - */ - public Decl get(int i) { - return decls[i]; - } - - /** - * Returns an unmodifiable iterator over the decls in this Decls object. - * - * @return an unmodifiable iterator over the decls in this Decls object. - */ - @Override - public Iterator iterator() { - return Containers.iterate(decls); - } - - /** - * Returns a sequence of this.size + other.size decls that has these decls as - * the prefix and the given decls as the suffix. - * - * @return {ds: Decls | ds.size = this.size + other.size && ds.decls = - * this.decls + {i: [this.size..this.size+other.size), d: Decl | d = - * other.decls[i-this.size] } - * @throws NullPointerException decl = null - */ - public final Decls and(Decls other) { - return new Decls(this, other); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public D accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return Arrays.toString(decls); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ExprToIntCast.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ExprToIntCast.java deleted file mode 100644 index 56eadaa58..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ExprToIntCast.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.ExprCastOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * An {@link kodkod.ast.IntExpression } representing the cardinality of an - * {@link kodkod.ast.Expression} or the sum of all the integer atoms contained - * in the expression. - * - * @specfield expression: Expression - * @specfield op: ExprCastOperator - * @invariant children = 0->expression - * @author Emina Torlak - */ -public final class ExprToIntCast extends IntExpression { - - private final Expression expression; - private final ExprCastOperator op; - - /** - * Constructs a new cardinality expression. - * - * @ensures this.expression' = expression && this.op' = op - * @throws NullPointerException expression = null || op = null - * @throws IllegalArgumentException op = SUM && child.arity != 1 - */ - ExprToIntCast(Expression child, ExprCastOperator op) { - if (child.arity() > 1 && op == ExprCastOperator.SUM) - throw new IllegalArgumentException("cannot apply " + op + " to " + child); - this.expression = child; - this.op = op; - } - - /** - * Returns this.expression. - * - * @return this.expression - */ - public Expression expression() { - return expression; - } - - /** - * Returns this.op. - * - * @return this.op - */ - public ExprCastOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return op + "(" + expression.toString() + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Expression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Expression.java deleted file mode 100644 index 36b128f4b..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Expression.java +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import static kodkod.ast.operator.ExprCastOperator.CARDINALITY; -import static kodkod.ast.operator.ExprCastOperator.SUM; -import static kodkod.ast.operator.ExprCompOperator.EQUALS; -import static kodkod.ast.operator.ExprCompOperator.SUBSET; -import static kodkod.ast.operator.ExprOperator.CLOSURE; -import static kodkod.ast.operator.ExprOperator.DIFFERENCE; -import static kodkod.ast.operator.ExprOperator.INTERSECTION; -import static kodkod.ast.operator.ExprOperator.JOIN; -import static kodkod.ast.operator.ExprOperator.OVERRIDE; -import static kodkod.ast.operator.ExprOperator.PRODUCT; -import static kodkod.ast.operator.ExprOperator.REFLEXIVE_CLOSURE; -import static kodkod.ast.operator.ExprOperator.TRANSPOSE; -import static kodkod.ast.operator.ExprOperator.UNION; -import static kodkod.ast.operator.Multiplicity.LONE; -import static kodkod.ast.operator.Multiplicity.NO; -import static kodkod.ast.operator.Multiplicity.ONE; -import static kodkod.ast.operator.Multiplicity.SOME; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import kodkod.ast.operator.ExprCastOperator; -import kodkod.ast.operator.ExprCompOperator; -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.util.collections.Containers; - -/** - * A relational expression. Unless otherwise noted, all methods in this class - * throw a NullPointerException when given null arguments. - * - * @specfield arity: int - * @invariant arity > 0 - * @author Emina Torlak - */ -public abstract class Expression extends Node { - - /** - * The universal relation: contains all atoms in a - * {@link kodkod.instance.Universe universe of discourse}. - */ - public static final Expression UNIV = new ConstantExpression("univ", 1); - - /** - * The identity relation: maps all atoms in a {@link kodkod.instance.Universe - * universe of discourse} to themselves. - */ - public static final Expression IDEN = new ConstantExpression("iden", 2); - - /** The empty relation: contains no atoms. */ - public static final Expression NONE = new ConstantExpression("none", 1); - - /** - * The integer relation: contains all atoms {@link kodkod.instance.Bounds bound} - * to integers - */ - public static final Expression INTS = new ConstantExpression("ints", 1); - - /** - * Constructs a leaf expression - * - * @ensures no this.children' - */ - Expression() {} - - /** - * Returns the join of this and the specified expression. The effect of this - * method is the same as calling this.compose(JOIN, expr). - * - * @return this.compose(JOIN, expr) - */ - public final Expression join(Expression expr) { - return compose(JOIN, expr); - } - - /** - * Returns the product of this and the specified expression. The effect of this - * method is the same as calling this.compose(PRODUCT, expr). - * - * @return this.compose(PRODUCT, expr) - */ - public final Expression product(Expression expr) { - return compose(PRODUCT, expr); - } - - /** - * Returns the union of this and the specified expression. The effect of this - * method is the same as calling this.compose(UNION, expr). - * - * @return this.compose(UNION, expr) - */ - public final Expression union(Expression expr) { - return compose(UNION, expr); - } - - /** - * Returns the difference of this and the specified expression. The effect of - * this method is the same as calling this.compose(DIFFERENCE, expr). - * - * @return this.compose(DIFFERENCE, expr) - */ - public final Expression difference(Expression expr) { - return compose(DIFFERENCE, expr); - } - - /** - * Returns the intersection of this and the specified expression. The effect of - * this method is the same as calling this.compose(INTERSECTION, expr). - * - * @return this.compose(INTERSECTION, expr) - */ - public final Expression intersection(Expression expr) { - return compose(INTERSECTION, expr); - } - - /** - * Returns the relational override of this with the specified expression. The - * effect of this method is the same as calling this.compose(OVERRIDE, expr). - * - * @return this.compose(OVERRIDE, expr) - */ - public final Expression override(Expression expr) { - return compose(OVERRIDE, expr); - } - - /** - * Returns the composition of this and the specified expression, using the given - * binary operator. - * - * @requires op in ExprOperator.BINARY - * @return {e: Expression | e.left = this and e.right = expr and e.op = this } - */ - public final Expression compose(ExprOperator op, Expression expr) { - return new BinaryExpression(this, op, expr); - } - - /** - * Returns the union of the given expressions. The effect of this method is the - * same as calling compose(UNION, exprs). - * - * @return compose(UNION, exprs) - */ - public static Expression union(Expression... exprs) { - return compose(UNION, exprs); - } - - /** - * Returns the union of the given expressions. The effect of this method is the - * same as calling compose(UNION, exprs). - * - * @return compose(UNION, exprs) - */ - public static Expression union(Collection< ? extends Expression> exprs) { - return compose(UNION, exprs); - } - - /** - * Returns the intersection of the given expressions. The effect of this method - * is the same as calling compose(INTERSECTION, exprs). - * - * @return compose(INTERSECTION, exprs) - */ - public static Expression intersection(Expression... exprs) { - return compose(INTERSECTION, exprs); - } - - /** - * Returns the intersection of the given expressions. The effect of this method - * is the same as calling compose(INTERSECTION, exprs). - * - * @return compose(INTERSECTION, exprs) - */ - public static Expression intersection(Collection< ? extends Expression> exprs) { - return compose(INTERSECTION, exprs); - } - - /** - * Returns the product of the given expressions. The effect of this method is - * the same as calling compose(PRODUCT, exprs). - * - * @return compose(PRODUCT, exprs) - */ - public static Expression product(Expression... exprs) { - return compose(PRODUCT, exprs); - } - - /** - * Returns the product of the given expressions. The effect of this method is - * the same as calling compose(PRODUCT, exprs). - * - * @return compose(PRODUCT, exprs) - */ - public static Expression product(Collection< ? extends Expression> exprs) { - return compose(PRODUCT, exprs); - } - - /** - * Returns the override of the given expressions. The effect of this method is - * the same as calling compose(OVERRIDE, exprs). - * - * @return compose(OVERRIDE, exprs) - */ - public static Expression override(Expression... exprs) { - return compose(OVERRIDE, exprs); - } - - /** - * Returns the override of the given expressions. The effect of this method is - * the same as calling compose(OVERRIDE, exprs). - * - * @return compose(OVERRIDE, exprs) - */ - public static Expression override(Collection< ? extends Expression> exprs) { - return compose(OVERRIDE, exprs); - } - - /** - * Returns the composition of the given expressions using the given operator. - * - * @requires exprs.length = 2 => op.binary(), exprs.length > 2 => op.nary() - * @return exprs.length=1 => exprs[0] else {e: Expression | e.children = exprs - * and e.op = this } - */ - public static Expression compose(ExprOperator op, Expression... exprs) { - switch (exprs.length) { - case 0 : - throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(exprs)); - case 1 : - return exprs[0]; - case 2 : - return new BinaryExpression(exprs[0], op, exprs[1]); - default : - return new NaryExpression(op, Containers.copy(exprs, new Expression[exprs.length])); - } - } - - /** - * Returns the composition of the given expressions using the given operator. - * - * @requires exprs.size() = 2 => op.binary(), exprs.size() > 2 => op.nary() - * @return exprs.size()=1 => exprs.iterator().next() else {e: Expression | - * e.children = exprs.toArray() and e.op = this } - */ - public static Expression compose(ExprOperator op, Collection< ? extends Expression> exprs) { - switch (exprs.size()) { - case 0 : - throw new IllegalArgumentException("Expected at least one argument: " + exprs); - case 1 : - return exprs.iterator().next(); - case 2 : - final Iterator< ? extends Expression> itr = exprs.iterator(); - return new BinaryExpression(itr.next(), op, itr.next()); - default : - return new NaryExpression(op, exprs.toArray(new Expression[exprs.size()])); - } - } - - /** - * Returns the transpose of this. The effect of this method is the same as - * calling this.apply(TRANSPOSE). - * - * @return this.apply(TRANSPOSE) - */ - public final Expression transpose() { - return apply(TRANSPOSE); - } - - /** - * Returns the transitive closure of this. The effect of this method is the same - * as calling this.apply(CLOSURE). - * - * @return this.apply(CLOSURE) - */ - public final Expression closure() { - return apply(CLOSURE); - } - - /** - * Returns the reflexive transitive closure of this. The effect of this method - * is the same as calling this.apply(REFLEXIVE_CLOSURE). - * - * @return this.apply(REFLEXIVE_CLOSURE) - */ - public final Expression reflexiveClosure() { - return apply(REFLEXIVE_CLOSURE); - } - - /** - * Returns the expression that results from applying the given unary operator to - * this. - * - * @requires op.unary() - * @return {e: Expression | e.expression = this && e.op = this } - * @throws IllegalArgumentException this.arity != 2 - */ - public final Expression apply(ExprOperator op) { - return new UnaryExpression(op, this); - } - - /** - * Returns the projection of this expression onto the specified columns. - * - * @return {e: Expression | e = project(this, columns) } - * @throws IllegalArgumentException columns.length < 1 - */ - public final Expression project(IntExpression... columns) { - return new ProjectExpression(this, columns); - } - - /** - * Returns the cardinality of this expression. The effect of this method is the - * same as calling this.apply(CARDINALITY). - * - * @return this.apply(CARDINALITY) - */ - public final IntExpression count() { - return apply(CARDINALITY); - } - - /** - * Returns the sum of the integer atoms in this expression. The effect of this - * method is the same as calling this.apply(SUM). - * - * @return this.apply(SUM) - */ - public final IntExpression sum() { - return apply(SUM); - } - - /** - * Returns the cast of this expression to an integer expression, that represents - * either the cardinality of this expression (if op is CARDINALITY) or the sum - * of the integer atoms it contains (if op is SUM). - * - * @return {e: IntExpression | e.op = op && e.expression = this} - */ - public final IntExpression apply(ExprCastOperator op) { - return new ExprToIntCast(this, op); - } - - /** - * Returns the formula 'this = expr'. The effect of this method is the same as - * calling this.compare(EQUALS, expr). - * - * @return this.compare(EQUALS, expr) - */ - public final Formula eq(Expression expr) { - return compare(EQUALS, expr); - } - - /** - * Returns the formula 'this in expr'. The effect of this method is the same as - * calling this.compare(SUBSET, expr). - * - * @return this.compare(SUBSET, expr) - */ - public final Formula in(Expression expr) { - return compare(SUBSET, expr); - } - - /** - * Returns the formula that represents the comparison of this and the given - * expression using the given comparison operator. - * - * @return {f: Formula | f.left = this && f.right = expr && f.op = op} - */ - public final Formula compare(ExprCompOperator op, Expression expr) { - return new ComparisonFormula(this, op, expr); - } - - /** - * Returns the formula 'some this'. The effect of this method is the same as - * calling this.apply(SOME). - * - * @return this.apply(SOME) - */ - public final Formula some() { - return apply(SOME); - } - - /** - * Returns the formula 'no this'. The effect of this method is the same as - * calling this.apply(NO). - * - * @return this.apply(NO) - */ - public final Formula no() { - return apply(NO); - } - - /** - * Returns the formula 'one this'. The effect of this method is the same as - * calling this.apply(ONE). - * - * @return this.apply(ONE) - */ - public final Formula one() { - return apply(ONE); - } - - /** - * Returns the formula 'lone this'. The effect of this method is the same as - * calling this.apply(LONE). - * - * @return this.apply(LONE) - */ - public final Formula lone() { - return apply(LONE); - } - - public Expression pre() { - return new UnaryExpression(ExprOperator.PRE, this); - } - - /** - * Returns the formula that results from applying the specified multiplicity to - * this expression. The SET multiplicity is not allowed. - * - * @return {f: Formula | f.multiplicity = mult && f.expression = this} - * @throws IllegalArgumentException mult = SET - */ - public final Formula apply(Multiplicity mult) { - return new MultiplicityFormula(mult, this); - } - - /** - * Returns the arity of this expression. - * - * @return this.arity - */ - public abstract int arity(); - - /** - * Accepts the given visitor and returns the result. - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public abstract E accept(ReturnVisitor visitor); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/FixFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/FixFormula.java deleted file mode 100644 index 662b41b59..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/FixFormula.java +++ /dev/null @@ -1,42 +0,0 @@ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -public class FixFormula extends Formula { - - private final Formula formula; - private final Formula condition; - - public FixFormula(Formula formula, Formula condition) { - if (formula == null || condition == null) { - throw new NullPointerException("null arg"); - } - this.formula = formula; - this.condition = condition; - } - - public Formula formula() { - return formula; - } - - public Formula condition() { - return condition; - } - - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - @Override - public String toString() { - return "(fix " + formula + " | " + condition + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Formula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Formula.java deleted file mode 100644 index c236662da..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Formula.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import static kodkod.ast.operator.FormulaOperator.AND; -import static kodkod.ast.operator.FormulaOperator.IFF; -import static kodkod.ast.operator.FormulaOperator.IMPLIES; -import static kodkod.ast.operator.FormulaOperator.OR; -import static kodkod.ast.operator.Quantifier.ALL; -import static kodkod.ast.operator.Quantifier.SOME; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.util.collections.Containers; - -/** - * A first-order formula. Unless otherwise noted, all methods in this class - * throw a NullPointerException when given null arguments. - * - * @author Emina Torlak - */ -public abstract class Formula extends Node { - - /** Constant formula true */ - public static final Formula TRUE = new ConstantFormula(true) {}; - - /** Constant formula false */ - public static final Formula FALSE = new ConstantFormula(false) {}; - - Formula() {} - - /** - * Returns the constant formula with the given value. - * - * @return value ? TRUE : FALSE - */ - public static Formula constant(boolean value) { - return value ? TRUE : FALSE; - } - - /** - * Returns the conjunction of this and the specified formula. The effect of this - * method is the same as calling this.compose(AND, formula). - * - * @return this.compose(AND, formula) - */ - public final Formula and(Formula formula) { - return compose(AND, formula); - } - - /** - * Returns the conjunction of this and the specified formula. The effect of this - * method is the same as calling this.compose(OR, formula). - * - * @return this.compose(OR, formula) - */ - public final Formula or(Formula formula) { - return compose(OR, formula); - } - - /** - * Returns a formula that equates this and the specified formula. The effect of - * this method is the same as calling this.compose(IFF, formula). - * - * @return this.compose(IFF, formula) - */ - public final Formula iff(Formula formula) { - return compose(IFF, formula); - } - - /** - * Returns the implication of the specified formula by this. The effect of this - * method is the same as calling this.compose(IMPLIES, formula). - * - * @return this.compose(IMPLIES, formula) - */ - public final Formula implies(Formula formula) { - return compose(IMPLIES, formula); - } - - /** - * Returns the composition of this and the specified formula using the given - * binary operator. - * - * @return {f: Formula | f.left = this and f.right = formula and f.op = op } - */ - public final Formula compose(FormulaOperator op, Formula formula) { - return new BinaryFormula(this, op, formula); - } - - /** - * Returns the conjunction of the given formulas. The effect of this method is - * the same as calling compose(AND, formulas). - * - * @return compose(AND, formulas) - */ - public static Formula and(Formula... formulas) { - return compose(AND, formulas); - } - - /** - * Returns the conjunction of the given formulas. The effect of this method is - * the same as calling compose(AND, formulas). - * - * @return compose(AND, formulas) - */ - public static Formula and(Collection< ? extends Formula> formulas) { - return compose(AND, formulas); - } - - /** - * Returns the disjunction of the given formulas. The effect of this method is - * the same as calling compose(OR, formulas). - * - * @return compose(OR, formulas) - */ - public static Formula or(Formula... formulas) { - return compose(OR, formulas); - } - - /** - * Returns the disjunction of the given formulas. The effect of this method is - * the same as calling compose(OR, formulas). - * - * @return compose(OR, formulas) - */ - public static Formula or(Collection< ? extends Formula> formulas) { - return compose(OR, formulas); - } - - /** - * Returns the composition of the given formulas using the given operator. - * - * @requires formulas.length != 2 => op.nary() - * @return - * - *

-     *  formulas.length = 0 => constant(op=AND) else
-     * 	formulas.length=1 => formulas[0] else
-     *  {e: Formula | e.children = formulas and e.op = this }
-     *         
- */ - public static Formula compose(FormulaOperator op, Formula... formulas) { - switch (formulas.length) { - case 0 : - switch (op) { - case AND : - return TRUE; - case OR : - return FALSE; - default : - throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(formulas)); - } - case 1 : - return formulas[0]; - case 2 : - return new BinaryFormula(formulas[0], op, formulas[1]); - default : - return new NaryFormula(op, Containers.copy(formulas, new Formula[formulas.length])); - } - } - - /** - * Returns the composition of the given formulas using the given operator. - * - * @requires formulas.size() != 2 => op.nary() - * @return - * - *
-     *  formulas.size() = 0 => constant(op=AND) else
-     *  formulas.size() = 1 => formulas.iterator().next() else
-     *  {e: Formula | e.children = formulas.toArray() and e.op = this }
-     *         
- */ - public static Formula compose(FormulaOperator op, Collection< ? extends Formula> formulas) { - switch (formulas.size()) { - case 0 : - switch (op) { - case AND : - return TRUE; - case OR : - return FALSE; - default : - throw new IllegalArgumentException("Expected at least one argument: " + formulas); - } - case 1 : - return formulas.iterator().next(); - case 2 : - final Iterator< ? extends Formula> itr = formulas.iterator(); - return new BinaryFormula(itr.next(), op, itr.next()); - default : - return new NaryFormula(op, formulas.toArray(new Formula[formulas.size()])); - } - } - - /** - * Returns a formula that represents a universal quantification of this formula - * over the given declarations. The effect of this method is the same as calling - * this.quantify(ALL, decls). - * - * @return this.quantify(ALL, decls) - */ - public final Formula forAll(Decls decls) { - return quantify(ALL, decls); - } - - public final Formula forAll(Decls decls, Formula domain) { - return quantify(ALL, decls, domain); - } - - /** - * Returns a formula that represents an existential quantification of this - * formula over the given declarations. The effect of this method is the same as - * calling this.quantify(SOME, decls). - * - * @return this.quantify(SOME, decls) - */ - public final Formula forSome(Decls decls) { - return quantify(SOME, decls); - } - - public final Formula forSome(Decls decls, Formula domain) { - return quantify(SOME, decls, domain); - } - - /** - * Returns a quantification of this formula using the given quantifier over the - * specified declarations. - * - * @return {f: Formula | f.decls = decls and f.formula = this and f.quantifier = - * quantifer } - */ - public final Formula quantify(Quantifier quantifier, Decls decls) { - return quantify(quantifier, decls, Formula.TRUE); - } - - public final Formula quantify(Quantifier quantifier, Decls decls, Formula domain) { - return new QuantifiedFormula(quantifier, decls, domain, this); - } - - /** - * Returns the comprehension expression constructed from this formula and the - * given declarations. - * - * @requires all d: decls.decls[int] | decl.variable.arity = 1 and - * decl.multiplicity = ONE - * @return {e: Expression | e.decls = decls and e.formula = this } - */ - public final Expression comprehension(Decls decls) { - return new Comprehension(decls, this); - } - - /** - * Returns the if expression constructed from this formula and the specified - * then and else expressions. - * - * @return {e: Expression | e.condition = this and e.thenExpr = thenExpr and - * e.elseExpr = elseExpr} - */ - public final Expression thenElse(Expression thenExpr, Expression elseExpr) { - return new IfExpression(this, thenExpr, elseExpr); - } - - /** - * Returns the if expression constructed from this formula and the specified - * then and else integer expressions. - * - * @return {e: IntExpression | e.condition = this and e.thenExpr = thenExpr and - * e.elseExpr = elseExpr} - */ - public final IntExpression thenElse(IntExpression thenExpr, IntExpression elseExpr) { - return new IfIntExpression(this, thenExpr, elseExpr); - } - - /** - * Returns the negation of this formula. - * - * @return {f : NotFormula | f.formula = this } - */ - public final Formula not() { - return new NotFormula(this); - } - - public Formula fix(Formula condition) { - return new FixFormula(this, condition); - } - - /** - * Accepts the given visitor and returns the result. - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public abstract F accept(ReturnVisitor visitor); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IfExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IfExpression.java deleted file mode 100644 index bc1c44b04..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IfExpression.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * An expression whose value depends on the truth of a given condition. - * - * @specfield condition: Formula - * @specfield thenExpr: Expression - * @specfield elseExpr: Expression - * @invariant children = 0->condition + 1->thenExpr + 2->elseExpr - * @author Greg Dennis (gdennis@mit.edu) - * @author Emina Torlak - */ -public final class IfExpression extends Expression { - - private final Formula condition; - private final Expression thenExpr, elseExpr; - private final int arity; - - /** - * @ensures this.condition' = condition && this.thenExpr' = thenExpr && - * this.elseExpr' = elseExpr - * @throws IllegalArgumentException thenExpr.arity != elseExpr.arity - */ - IfExpression(Formula condition, Expression thenExpr, Expression elseExpr) { - if (thenExpr.arity() != elseExpr.arity()) { - throw new IllegalArgumentException("Arity mismatch: " + thenExpr + "::" + thenExpr.arity() + " and " + elseExpr + "::" + elseExpr.arity()); - } - this.condition = condition; - this.thenExpr = thenExpr; - this.elseExpr = elseExpr; - this.arity = thenExpr.arity(); - } - - /** - * Returns the if-condition. - * - * @return this.condition - */ - public Formula condition() { - return condition; - } - - /** - * Returns the then-expression. - * - * @return this.thenExpr - */ - public Expression thenExpr() { - return thenExpr; - } - - /** - * Returns the else-expression. - * - * @return this.elseExpr - */ - public Expression elseExpr() { - return elseExpr; - } - - /** - * Returns the arity of this. - * - * @return this.arity - */ - @Override - public int arity() { - return arity; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(if " + condition + " then " + thenExpr + " else " + elseExpr + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IfIntExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IfIntExpression.java deleted file mode 100644 index f0ccb9b4c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IfIntExpression.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * An int expression whose value depends on the truth of a condition. - * - * @specfield condition: Formula - * @specfield thenExpr: IntExpression - * @specfield elseExpr: IntExpression - * @invariant children = 0->condition + 1->thenExpr + 2->elseExpr - * @author Emina Torlak - */ -public final class IfIntExpression extends IntExpression { - - private final Formula condition; - private final IntExpression thenExpr, elseExpr; - - /** - * @ensures this.condition' = condition && this.thenExpr' = thenExpr && - * this.elseExpr' = elseExpr - */ - IfIntExpression(Formula condition, IntExpression thenExpr, IntExpression elseExpr) { - this.condition = condition; - this.thenExpr = thenExpr; - this.elseExpr = elseExpr; - } - - /** - * Returns the if-condition. - * - * @return this.condition - */ - public Formula condition() { - return condition; - } - - /** - * Returns the then-expression. - * - * @return this.thenExpr - */ - public IntExpression thenExpr() { - return thenExpr; - } - - /** - * Returns the else-expression. - * - * @return this.elseExpr - */ - public IntExpression elseExpr() { - return elseExpr; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(if " + condition + " then " + thenExpr + " else " + elseExpr + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntComparisonFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntComparisonFormula.java deleted file mode 100644 index 32b25c050..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntComparisonFormula.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.IntCompOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * An integer comparison formula, e.g. x = y, x <= y, etc. - * - * @specfield left: IntExpression - * @specfield right: IntExpression - * @specfield op: IntCompOperator - * @invariant children = 0->left + 1->right - * @author Emina Torlak - */ -public final class IntComparisonFormula extends Formula { - - private final IntCompOperator op; - private final IntExpression left, right; - - /** - * Constructs a new int comparison formula: left op right - * - * @ensures this.left' = left && this.right' = right && this.op' = op - * @throws NullPointerException left = null || right = null || op = null - */ - IntComparisonFormula(final IntExpression left, final IntCompOperator op, final IntExpression right) { - this.left = left; - this.right = right; - this.op = op; - } - - /** - * Returns the left child of this. - * - * @return this.left - */ - public IntExpression left() { - return left; - } - - /** - * Returns the right child of this. - * - * @return this.right - */ - public IntExpression right() { - return right; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public IntCompOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(" + left + " " + op + " " + right + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntConstant.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntConstant.java deleted file mode 100644 index 16f1647ac..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntConstant.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * An integer constant (literal). - * - * @specfield value: int - * @invariant no children - * @author Emina Torlak - */ -public final class IntConstant extends IntExpression { - - private final int value; - - /** - * Constructs an int constant. - * - * @ensures this.value' = value - */ - private IntConstant(int value) { - this.value = value; - } - - /** - * Returns an IntConstant corresponding to the given value. - * - * @return {c: IntConstant | c.value = value} - */ - public static IntConstant constant(int value) { - return new IntConstant(value); - } - - /** - * Returns this.value. - * - * @return this.value - */ - public int value() { - return value; - } - - /** - * Return true if o is an IntConstant with the same value as this. - * - * @return o in IntConstant && o.value = this.value - */ - @Override - public boolean equals(Object o) { - if (o == this) - return true; - else if (o instanceof IntConstant) - return value == ((IntConstant) o).value; - else - return false; - } - - /** - * Return this.value - * - * @return this.value - */ - @Override - public int hashCode() { - return value; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return String.valueOf(value); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntExpression.java deleted file mode 100644 index 5bec86376..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntExpression.java +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import static kodkod.ast.operator.IntCastOperator.BITSETCAST; -import static kodkod.ast.operator.IntCastOperator.INTCAST; -import static kodkod.ast.operator.IntCompOperator.EQ; -import static kodkod.ast.operator.IntCompOperator.GT; -import static kodkod.ast.operator.IntCompOperator.GTE; -import static kodkod.ast.operator.IntCompOperator.LT; -import static kodkod.ast.operator.IntCompOperator.LTE; -import static kodkod.ast.operator.IntCompOperator.NEQ; -import static kodkod.ast.operator.IntOperator.ABS; -import static kodkod.ast.operator.IntOperator.AND; -import static kodkod.ast.operator.IntOperator.DIVIDE; -import static kodkod.ast.operator.IntOperator.MINUS; -import static kodkod.ast.operator.IntOperator.MODULO; -import static kodkod.ast.operator.IntOperator.MULTIPLY; -import static kodkod.ast.operator.IntOperator.NEG; -import static kodkod.ast.operator.IntOperator.NOT; -import static kodkod.ast.operator.IntOperator.OR; -import static kodkod.ast.operator.IntOperator.PLUS; -import static kodkod.ast.operator.IntOperator.SGN; -import static kodkod.ast.operator.IntOperator.SHA; -import static kodkod.ast.operator.IntOperator.SHL; -import static kodkod.ast.operator.IntOperator.SHR; -import static kodkod.ast.operator.IntOperator.XOR; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import kodkod.ast.operator.IntCastOperator; -import kodkod.ast.operator.IntCompOperator; -import kodkod.ast.operator.IntOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; - -/** - * A Node whose value is an integer rather than a relational expression. - * - * @author Emina Torlak - */ -public abstract class IntExpression extends Node { - - /** - * Constructs an IntExpression. - */ - IntExpression() {} - - /** - * Returns a formula stating that the given int expression and this have the - * same value. The effect of this method is the same as calling this.compare(EQ, - * intExpr). - * - * @return this.compare(EQ, intExpr) - */ - public final Formula eq(IntExpression intExpr) { - return this.compare(EQ, intExpr); - } - - public final Formula neq(IntExpression intExpr) { - return this.compare(NEQ, intExpr); - } - - /** - * Returns a formula stating that the value of this int expression is less than - * the value of the given int expression The effect of this method is the same - * as calling this.compare(LT, intExpr). - * - * @return this.compare(LT, intExpr) - */ - public final Formula lt(IntExpression intExpr) { - return this.compare(LT, intExpr); - } - - /** - * Returns a formula stating that the value of this int expression is less than - * or equal to the value of the given int expression The effect of this method - * is the same as calling this.compare(LTE, intExpr). - * - * @return this.compare(LTE, intExpr) - */ - public final Formula lte(IntExpression intExpr) { - return this.compare(LTE, intExpr); - } - - /** - * Returns a formula stating that the value of this int expression is greater - * than the value of the given int expression The effect of this method is the - * same as calling this.compare(GT, intExpr). - * - * @return this.compare(GT, intExpr) - */ - public final Formula gt(IntExpression intExpr) { - return this.compare(GT, intExpr); - } - - /** - * Returns a formula stating that the value of this int expression is greater - * than or equal to the value of the given int expression The effect of this - * method is the same as calling this.compare(GTE, intExpr). - * - * @return this.compare(GTE, intExpr) - */ - public final Formula gte(IntExpression intExpr) { - return this.compare(GTE, intExpr); - } - - /** - * Returns a formula comparing this and the given integer expression using the - * specified operator. - * - * @return {f: Formula | f.left = this and f.right = intExpr and f.op = op } - */ - public Formula compare(IntCompOperator op, IntExpression intExpr) { - if (op == null || intExpr == null) - throw new NullPointerException(); - return new IntComparisonFormula(this, op, intExpr); - } - - /** - * Returns an integer expression that is the sum of all values that this integer - * expression can take given the provided declarations. - * - * @return {e: IntExpression | e.decls = decls and e.intExpr = this } - */ - public final IntExpression sum(Decls decls) { - return new SumExpression(decls, this); - } - - /** - * Returns an IntExpression that represents the sum of this and the given int - * node. The effect of this method is the same as calling this.compose(PLUS, - * intExpr). - * - * @return this.compose(PLUS, intExpr) - */ - public final IntExpression plus(IntExpression intExpr) { - return compose(PLUS, intExpr); - } - - /** - * Returns an IntExpression that represents the difference between this and the - * given int node. The effect of this method is the same as calling - * this.compose(MINUS, intExpr). - * - * @return this.compose(MINUS, intExpr) - */ - public final IntExpression minus(IntExpression intExpr) { - return compose(MINUS, intExpr); - } - - /** - * Returns an IntExpression that represents the product of this and the given - * int node. The effect of this method is the same as calling - * this.compose(MULTIPLY, intExpr). - * - * @return this.compose(MULTIPLY, intExpr) - */ - public final IntExpression multiply(IntExpression intExpr) { - return compose(MULTIPLY, intExpr); - } - - /** - * Returns an IntExpression that represents the quotient of the division between - * this and the given int node. The effect of this method is the same as calling - * this.compose(DIVIDE, intExpr). - * - * @return this.compose(DIVIDE, intExpr) - */ - public final IntExpression divide(IntExpression intExpr) { - return compose(DIVIDE, intExpr); - } - - /** - * Returns an IntExpression that represents the remainder of the division - * between this and the given int node. The effect of this method is the same as - * calling this.compose(MODULO, intExpr). - * - * @return this.compose(MODULO, intExpr) - */ - public final IntExpression modulo(IntExpression intExpr) { - return compose(MODULO, intExpr); - } - - /** - * Returns an IntExpression that represents the bitwise AND of this and the - * given int node. The effect of this method is the same as calling - * this.compose(AND, intExpr). - * - * @return this.compose(AND, intExpr) - */ - public final IntExpression and(IntExpression intExpr) { - return compose(AND, intExpr); - } - - /** - * Returns an IntExpression that represents the bitwise OR of this and the given - * int node. The effect of this method is the same as calling this.compose(OR, - * intExpr). - * - * @return this.compose(OR, intExpr) - */ - public final IntExpression or(IntExpression intExpr) { - return compose(OR, intExpr); - } - - /** - * Returns an IntExpression that represents the bitwise XOR of this and the - * given int node. The effect of this method is the same as calling - * this.compose(XOR, intExpr). - * - * @return this.compose(XOR, intExpr) - */ - public final IntExpression xor(IntExpression intExpr) { - return compose(XOR, intExpr); - } - - /** - * Returns an IntExpression that represents the left shift of this by the given - * int node. The effect of this method is the same as calling this.compose(SHL, - * intExpr). - * - * @return this.compose(SHL, intExpr) - */ - public final IntExpression shl(IntExpression intExpr) { - return compose(SHL, intExpr); - } - - /** - * Returns an IntExpression that represents the right shift of this and the - * given int node, with zero extension. The effect of this method is the same as - * calling this.compose(SHR, intExpr). - * - * @return this.compose(SHR, intExpr) - */ - public final IntExpression shr(IntExpression intExpr) { - return compose(SHR, intExpr); - } - - /** - * Returns an IntExpression that represents the right shift of this and the - * given int node, with sign extension. The effect of this method is the same as - * calling this.compose(SHA, intExpr). - * - * @return this.compose(SHA, intExpr) - */ - public final IntExpression sha(IntExpression intExpr) { - return compose(SHA, intExpr); - } - - /** - * Returns an expression that combines this and the given integer expression - * using the specified operator. - * - * @requires op.binary() - * @return {e: IntExpression | e.left = this and e.right = intExpr and e.op = op - * } - */ - public final IntExpression compose(IntOperator op, IntExpression intExpr) { - if (op == null || intExpr == null) - throw new NullPointerException(); - return new BinaryIntExpression(this, op, intExpr); - } - - /** - * Returns the sum of the given int expressions. The effect of this method is - * the same as calling compose(PLUS, intExprs). - * - * @return compose(PLUS, intExprs) - */ - public static IntExpression plus(IntExpression... intExprs) { - return compose(PLUS, intExprs); - } - - /** - * Returns the plus of the given int expressions. The effect of this method is - * the same as calling compose(PLUS, intExprs). - * - * @return compose(PLUS, intExprs) - */ - public static IntExpression plus(Collection< ? extends IntExpression> intExprs) { - return compose(PLUS, intExprs); - } - - /** - * Returns the product of the given int expressions. The effect of this method - * is the same as calling compose(MULTIPLY, intExprs). - * - * @return compose(MULTIPLY, intExprs) - */ - public static IntExpression multiply(IntExpression... intExprs) { - return compose(MULTIPLY, intExprs); - } - - /** - * Returns the product of the given int expressions. The effect of this method - * is the same as calling compose(MULTIPLY, intExprs). - * - * @return compose(MULTIPLY, intExprs) - */ - public static IntExpression multiply(Collection< ? extends IntExpression> intExprs) { - return compose(MULTIPLY, intExprs); - } - - /** - * Returns the bitwise and of the given int expressions. The effect of this - * method is the same as calling compose(AND, intExprs). - * - * @return compose(AND, intExprs) - */ - public static IntExpression and(IntExpression... intExprs) { - return compose(AND, intExprs); - } - - /** - * Returns the bitwise and of the given int expressions. The effect of this - * method is the same as calling compose(AND, intExprs). - * - * @return compose(AND, intExprs) - */ - public static IntExpression and(Collection< ? extends IntExpression> intExprs) { - return compose(AND, intExprs); - } - - /** - * Returns the bitwise or of the given int expressions. The effect of this - * method is the same as calling compose(OR, intExprs). - * - * @return compose(OR, intExprs) - */ - public static IntExpression or(IntExpression... intExprs) { - return compose(OR, intExprs); - } - - /** - * Returns the bitwise or of the given int expressions. The effect of this - * method is the same as calling compose(OR, intExprs). - * - * @return compose(OR, intExprs) - */ - public static IntExpression or(Collection< ? extends IntExpression> intExprs) { - return compose(OR, intExprs); - } - - /** - * Returns the composition of the given int expressions using the given - * operator. - * - * @requires intExprs.length = 2 => op.binary(), intExprs.length > 2 => - * op.nary() - * @return intExprs.length=1 => intExprs[0] else {e: IntExpression | e.children - * = intExprs and e.op = this } - */ - public static IntExpression compose(IntOperator op, IntExpression... intExprs) { - switch (intExprs.length) { - case 0 : - throw new IllegalArgumentException("Expected at least one argument: " + Arrays.toString(intExprs)); - case 1 : - return intExprs[0]; - case 2 : - return new BinaryIntExpression(intExprs[0], op, intExprs[1]); - default : - return new NaryIntExpression(op, Containers.copy(intExprs, new IntExpression[intExprs.length])); - } - } - - /** - * Returns the composition of the given int expressions using the given - * operator. - * - * @requires intExprs.length = 2 => op.binary(), intExprs.length > 2 => - * op.nary() - * @return intExprs.size() = 1 => intExprs.iterator().next() else {e: - * IntExpression | e.children = intExprs.toArray() and e.op = this } - */ - public static IntExpression compose(IntOperator op, Collection< ? extends IntExpression> intExprs) { - switch (intExprs.size()) { - case 0 : - throw new IllegalArgumentException("Expected at least one argument: " + intExprs); - case 1 : - return intExprs.iterator().next(); - case 2 : - final Iterator< ? extends IntExpression> itr = intExprs.iterator(); - return new BinaryIntExpression(itr.next(), op, itr.next()); - default : - return new NaryIntExpression(op, intExprs.toArray(new IntExpression[intExprs.size()])); - } - } - - /** - * Returns an IntExpression that represents the negation of this int expression. - * The effect of this method is the same as calling this.apply(NEG). - * - * @return this.apply(NEG) - */ - public final IntExpression negate() { - return apply(NEG); - } - - /** - * Returns an IntExpression that represents the bitwise negation of this int - * expression. The effect of this method is the same as calling this.apply(NOT). - * - * @return this.apply(NOT) - */ - public final IntExpression not() { - return apply(NOT); - } - - /** - * Returns an IntExpression that represents the absolute value of this int - * expression. The effect of this method is the same as calling this.apply(ABS). - * - * @return this.apply(ABS) - */ - public final IntExpression abs() { - return apply(ABS); - } - - /** - * Returns an IntExpression that represents the sign of this int expression. The - * effect of this method is the same as calling this.apply(SGN). - * - * @return this.apply(SGN) - */ - public final IntExpression signum() { - return apply(SGN); - } - - /** - * Returns an expression that represents the application of the given unary - * operator to this integer expression. - * - * @requires op.unary() - * @return {e: IntExpression | e.op = op and e.intExpr = this } - */ - public final IntExpression apply(IntOperator op) { - return new UnaryIntExpression(op, this); - } - - /** - * Returns an expression whose meaning is the singleton set containing the atom - * that represents the integer given by this integer expression. The effect of - * this method is the same as calling this.cast(INTCAST). - * - * @return this.cast(INTCAST) - */ - public final Expression toExpression() { - return cast(INTCAST); - } - - /** - * Returns an expression whose meaning is the set containing the atoms that - * represent the powers of 2 (bits) present in this integer expression. The - * effect of this method is the same as calling this.cast(BITSETCAST). - * - * @return this.cast(BITSETCAST) - */ - public final Expression toBitset() { - return cast(BITSETCAST); - } - - /** - * Returns an expression that is the relational representation of this integer - * expression specified by the given operator. - * - * @return an expression that is the relational representation of this integer - * expression specified by the given operator. - */ - public final Expression cast(IntCastOperator op) { - if (op == null) - throw new NullPointerException(); - return new IntToExprCast(this, op); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public abstract I accept(ReturnVisitor visitor); - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public abstract void accept(VoidVisitor visitor); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntToExprCast.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntToExprCast.java deleted file mode 100644 index a9928eece..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/IntToExprCast.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.IntCastOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * Represents the conversion from an {@link kodkod.ast.IntExpression int - * expression } to an {@link kodkod.ast.Expression expression}. The meaning of - * the resulting expression is a singleton set containing the atom that - * represents the integer given by the wrapped int expression, if the conversion - * operator is INTCAST. Otherwise, the meaning is the set of powers of 2 that - * make up the given integer expression. - * - * @specfield intExpr: IntExpression - * @specfield op: IntCastOperator - * @invariant children = 0->intExpr - * @invariant arity = 1 - * @author Emina Torlak - */ -public final class IntToExprCast extends Expression { - - private final IntExpression intExpr; - private final IntCastOperator op; - - /** - * Constructs a new IntToExprCast. - * - * @requires intExpr != null && op != null - * @ensures this.intexpr' = intExpr - */ - IntToExprCast(IntExpression intExpr, IntCastOperator op) { - this.intExpr = intExpr; - this.op = op; - } - - /** - * Returns 1. - * - * @return 1 - */ - @Override - public int arity() { - return 1; - } - - /** - * Returns this.intExpr. - * - * @return this.intExpr - */ - public IntExpression intExpr() { - return intExpr; - } - - /** - * Returns this.op - * - * @return this.op - */ - public final IntCastOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return op + "[" + intExpr + "]"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/LeafExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/LeafExpression.java deleted file mode 100644 index 057a5ec85..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/LeafExpression.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -/** - * An expression with no children. {@link kodkod.ast.Relation Relation} and - * {@link kodkod.ast.Variable Variable} are examples of leaf exressions. Two - * leaf expressions are equal if and only if they refer to the same object. That - * is, leaf1.eauls(leaf2) <=> leaf1 == leaf2. A leaf has a name, which is - * basically a comment for the purpose of printing, viewing, etc. The name has - * no meaning otherwise. - * - * @specfield name: String - * @specfield arity: int - * @specfield no children - * @author Emina Torlak - */ -public abstract class LeafExpression extends Expression { - - private final int arity; - private final String name; - - /** - * Constructs a leaf with the specified name and arity - * - * @ensures this.name' = name && this.arity' = arity - * @throws IllegalArgumentException arity < 1 - */ - LeafExpression(String name, int arity) { - if (arity < 1) { - throw new IllegalArgumentException("Arity must be at least 1: " + arity); - } - this.name = name; - this.arity = arity; - } - - /** - * Returns the arity of this leaf. - * - * @return this.arity - */ - @Override - public final int arity() { - return arity; - } - - /** - * Returns the name of this leaf. - * - * @return this.name - */ - public final String name() { - return name; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return name; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/MultiplicityFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/MultiplicityFormula.java deleted file mode 100644 index b0d419185..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/MultiplicityFormula.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A multiplicity formula, e.g. some x - * - * @specfield expression: Expression - * @specfield multiplicity: (ONE + LONE + SOME + NO) - * @invariant children = 0->expression - * @author Emina Torlak - */ -public final class MultiplicityFormula extends Formula { - - private final Expression expression; - private final Multiplicity multiplicity; - - /** - * Constructs a new multiplicity formula: multiplicity expression - * - * @ensures this.expression' = expression && this.multiplicity' = multiplicity - * @throws NullPointerException multiplicity = null || expression = null - * @throws IllegalArgumentException multiplicity = SET - */ - MultiplicityFormula(Multiplicity multiplicity, Expression expression) { - if (multiplicity == Multiplicity.SET) - throw new IllegalArgumentException("invalid expression mulitplicity: SET"); - if (multiplicity == null || expression == null) - throw new NullPointerException("null arg"); - this.multiplicity = multiplicity; - this.expression = expression; - } - - /** - * Returns the mulitplicity of this. - * - * @return this.multiplicity - */ - public Multiplicity multiplicity() { - return multiplicity; - } - - /** - * Returns the expression of this. - * - * @return this.expression - */ - public Expression expression() { - return expression; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return multiplicity + " " + expression; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryExpression.java deleted file mode 100644 index 11220856f..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryExpression.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import java.util.Iterator; - -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; - -/** - * A relational {@linkplain kodkod.ast.Expression expression} with more than two - * children, composed with an nary {@linkplain ExprOperator operator}. - * - * @specfield op: ExprOperator - * @invariant op.nary() - * @invariant #children > 2 - * @author Emina Torlak - */ -public final class NaryExpression extends Expression implements Iterable { - - private final ExprOperator op; - private final int arity; - private final Expression[] children; - - /** - * Constructs a new associative expression: op(children) - * - * @requires children array is not modified while in use by this associative - * expression - * @requires some op.op[children] - * @ensures this.children' = children && this.op' = op - */ - NaryExpression(ExprOperator op, Expression[] children) { - assert children.length > 2; - if (!op.nary()) - throw new IllegalArgumentException("Cannot construct an nary expression using the non-nary operator " + op); - - this.op = op; - this.children = children; - - switch (op) { - case UNION : - case INTERSECTION : - case OVERRIDE : - this.arity = children[0].arity(); - for (int i = 1; i < children.length; i++) { - if (children[i].arity() != arity) - throw new IllegalArgumentException("Incompatible arities: " + children[0] + " and " + children[i]); - } - break; - case PRODUCT : - int sum = 0; - for (Expression child : children) { - sum += child.arity(); - } - this.arity = sum; - break; - default : - throw new IllegalArgumentException("Unknown associative operator: " + op); - } - } - - /** - * Returns the arity of this associative expression. - * - * @return this.arity - * @see kodkod.ast.Expression#arity() - */ - @Override - public final int arity() { - return arity; - } - - /** - * Returns this.op. - * - * @return this.op - */ - public ExprOperator op() { - return op; - } - - /** - * Returns the number of children of this expression. - * - * @return #this.children - */ - public int size() { - return children.length; - } - - /** - * Returns the ith child of this associative expression. - * - * @requires 0 <= i < #this.children - * @return this.children[i] - */ - public Expression child(int i) { - return children[i]; - } - - /** - * Returns an iterator over this expression's children, in the increasing order - * of indices. - * - * @return an iterator over this expression's children, in the increasing order - * of indices. - */ - @Override - public Iterator iterator() { - return Containers.iterate(children); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - final StringBuilder s = new StringBuilder("("); - s.append(child(0)); - for (int i = 1, size = size(); i < size; i++) { - s.append(" "); - s.append(op); - s.append(" "); - s.append(child(i)); - } - s.append(")"); - return s.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryFormula.java deleted file mode 100644 index 33e11cdb3..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryFormula.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import java.util.Iterator; - -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; - -/** - * A {@linkplain kodkod.ast.Formula formula} with more than two children, - * composed with an nary {@linkplain FormulaOperator operator}. - * - * @specfield op: FormulaOperator - * @invariant op.nary() - * @invariant #children > 2 - * @author Emina Torlak - */ -public final class NaryFormula extends Formula implements Iterable { - - private final FormulaOperator op; - private final Formula[] children; - - /** - * Constructs a new composite Formula: op(children) - * - * @requires children array is not modified while in use by this composite - * Formula - * @requires some op.op[children] - * @ensures this.children' = children && this.op' = op - */ - NaryFormula(FormulaOperator op, Formula[] children) { - assert children.length > 2; - if (!op.nary()) - throw new IllegalArgumentException("Cannot construct an nary formula using the non-nary operator " + op); - this.op = op; - this.children = children; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public FormulaOperator op() { - return op; - } - - /** - * Returns the number of children of this formula. - * - * @return #this.children - */ - public int size() { - return children.length; - } - - /** - * Returns the ith child of this formula. - * - * @requires 0 <= i < #this.children - * @return this.children[i] - */ - public Formula child(int i) { - return children[i]; - } - - /** - * Returns an iterator over this formula's children, in the increasing order of - * indices. - * - * @return an iterator over this formula's children, in the increasing order of - * indices. - */ - @Override - public Iterator iterator() { - return Containers.iterate(children); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - final StringBuilder s = new StringBuilder("("); - s.append(child(0)); - for (int i = 1, size = size(); i < size; i++) { - s.append(" "); - s.append(op); - s.append(" "); - s.append(child(i)); - } - s.append(")"); - return s.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryIntExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryIntExpression.java deleted file mode 100644 index b0e33ca1c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NaryIntExpression.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import java.util.Iterator; - -import kodkod.ast.operator.IntOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; - -/** - * A {@linkplain kodkod.ast.IntExpression int expression} with more than two - * children, composed with an nary {@linkplain IntOperator operator}. - * - * @specfield op: IntOperator - * @invariant op.nary() - * @invariant #children > 2 - * @author Emina Torlak - */ -public final class NaryIntExpression extends IntExpression implements Iterable { - - private final IntOperator op; - private final IntExpression[] children; - - /** - * Constructs a new composite IntExpression: op(children) - * - * @requires children array is not modified while in use by this composite - * IntExpression - * @requires some op.op[children] - * @ensures this.children' = children && this.op' = op - */ - NaryIntExpression(IntOperator op, IntExpression[] children) { - assert children.length > 2; - if (!op.nary()) - throw new IllegalArgumentException("Cannot construct an nary int expression using the non-nary operator " + op); - this.op = op; - this.children = children; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public IntOperator op() { - return op; - } - - /** - * Returns the number of children of this int expression. - * - * @return #this.children - */ - public int size() { - return children.length; - } - - /** - * Returns the ith child of this int expression. - * - * @requires 0 <= i < #this.children - * @return this.children[i] - */ - public IntExpression child(int i) { - return children[i]; - } - - /** - * Returns an iterator over this int expression's children, in the increasing - * order of indices. - * - * @return an iterator over this int expression's children, in the increasing - * order of indices. - */ - @Override - public Iterator iterator() { - return Containers.iterate(children); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - final StringBuilder s = new StringBuilder("("); - s.append(child(0)); - for (int i = 1, size = size(); i < size; i++) { - s.append(" "); - s.append(op); - s.append(" "); - s.append(child(i)); - } - s.append(")"); - return s.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Node.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Node.java deleted file mode 100644 index b882db543..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Node.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A node in the abstract syntax tree (DAG). A node can accept a ReturnVisitor - * and have a sequence of zero or more children. - * - * @specfield children: int ->lone Node - * @specfield components: set Node - * @invariant children.Node = { i: int | 0 <= i < #children } - * @invariant components= children[int] - * @author Emina Torlak - */ -public abstract class Node { - - /** - * Accepts the given visitor and returns the result of the visit (i.e. the - * result of the call visitor.visit(this)) - * - * @return the result of being visited by the given visitor - * @throws NullPointerException visitor = null - */ - public abstract Object accept(ReturnVisitor visitor); - - /** - * Accepts the given void visitor by calling visitor.visit(this). - * - * @throws NullPointerException visitor = null - */ - public abstract void accept(VoidVisitor visitor); - - /** - * Returns a string representation of this node. For a pretty-printed string, - * use {@linkplain kodkod.util.nodes.PrettyPrinter}. - * - * @return a string representation of this node - * @see kodkod.util.nodes.PrettyPrinter - */ - @Override - public abstract String toString(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NotFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NotFormula.java deleted file mode 100644 index 40acc8883..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/NotFormula.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * Negation of a {@link kodkod.ast.Formula formula}. - * - * @specfield formula: Formula - * @invariant children = 0->formula - * @author Emina Torlak - */ -public final class NotFormula extends Formula { - - private final Formula formula; - - /** - * Constructs a new formula: !formula - * - * @ensures this.formula' = formula - * @throws NullPointerException formula = null - */ - NotFormula(Formula child) { - if (child == null) - throw new NullPointerException("formula"); - this.formula = child; - } - - /** - * Returns this.formula. - * - * @return this.formula - */ - public Formula formula() { - return formula; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "!" + formula; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ProjectExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ProjectExpression.java deleted file mode 100644 index e4a2f3bd5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/ProjectExpression.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import java.util.Arrays; -import java.util.Iterator; - -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; - -/** - * A general projection expression. For example, let [[e]] = {<a, b, c>, - * <d, e, f>, <d, g, f>}. Then, project(e, 1, 3) = {<a, c>, - * <d, f>} and project(e, 1, 1, 2) = {<a, a, b>, <d, d, e>, - * <d, d, g>}. - * - * @specfield expression: Expression - * @specfield columns: [0..arity) -> one IntExpression - * @invariant children = 0->expression + { i: int, e: IntExpression | - * columns[i-1] = e } - * @author Emina Torlak - */ -public final class ProjectExpression extends Expression { - - private final Expression expr; - private final IntExpression[] columns; - - /** - * Constructs a new projection expression using the given expr and columns. - * - * @ensures this.expression' = expr && this.indices' = columns - */ - ProjectExpression(Expression expr, IntExpression... columns) { - if (columns.length == 0) - throw new IllegalArgumentException("No columns specified for projection."); - this.expr = expr; - this.columns = new IntExpression[columns.length]; - System.arraycopy(columns, 0, this.columns, 0, columns.length); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#arity() - */ - @Override - public int arity() { - return columns.length; - } - - /** - * Returns this.expression. - * - * @return this.expression - */ - public Expression expression() { - return expr; - } - - /** - * Returns an iterator over this.columns, in proper sequence. - * - * @return an iterator over this.columns, in proper sequence - */ - public Iterator columns() { - return Containers.iterate(columns); - } - - /** - * Returns the ith column. - * - * @requires 0 <= i < this.arity - * @return this.columns[i] - */ - public IntExpression column(int i) { - return columns[i]; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return expr.toString() + Arrays.toString(columns); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/QuantifiedFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/QuantifiedFormula.java deleted file mode 100644 index 55c930f46..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/QuantifiedFormula.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A quantified formula. - * - * @specfield decls: Declarations - * @specfield formula: Formula - * @specfield quantifier: Quantifier - * @invariant children = 0->decls + 1->formula - * @author Emina Torlak - */ -public final class QuantifiedFormula extends Formula { - - private final Quantifier quantifier; - private final Decls decls; - private final Formula domain; - private final Formula body; - - /** - * Constructs a new quantified formula: quantifier decls | formula - * - * @ensures this.quantifier' = quantifier && this.decls' = decls && - * this.formula' = formula - * @throws NullPointerException quantifier = null || decls = null || formula = - * null - */ - QuantifiedFormula(Quantifier quantifier, Decls declarations, Formula domain, Formula body) { - if (quantifier == null || declarations == null || domain == null || body == null) { - throw new NullPointerException("null arg"); - } - this.quantifier = quantifier; - this.decls = declarations; - this.domain = domain; - this.body = body; - } - - /** - * Returns this.formula. - * - * @return this.formula - */ - public Formula domain() { - return domain; - } - - /** - * Returns this.body. - * - * @return this.body - */ - public Formula body() { - return body; - } - - public Formula formula() { - if (domain == Formula.TRUE) - return body; - if (quantifier == Quantifier.ALL) - return domain.implies(body); - else - return domain.and(body); - } - - /** - * Returns this.decls. - * - * @return this.decls - */ - public Decls decls() { - return decls; - } - - /** - * Returns this.quantifier. - * - * @return this.quantifier - */ - public Quantifier quantifier() { - return quantifier; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - if (domain != Formula.TRUE) - return "(" + quantifier + " " + decls + " | " + domain + " | " + body + ")"; - else - return "(" + quantifier + " " + decls + " | " + formula() + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Relation.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Relation.java deleted file mode 100644 index b830471ad..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Relation.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A relation is a leaf expression. Two relations are the same if and only if - * they refer to the same object. That is, r1.equals(r2) <=> r1 == r2. Each - * variable has a name, which is a comment for the purpose of printing, viewing, - * etc. The name has no meaning otherwise. - *

- * Four methods for creating commonly used predicates over binary relations are - * provided: {@link #function(Expression, Expression)}, - * {@link #partialFunction(Expression, Expression)}, {@link #acyclic()}, and - * {@link #totalOrder(Relation, Relation, Relation)}. Using these methods to - * generate desired predicates will result in faster constraint solving than - * creating the same predicates via other API calls. - *

- * - * @specfield name: String - * @specfield arity: int - * @invariant no children - * @author Emina Torlak - */ -public class Relation extends LeafExpression { - - /** - * Constructs a relation with the specified name and arity. - * - * @ensures this.name' = name && this.arity' = arity - * @throws IllegalArgumentException arity < 1 - */ - protected Relation(String name, int arity) { - super(name, arity); - } - - /** - * Returns a new relation with the given name and arity. - * - * @return {r: Relation | r.arity = arity && r.name = name } - * @throws IllegalArgumentException arity < 1 - */ - public static Relation nary(String name, int arity) { - return new Relation(name, arity); - } - - /** - * TODO - * - * @param name - * @return - */ - public static AtomRelation atom(String name) { - return new AtomRelation(name, 1); - } - - public static Relation skolem(String name, int arity, Variable forVariable, Decl decl, Quantifier quant) { - return new SkolemRelation(name, arity, forVariable, decl, quant); - } - - /** - * Returns a new unary relation with the given name. The effect of this method - * is the same as calling Relation.nary(name,1). - * - * @return {r: Relation | r.arity = 1 && r.name = name } - */ - public static Relation unary(String name) { - return new Relation(name, 1); - } - - /** - * Returns a new binary relation with the given name. The effect of this method - * is the same as calling Relation.nary(name,2). - * - * @return {r: Relation | r.arity = 2 && r.name = name } - */ - public static Relation binary(String name) { - return new Relation(name, 2); - } - - /** - * Returns a ternary relation with the specified name. - * - * @return {r: Relation | r.name = name && r.arity = 3} - */ - public static Relation ternary(String name) { - return new Relation(name, 3); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * Returns a formula stating that this relation is acyclic. - * - * @return {f: Formula | f <=> no ^this & iden} - * @throws IllegalArgumentException this.arity != 2 - */ - public Formula acyclic() { - return new RelationPredicate.Acyclic(this); - } - - /** - * Returns a formula stating that this relation is a total function with the - * specified domain and range. - * - * @return {f: Formula | f <=> this in domain->range && all v: domain | one - * v.this } - * @throws NullPointerException domain = null || range = null - * @throws IllegalArgumentException domain.arity != 1 || range.arity != 1 - * @throws IllegalArgumentException this.arity != 2 - */ - public Formula function(Expression domain, Expression range) { - return new RelationPredicate.Function(this, domain, Multiplicity.ONE, range); - } - - /** - * Returns a formula stating that this relation is a partial function with the - * specified domain and range. - * - * @return {f: Formula | f <=> this in domain->range && all v: domain | lone - * v.this } - * @throws NullPointerException domain = null || range = null - * @throws IllegalArgumentException domain.arity != 1 || range.arity != 1 - * @throws IllegalArgumentException this.arity != 2 - */ - public Formula partialFunction(Expression domain, Expression range) { - return new RelationPredicate.Function(this, domain, Multiplicity.LONE, range); - } - - /** - * Returns a formula stating that this relation imposes a total ordering over - * the atoms in the set ordered, and that thet first and last - * elements in the ordering are given by the relations first and - * last. - * - * @return {f: Formula | f <=> one first && one last && last in ordered && no - * this.first && no last.this && ordered = first.*this && all e: ordered - * - last | one e.this } - * @throws NullPointerException any of the arguments are null - * @throws IllegalArgumentException any of the argument relations' arities are - * greater than one - * @throws IllegalArgumentException this.arity != 2 - */ - public Formula totalOrder(Relation ordered, Relation first, Relation last) { - return new RelationPredicate.TotalOrdering(this, ordered, first, last); - } - - public boolean isAtom() { - return false; - } - - public boolean isSkolem() { - return false; - } - - public Variable getSkolemVar() { - return null; - } - - public Decl getSkolemVarDecl() { - return null; - } - - public Expression getSkolemVarDomain() { - return null; - } - - public Quantifier getSkolemVarQuant() { - return null; - } -} - -class AtomRelation extends Relation { - - public AtomRelation(String name, int arity) { - super(name, arity); - } - - @Override - public boolean isAtom() { - return true; - } - - @Override - public String toString() { - return "$$" + name() + "$$"; - } -} - -class SkolemRelation extends Relation { - - private final Variable forVariable; - private final Decl skolemVarDecl; - private final Quantifier quant; - - public SkolemRelation(String name, int arity, Variable forVariable, Decl decl, Quantifier quant) { - super(name, arity); - this.forVariable = forVariable; - this.skolemVarDecl = decl; - this.quant = quant; - } - - @Override - public boolean isSkolem() { - return true; - } - - @Override - public final Variable getSkolemVar() { - return forVariable; - } - - @Override - public final Decl getSkolemVarDecl() { - return skolemVarDecl; - } - - @Override - public final Expression getSkolemVarDomain() { - return skolemVarDecl.expression(); - } - - @Override - public final Quantifier getSkolemVarQuant() { - return quant; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/RelationPredicate.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/RelationPredicate.java deleted file mode 100644 index a3abaa4e8..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/RelationPredicate.java +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * Represents common predicates on relations; e.g. predicates stating that a - * relation is a total function, partial function, acyclic, or a total ordering - * over a set of atoms. - * - * @specfield relation: Relation - * @specfield name: Name // name of the predicate - * @invariant relation.arity = 2 - * @author Emina Torlak - */ -public abstract class RelationPredicate extends Formula { - - private final Relation relation; - - /** - * Constructs a new relation predicate for the given relation. - * - * @throws NullPointerException relation = null - * @throws IllegalArgumentException relation.arity != 2 - */ - private RelationPredicate(Relation relation) { - if (relation.arity() != 2) - throw new IllegalArgumentException("invalid arity: " + relation.arity()); - this.relation = relation; - } - - /** - * Returns the relation to which this predicate applies. - * - * @return this.relation - */ - public Relation relation() { - return relation; - } - - /** - * Returns the name of this predicate. - * - * @return this.name - */ - public abstract Name name(); - - /** - * Turns this predicate into explicit constraiants. - * - * @return {f: Formula - RelationPredicate | f <=> this } - */ - public abstract Formula toConstraints(); - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Formula#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public F accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * Enumerates built-in predicates. - */ - public static enum Name { - /** Function predicate. */ - FUNCTION, - /** Partial function predicate. */ - // PARTIAL_FUNCTION, - /** Acyclic predicate. */ - ACYCLIC, - /** Total ordering predicate. */ - TOTAL_ORDERING - } - - /** - * Represents the acyclic predicate. The predicate states that the given - * relation is acyclic. - * - * @specfield relation: Relation - * @invariant name = ACYCLIC - * @invariant children = 0->relation - * @author Emina Torlak - */ - public static final class Acyclic extends RelationPredicate { - - /** - * Constructs a new acyclic predicate over the given relation. - * - * @ensures this.relation' = relation && this.name' = ACYCLIC - * @throws IllegalArgumentException relation.arity != 2 - */ - Acyclic(Relation relation) { - super(relation); - } - - /** - * Returns the name of this predicate. - * - * @return ACYCLIC - */ - @Override - public Name name() { - return Name.ACYCLIC; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.RelationPredicate#toConstraints() - */ - @Override - public Formula toConstraints() { - return relation().closure().intersection(Expression.IDEN).no(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return name() + "(" + relation() + ")"; - } - } - - /** - * Represents the function predicate. The predicate states that the given - * relation is a total or partial function with the specified - * domain and range. - * - * @specfield relation: Relation - * @specfield domain, range: Expression - * @specfield targetMult: ONE + LONE - * @invariant name = FUNCTION - * @invariant domain.arity = range.arity = 1 - * @invariant children = 0->relation + 1->domain + 2->range - * @author Emina Torlak - */ - public static final class Function extends RelationPredicate { - - private final Expression domain, range; - private final Multiplicity targetMult; - - /** - * Constructs a new function predicate over the given relation and domain, with - * the specified target multiplicity. - * - * @ensures this.name' = FUNCTION && this.relation' = relation && this.domain' = - * domain && this.range' = range - * @throws IllegalArgumentException relation.arity != 2 || domain.arity != 1 || - * range.arity != 1 || targetMult !in ONE + LONE - */ - Function(Relation relation, Expression domain, Multiplicity targetMult, Expression range) { - super(relation); - if (targetMult != Multiplicity.ONE && targetMult != Multiplicity.LONE) - throw new IllegalArgumentException("invalid target multiplicity for a function: " + targetMult); - if (domain.arity() != 1 || range.arity() != 1) - throw new IllegalArgumentException("invalid arity: " + domain + " or " + range); - this.targetMult = targetMult; - this.domain = domain; - this.range = range; - } - - /** - * Returns the name of this predicate. - * - * @return this.name - */ - @Override - public Name name() { - return Name.FUNCTION; - } - - /** - * Returns the target multiplicity of the function represented by this.relation. - * - * @return this.targetMult - */ - public Multiplicity targetMult() { - return targetMult; - } - - /** - * Returns the domain of this.relation. - * - * @return this.domain - */ - public Expression domain() { - return domain; - } - - /** - * Returns the range of this.relation. - * - * @return this.range - */ - public Expression range() { - return range; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.RelationPredicate#toConstraints() - */ - @Override - public Formula toConstraints() { - // relation in domain->range - final Formula domainConstraint = relation().in(domain.product(range)); - // all v: domain | targetMult v.relation - final Variable v = Variable.unary("v" + relation().name()); - final Formula funConstraint = v.join(relation()).apply(targetMult).forAll(v.oneOf(domain)); - // relation in domain->range && all v: domain | targetMult - // v.relation - return domainConstraint.and(funConstraint); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return name() + "(" + relation() + ", " + domain + " ->" + targetMult + " " + range + ")"; - } - } - - /** - * Represents the total ordering predicate. The predicate states that the given - * relation imposes a total ordering over the set - * ordered, and that the smallest/largest elements resulting from - * the ordering are given by the first/last relations. - * - * @specfield relation: Relation - * @specfield ordered, first, last: Relation - * @invariant name = TOTAL_ORDERING - * @invariant ordered.arity = first.arity = last.arity = 1 - * @invariant children = 0->relation + 1->ordered + 2->first + 3->last - */ - public static final class TotalOrdering extends RelationPredicate { - - private final Relation first, last, ordered; - - /** - * Constructs a new total ordering predicate. - * - * @ensures this.relation' = relation && this.first' = first && this.last' = - * last && this.name' = TOTAL_ORDERING - * @throws NullPointerException any of the arguments are null - * @throws IllegalArgumentException relation.arity != 2 || first.arity != 1 || - * last.arity != 1 - **/ - TotalOrdering(Relation relation, Relation ordered, Relation first, Relation last) { - super(relation); - if (first.arity() != 1 || last.arity() != 1 || ordered.arity() != 1) - throw new IllegalArgumentException("invalid arity: " + first + " or " + last + " or " + ordered); - this.first = first; - this.last = last; - this.ordered = ordered; - } - - /** - * Returns the name of this predicate. - * - * @return TOTAL_ORDERING - */ - @Override - public Name name() { - return Name.TOTAL_ORDERING; - } - - /** - * Returns the relation representing the first element in the ordering imposed - * by this.relation. - * - * @return this.first - */ - public Relation first() { - return first; - } - - /** - * Returns the relation representing the last element in the ordering imposed by - * this.relation. - * - * @return this.last - */ - public Relation last() { - return last; - } - - /** - * Returns the relation representing the atoms which are ordered by - * this.relation. - * - * @return this.ordered - */ - public Relation ordered() { - return ordered; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.RelationPredicate#toConstraints() - */ - @Override - public Formula toConstraints() { - // one first && one last && last in ordered - final Formula f0 = first.one().and(last.one()).and(last.in(ordered)); - // ordered = first.*relation - final Formula f1 = ordered.eq(first.join(relation().reflexiveClosure())); - // no relation.first && no last.relation - final Formula f2 = relation().join(first).no().and(last.join(relation()).no()); - // all e: ordered - last | one e.this - final Variable e = Variable.unary("e" + relation().name()); - final Formula f3 = e.join(relation()).one().forAll(e.oneOf(ordered.difference(last))); - - return and(f0, f1, f2, f3); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return name() + "(" + relation() + ", " + ordered + ", " + first + ", " + last + ")"; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/SumExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/SumExpression.java deleted file mode 100644 index fb595e6ce..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/SumExpression.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * Denotes the integer obtained by summing the values of an iteger expression - * ie for all values of a scalar x drawn from a set e. - * - * @specfield intExpr: IntExpression - * @specfield decls: Decls - * @specfield children = 0->decls + 1->intExpr - * @invariant all d: decls.children[int] | d.multiplicity = 1 - * @author Emina Torlak - */ -public final class SumExpression extends IntExpression { - - private final Decls decls; - private final IntExpression intExpr; - - /** - * Constructs a sum expression - * - * @ensures this.decls' = decls && this.intExpr' = intExpr - * @throws IllegalArgumentException some d: decls.children | d.multiplicty != - * ONE - */ - SumExpression(Decls decls, IntExpression intExpr) { - for (Decl d : decls) { - if (d.multiplicity() != Multiplicity.ONE) - throw new IllegalArgumentException(d + " is not a scalar declaration."); - } - this.decls = decls; - this.intExpr = intExpr; - } - - /** - * Returns this.decls. - * - * @return this.decls - */ - public final Decls decls() { - return decls; - } - - /** - * Returns this.intExpr. - * - * @return this.intExpr - */ - public final IntExpression intExpr() { - return intExpr; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return "(sum " + decls + " | " + intExpr + ")"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/UnaryExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/UnaryExpression.java deleted file mode 100644 index 7c241cb35..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/UnaryExpression.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * An {@link kodkod.ast.Expression expression} with one child. - * - * @specfield expression: Expression - * @specfield op: ExprOperator - * @invariant op.unary() - * @invariant children = 0->Expression - * @author Emina Torlak - */ -public final class UnaryExpression extends Expression { - - private final Expression expression; - private final ExprOperator op; - private final int arity; - - /** - * Constructs a new unary expression: op expression - * - * @ensures this.expression' = expression && this.op' = op - * @throws NullPointerException expression = null || op = null - * @throws IllegalArgumentException op in {TRANSPOSE, CLOSURE, - * REFLEXIVE_CLOSURE} && child.arity != 2 - */ - UnaryExpression(ExprOperator op, Expression child) { - if (!op.unary()) { - throw new IllegalArgumentException("Not a unary operator: " + op); - } - if (child.arity() != 2 && op != ExprOperator.PRE) { - throw new IllegalArgumentException("Invalid arity: " + child + "::" + child.arity()); - } - this.expression = child; - this.op = op; - this.arity = child.arity(); - } - - /** - * Returns the arity of this expression. - * - * @return this.arity - * @see kodkod.ast.Expression#arity() - */ - @Override - public int arity() { - return arity; - } - - /** - * Returns this.expression. - * - * @return this.expression - */ - public Expression expression() { - return expression; - } - - /** - * Returns this.op. - * - * @return this.op - */ - public ExprOperator op() { - return op; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return op.toString() + expression.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/UnaryIntExpression.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/UnaryIntExpression.java deleted file mode 100644 index ef6ae2a5c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/UnaryIntExpression.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.IntOperator; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * A unary integer intExpr, e.g. -x. - * - * @specfield intExpr: IntExpression - * @specfield op: IntOperator - * @invariant op.unary() - * @invariant children = 0->intExpr - * @author Emina Torlak - */ -public final class UnaryIntExpression extends IntExpression { - - private final IntOperator op; - private final IntExpression intExpr; - - /** - * Constructs a new unary int formula: op intExpr - * - * @ensures this.op' = op && this.intExpr' = intExpr - */ - UnaryIntExpression(IntOperator op, IntExpression intExpr) { - if (!op.unary()) - throw new IllegalArgumentException("Not a unary operator: " + op); - this.op = op; - this.intExpr = intExpr; - } - - /** - * Returns the operator of this. - * - * @return this.op - */ - public IntOperator op() { - return op; - } - - /** - * Returns this.intExpr. - * - * @return this.intExpr - */ - public IntExpression intExpr() { - return intExpr; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public I accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.IntExpression#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#toString() - */ - @Override - public String toString() { - return (op == IntOperator.NEG || op == IntOperator.NOT) ? "(" + op + intExpr + ")" : op + "(" + intExpr + ")"; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Variable.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Variable.java deleted file mode 100644 index cde70c044..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/Variable.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast; - -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.ast.visitor.VoidVisitor; - -/** - * Represents a variable in a {@link QuantifiedFormula quantified formula}, a - * {@link Comprehension comprehension expression}, or a {@link SumExpression sum - * expression}. Two variables are the same if and only if they refer to the same - * object. That is, v1.eauls(v2) <=> v1 == v2. Each variable has a name, which - * is basically a comment for the purpose of printing, viewing, etc. The name - * has no meaning otherwise. The arity of a variable specifies the arity of - * expressions over which the variable can range. - * - * @specfield name: String - * @specfield arity: int - * @invariant no children - * @author Emina Torlak - */ -public final class Variable extends LeafExpression { - - /** - * Constructs a variable with the specified name and arity 1. - * - * @ensures this.name' = name && this.arity' = 1 - */ - private Variable(String name) { - super(name, 1); - } - - /** - * Constructs a variable with the specified name and arity. - * - * @ensures this.name' = name && this.arity' = arity - */ - private Variable(String name, int arity) { - super(name, arity); - } - - /** - * Returns a new variable with the specified name and arity 1. - * - * @ensures this.name' = name && this.arity' = 1 - */ - public static Variable unary(String name) { - return new Variable(name); - } - - /** - * Returns a new variable with the specified name and arity. - * - * @ensures this.name' = name && this.arity' = arity - * @throws IllegalArgumentException arity < 1 - */ - public static Variable nary(String name, int arity) { - return new Variable(name, arity); - } - - /** - * Returns the declaration that constrains this variable to be bound to at most - * one element of the given expression: 'this: lone expr'. - * - * @return {d: Decl | d.variable = this && d.multiplicity = LONE && d.expression - * = expr } - * @throws NullPointerException expr = null - * @throws IllegalArgumentException this.arity != expr.arity || expr.arity != 1 - */ - public Decl loneOf(Expression expr) { - return new Decl(this, Multiplicity.LONE, expr); - } - - /** - * Returns the declaration that constrains this variable to be bound to exactly - * one element of the given expression: 'this: one expr'. - * - * @return {d: Decl | d.variable = this && d.multiplicity = ONE && d.expression - * = expr } - * @throws NullPointerException expr = null - * @throws IllegalArgumentException this.arity != expr.arity || expr.arity != 1 - */ - public Decl oneOf(Expression expr) { - return new Decl(this, Multiplicity.ONE, expr); - } - - /** - * Returns the declaration that constrains this variable to be bound to at least - * one element of the given expression: 'this: some expr'. - * - * @return {d: Decl | d.variable = this && d.multiplicity = SOME && d.expression - * = expr } - * @throws NullPointerException expr = null - * @throws IllegalArgumentException this.arity != expr.arity || expr.arity != 1 - */ - public Decl someOf(Expression expr) { - return new Decl(this, Multiplicity.SOME, expr); - } - - /** - * Returns the declaration that constrains this variable to be bound to a subset - * of the elements in the given expression: 'this: set expr'. - * - * @return {d: Decl | d.variable = this && d.multiplicity = SET && d.expression - * = expr } - * @throws NullPointerException expr = null - * @throws IllegalArgumentException this.arity != expr.arity - */ - public Decl setOf(Expression expr) { - return new Decl(this, Multiplicity.SET, expr); - } - - /** - * Returns the declaration that constrains this variable to be bound to the - * specified number of the elements in the given expression: 'this: mult expr'. - * - * @return {d: Decl | d.variable = this && d.multiplicity = mult && d.expression - * = expr } - * @throws NullPointerException expression = null || mult = null - * @throws IllegalArgumentException mult = NO - * @throws IllegalArgumentException mult in ONE + LONE + SOME && expr.arity != 1 - * @throws IllegalArgumentException this.arity != expr.arity - */ - public Decl declare(Multiplicity mult, Expression expr) { - return new Decl(this, mult, expr); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Expression#accept(kodkod.ast.visitor.ReturnVisitor) - */ - @Override - public E accept(ReturnVisitor visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.Node#accept(kodkod.ast.visitor.VoidVisitor) - */ - @Override - public void accept(VoidVisitor visitor) { - visitor.visit(this); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprCastOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprCastOperator.java deleted file mode 100644 index 826f3bb63..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprCastOperator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerates expression 'cast' operators. - */ -public enum ExprCastOperator { - /** The cardinality operator (#). */ - CARDINALITY { - - @Override - public String toString() { - return "#"; - } - }, - /** The sum operator. */ - SUM { - - @Override - public String toString() { - return "sum"; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprCompOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprCompOperator.java deleted file mode 100644 index 6bd988d20..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprCompOperator.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerates relational comparison operators. - */ -public enum ExprCompOperator { - /** Subset operator (in). */ - SUBSET { - - @Override - public String toString() { - return "in"; - } - }, - /** Equality operator (=). */ - EQUALS { - - @Override - public String toString() { - return "="; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprOperator.java deleted file mode 100644 index af575bf70..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/ExprOperator.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerates unary (~, ^, *), binary (+, &, ++, ->, -, .) and nary (+, &, ++, - * ->) expression operators. - * - * @specfield op: (int->lone Expression) -> Expression - * @invariant all args: seq Expression, out: Expression | args->out in op => - * (out.children = args && out.op = this) - */ -public enum ExprOperator { - /** Relational union (+) operator. */ - UNION { - - @Override - public String toString() { - return "+"; - } - }, - /** Relational intersection (&) operator. */ - INTERSECTION { - - @Override - public String toString() { - return "&"; - } - }, - /** Relational override (++) operator. */ - OVERRIDE { - - @Override - public String toString() { - return "++"; - } - }, - /** Relational product (->) operator. */ - PRODUCT { - - @Override - public String toString() { - return "->"; - } - }, - /** Relational difference (-) operator. */ - DIFFERENCE { - - @Override - public String toString() { - return "-"; - } - }, - /** Relational join (.) operator. */ - JOIN { - - @Override - public String toString() { - return "."; - } - }, - /** Transpose (~) operator. */ - TRANSPOSE { - - @Override - public String toString() { - return "~"; - } - }, - /** Transitive closure (^) operator. */ - CLOSURE { - - @Override - public String toString() { - return "^"; - } - }, - /** Reflexive transitive closure (*) operator. */ - REFLEXIVE_CLOSURE { - - @Override - public String toString() { - return "*"; - } - }, - /** - * Value in post-state (used only for fixpoint computation. - */ - PRE { - - @Override - public String toString() { - return "PRE"; - } - }; - - static final int unary = TRANSPOSE.index() | CLOSURE.index() | REFLEXIVE_CLOSURE.index() | PRE.index(); - - static final int binary = ~unary; - - static final int nary = UNION.index() | INTERSECTION.index() | OVERRIDE.index() | PRODUCT.index(); - - private final int index() { - return 1 << ordinal(); - } - - /** - * Returns true if this is a unary operator. - * - * @return true if this is a unary operator. - */ - public final boolean unary() { - return (unary & index()) != 0; - } - - /** - * Returns true if this is a binary operator. - * - * @return true if this is a binary operator. - */ - public final boolean binary() { - return (binary & index()) != 0; - } - - /** - * Returns true if this is an nary operator. - * - * @return true if this is an nary operator. - */ - public final boolean nary() { - return (nary & index()) != 0; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/FormulaOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/FormulaOperator.java deleted file mode 100644 index 1b6331f34..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/FormulaOperator.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerates binary (&&, ||, =>, <=>) and nary (&&, ||) logical operators. - * - * @specfield op: (int->lone Formula) -> Formula - * @invariant all args: seq Formula, out: Formula | args->out in op => - * (out.children = args && out.op = this) - */ -public enum FormulaOperator { - /** Logical AND operator. */ - AND { - - @Override - public String toString() { - return "&&"; - } - }, - /** Logical OR operator. */ - OR { - - @Override - public String toString() { - return "||"; - } - }, - /** Logical bi-implication operator. */ - IFF { - - @Override - public String toString() { - return "<=>"; - } - }, - /** Logical implication operator. */ - IMPLIES { - - @Override - public String toString() { - return "=>"; - } - }; - - static final int nary = (1 << AND.ordinal()) | (1 << OR.ordinal()); - - /** - * Returns true if this is an nary operator. - * - * @return true if this is an nary operator - */ - public final boolean nary() { - return (nary & (1 << ordinal())) != 0; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntCastOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntCastOperator.java deleted file mode 100644 index db13c6a02..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntCastOperator.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Represents an intexpression 'cast' operator. - */ -public enum IntCastOperator { - /** The Int cast operator Int[intExpr]. */ - INTCAST { - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Int"; - } - }, - /** The Bitset cast operator Bits[intExpr]. */ - BITSETCAST { - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Bits"; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntCompOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntCompOperator.java deleted file mode 100644 index 7b56c61fd..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntCompOperator.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerates binary comparison operators: =, < , >, <=, >=. - */ -public enum IntCompOperator { - /** `=' operator */ - EQ { - - @Override - public String toString() { - return "="; - } - }, - /** `!=' operator */ - NEQ { - - @Override - public String toString() { - return "!="; - } - }, - /** `<' operator */ - LT { - - @Override - public String toString() { - return "<"; - } - }, - /** `<=' operator */ - LTE { - - @Override - public String toString() { - return "<="; - } - }, - /** `>' operator */ - GT { - - @Override - public String toString() { - return ">"; - } - }, - /** `>=' operator */ - GTE { - - @Override - public String toString() { - return ">="; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntOperator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntOperator.java deleted file mode 100644 index c92464a88..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/IntOperator.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerate unary (-, ~, abs, sgn), binary (+, *, &, |, -, /, %, >>, >>>, <<) - * and nary (+, *, &, |) operators on integer expressions. - * - * @specfield op: (int->lone IntExpression) -> IntExpression - * @invariant all args: seq IntExpression, out: IntExpression | args->out in op - * => (out.children = args && out.op = this) - */ -public enum IntOperator { - /** `+' operator */ - PLUS { - - @Override - public String toString() { - return "+"; - } - }, - /** `*' operator */ - MULTIPLY { - - @Override - public String toString() { - return "*"; - } - }, - /** `-' operator */ - MINUS { - - @Override - public String toString() { - return "-"; - } - }, - /** `/' operator */ - DIVIDE { - - @Override - public String toString() { - return "/"; - } - }, - /** `%' operator */ - MODULO { - - @Override - public String toString() { - return "%"; - } - }, - /** Bitwise AND operator */ - AND { - - @Override - public String toString() { - return "&"; - } - }, - /** Bitwise OR operator */ - OR { - - @Override - public String toString() { - return "|"; - } - }, - /** Bitwise XOR operator */ - XOR { - - @Override - public String toString() { - return "^"; - } - }, - /** Left shift operator */ - SHL { - - @Override - public String toString() { - return "<<"; - } - }, - /** Right shift operator with zero extension */ - SHR { - - @Override - public String toString() { - return ">>>"; - } - }, - /** Right shift operator with sign extension */ - SHA { - - @Override - public String toString() { - return ">>"; - } - }, - /** unary negation (`-') operator */ - NEG { - - @Override - public String toString() { - return "-"; - } - }, - /** bit negation (`~') operator */ - NOT { - - @Override - public String toString() { - return "~"; - } - }, - /** absolute value function */ - ABS { - - @Override - public String toString() { - return "abs"; - } - }, - /** signum function */ - SGN { - - @Override - public String toString() { - return "sgn"; - } - }; - - static final int unary = NEG.index() | NOT.index() | ABS.index() | SGN.index(); - - static final int binary = ~unary; - - static final int nary = PLUS.index() | MULTIPLY.index() | AND.index() | OR.index(); - - private final int index() { - return 1 << ordinal(); - } - - /** - * Returns true if this is a unary operator. - * - * @return true if this is a unary operator. - */ - public final boolean unary() { - return (unary & index()) != 0; - } - - /** - * Returns true if this is a binary operator. - * - * @return true if this is a binary operator. - */ - public final boolean binary() { - return (binary & index()) != 0; - } - - /** - * Returns true if this is an nary operator. - * - * @return true if this is an nary operator. - */ - public final boolean nary() { - return (nary & index()) != 0; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/Multiplicity.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/Multiplicity.java deleted file mode 100644 index a8c92ec97..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/Multiplicity.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Represents the multiplicity of an expression in a - * {@link kodkod.ast.MultiplicityFormula} or the multiplicity of a variable in a - * {@link kodkod.ast.Decl }. - * - * @author Emina Torlak - */ -public enum Multiplicity { - /** - * no expr: expr contains no elements. The 'no' multiplicity can only - * be used in a multiplicity formula. - */ - NO { - - @Override - public String toString() { - return "no"; - } - }, - /** - * lone expr: expr contains at most one element. - */ - LONE { - - @Override - public String toString() { - return "lone"; - } - }, - /** one expr: expr contains exactly one element. */ - ONE { - - @Override - public String toString() { - return "one"; - } - }, - /** - * some expr: expr contains at least one element. - */ - SOME { - - @Override - public String toString() { - return "some"; - } - }, - /** - * v: set expr: v is a subset of expr. The 'set' multiplicity can only - * be used in a declaration. - */ - SET { - - @Override - public String toString() { - return "set"; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/Quantifier.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/Quantifier.java deleted file mode 100644 index a7ef31769..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/Quantifier.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.operator; - -/** - * Enumerates logical quantifiers. - */ -public enum Quantifier { - - /** Universal quantifier. */ - ALL { - - @Override - public String toString() { - return "all"; - } - }, - /** Existential quantifier. */ - SOME { - - @Override - public String toString() { - return "some"; - } - }; - - public Quantifier opposite; - public boolean universal; - public boolean existential; - - static { - ALL.opposite = SOME; - ALL.universal = true; - ALL.existential = false; - SOME.opposite = ALL; - SOME.universal = false; - SOME.existential = true; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/package.html deleted file mode 100644 index 50cb245bf..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/package.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -Contains operators for Kodkod formulas, expressions, and integer expressions. - -

Package Specification

- -

Contains operators for Kodkod formulas, expressions, and integer expressions.

- - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/operator/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/package.html deleted file mode 100644 index 6f886408c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/package.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - -Contains classes for creating Kodkod formulas, expressions, -and integer expressions. - -

Package Specification

- -

Contains the classes for creating a Kodkod abstract syntax -tree (AST). An object such as a quantified formula or a union expression is called a node. -The {@linkplain kodkod.ast.Node} class is the root of the Kodkod syntax hierarchy.

- -

All classes in this package are immutable. Their instances -are created by calling factory methods of the classes {@linkplain kodkod.ast.Relation}, {@linkplain kodkod.ast.Variable}, -{@linkplain kodkod.ast.Expression}, {@linkplain kodkod.ast.IntExpression}, and {@linkplain kodkod.ast.Formula}. Nodes can be freely shared between -multiple parents (so a Kodkod AST is actually a directed acyclic graph).

- -

Related Documentation

- -@see kodkod.ast.Relation -@see kodkod.ast.Variable -@see kodkod.ast.Expression -@see kodkod.ast.IntExpression -@see kodkod.ast.Formula -@see kodkod.ast.Node - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/packageinfo deleted file mode 100644 index 084a0d4e3..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 2.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractCollector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractCollector.java deleted file mode 100644 index ee9663f96..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractCollector.java +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.visitor; - -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; - -/** - *

- * A depth first collector. Subclasses should override the methods in which - * detection is performed to return the appropriate set. For example, a Variable - * collector could be implemented simply by subclassing this implementation and - * overriding the {@link #visit(Variable) } method to return a singleton set - * containing the input argument. - *

- * - * @specfield cached: set Node // result of visiting these nodes will be cached - * @specfield cache: Node -> lone Set - * @specfield cached in cache.Node - * @author Emina Torlak - */ -public abstract class AbstractCollector implements ReturnVisitor,Set,Set,Set> { - - protected final Map> cache; - protected final Set cached; - - /** - * Constructs a depth first collector which will cache the results of visiting - * the given nodes and re-use them on subsequent visits. - * - * @ensures this.cached' = cached && no this.cache - */ - protected AbstractCollector(Set cached) { - this.cached = cached; - this.cache = new IdentityHashMap>(cached.size()); - } - - /** - * Constructs a depth-first collectior which will cache the results of visiting - * the given nodes in the given map, and re-use them on subsequent visits. - * - * @ensures this.cached' = cached && this.cache' = cache - */ - protected AbstractCollector(Set cached, Map> cache) { - this.cached = cached; - this.cache = cache; - } - - /** - * If n has been visited and a value for it cached, the cached value is - * returned. Otherwise null is returned. - * - * @return this.cache[n] - */ - protected Set lookup(Node n) { - return cache.get(n); - } - - /** - * Caches the given value for the specified node, if this is a caching visitor, - * and returns it. - * - * @ensures n in this.cached => this.cache' = this.cache ++ n->reduce(val), - * this.cache' = this.cache - * @return val - */ - protected Set cache(Node n, Set val) { - if (cached.contains(n)) { - cache.put(n, reduce(val)); - } - return val; - } - - /** - * Returns the set that has the same contents as val, but that may be more - * efficiently implemented than val. - * - * @return val.size()=0 => Collections.EMPTY_SET, val.size()=1 => - * Collections.singleton(val.iterator().next()), val - */ - protected Set reduce(Set val) { - switch (val.size()) { - case 0 : - return Collections.emptySet(); - case 1 : - return Collections.singleton(val.iterator().next()); - default : - return val; - } - } - - /** - * Returns a new, empty, modifiable set. - * - * @return a new, empty, modifiable set. - */ - protected abstract Set newSet(); - - /** - * Calls lookup(decls) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the union of the sets returned by the - * children and returns it. - * - * @return let x = lookup(decls) | x != null => x, cache(decls, - * decls.declarations[0].accept(this) +...+ - * decls.declarations[decls.size-1].accept(this)) - */ - @Override - public Set visit(Decls decls) { - Set ret = lookup(decls); - if (ret != null) - return ret; - ret = newSet(); - for (Decl d : decls) { - ret.addAll(d.accept(this)); - } - return cache(decls, ret); - } - - /** - * Calls lookup(decl) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the union of the sets returned by the - * children and returns it. - * - * @return let x = lookup(decl) | x != null => x, cache(decls, - * decl.variable.accept(this) + decl.expression.accept(this)) - */ - @Override - public Set visit(Decl decl) { - Set ret = lookup(decl); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(decl.variable().accept(this)); - ret.addAll(decl.expression().accept(this)); - return cache(decl, ret); - } - - /** - * Returns Collections.EMPTY_SET - * - * @return Collections.EMPTY_SET - */ - @Override - @SuppressWarnings("unchecked" ) - public Set visit(Relation relation) { - return Collections.EMPTY_SET; - } - - /** - * Returns Collections.EMPTY_SET - * - * @return Collections.EMPTY_SET - */ - @Override - @SuppressWarnings("unchecked" ) - public Set visit(Variable variable) { - return Collections.EMPTY_SET; - } - - /** - * Returns Collections.EMPTY_SET - * - * @return Collections.EMPTY_SET - */ - @Override - @SuppressWarnings("unchecked" ) - public Set visit(ConstantExpression constExpr) { - return Collections.EMPTY_SET; - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the union of the children's return values - * and returns it. - * - * @return let x = lookup(expr) | x != null => x, cache(expr, - * expr.child(0).accept(this) + .. + - * expr.child(expr.size()-1).accept(this)) - */ - @Override - public Set visit(NaryExpression expr) { - Set ret = lookup(expr); - if (ret != null) - return ret; - ret = newSet(); - for (Expression child : expr) { - ret.addAll(child.accept(this)); - } - return cache(expr, ret); - } - - /** - * Calls lookup(binExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(binExpr) | x != null => x, cache(binExpr, - * binExpr.left.accept(this) + binExpr.right.accept(this)) - */ - @Override - public Set visit(BinaryExpression binExpr) { - Set ret = lookup(binExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(binExpr.left().accept(this)); - ret.addAll(binExpr.right().accept(this)); - return cache(binExpr, ret); - } - - /** - * Calls lookup(unaryExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(unaryExpr) | x != null => x, cache(unaryExpr, - * unaryExpr.expression.accept(this)) - */ - @Override - public Set visit(UnaryExpression unaryExpr) { - Set ret = lookup(unaryExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(unaryExpr.expression().accept(this)); - return cache(unaryExpr, ret); - } - - /** - * Calls lookup(comprehension) and returns the cached value, if any. If no - * cached value exists, visits each child, caches the union of the children's - * return values and returns it. - * - * @return let x = lookup(comprehension) | x != null => x, cache(comprehension, - * comprehension.declarations.accept(this) + - * comprehension.formula.accept(this)) - */ - @Override - public Set visit(Comprehension comprehension) { - Set ret = lookup(comprehension); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(comprehension.decls().accept(this)); - ret.addAll(comprehension.formula().accept(this)); - return cache(comprehension, ret); - } - - /** - * Calls lookup(ifExpr) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the union of the children's return values - * and returns it. - * - * @return let x = lookup(ifExpr) | x != null => x, cache(ifExpr, - * ifExpr.condition.accept(this) + ifExpr.thenExpr.accept(this) + - * ifExpr.elseExpr.accept(this)) - */ - @Override - public Set visit(IfExpression ifExpr) { - Set ret = lookup(ifExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(ifExpr.condition().accept(this)); - ret.addAll(ifExpr.thenExpr().accept(this)); - ret.addAll(ifExpr.elseExpr().accept(this)); - return cache(ifExpr, ret); - } - - /** - * Calls lookup(project) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(project) | x != null => x, cache(project, - * project.expression.accept(this) + project.columns[int].accept(this)) - */ - @Override - public Set visit(ProjectExpression project) { - Set ret = lookup(project); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(project.expression().accept(this)); - for (int i = 0, arity = project.arity(); i < arity; i++) { - ret.addAll(project.column(i).accept(this)); - } - return cache(project, ret); - } - - /** - * Calls lookup(castExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(castExpr) | x != null => x, cache(intExpr, - * castExpr.intExpr.accept(this)) - */ - @Override - public Set visit(IntToExprCast castExpr) { - Set ret = lookup(castExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(castExpr.intExpr().accept(this)); - return cache(castExpr, ret); - } - - /** - * Returns Collections.EMPTY_SET - * - * @return Collections.EMPTY_SET - */ - @Override - @SuppressWarnings("unchecked" ) - public Set visit(IntConstant intConst) { - return Collections.EMPTY_SET; - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.condition.accept(this) + intExpr.thenExpr.accept(this) + - * intExpr.elseExpr.accept(this)) - */ - @Override - public Set visit(IfIntExpression intExpr) { - Set ret = lookup(intExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(intExpr.condition().accept(this)); - ret.addAll(intExpr.thenExpr().accept(this)); - ret.addAll(intExpr.elseExpr().accept(this)); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.expression.accept(this)) - */ - @Override - public Set visit(ExprToIntCast intExpr) { - Set ret = lookup(intExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(intExpr.expression().accept(this)); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.child(0).accept(this) + .. + - * intExpr.child(intExpr.size()-1).accept(this)) - */ - @Override - public Set visit(NaryIntExpression intExpr) { - Set ret = lookup(intExpr); - if (ret != null) - return ret; - ret = newSet(); - for (IntExpression child : intExpr) { - ret.addAll(child.accept(this)); - } - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.left.accept(this) + intExpr.right.accept(this)) - */ - @Override - public Set visit(BinaryIntExpression intExpr) { - Set ret = lookup(intExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(intExpr.left().accept(this)); - ret.addAll(intExpr.right().accept(this)); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.expression.accept(this)) - */ - @Override - public Set visit(UnaryIntExpression intExpr) { - Set ret = lookup(intExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(intExpr.intExpr().accept(this)); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.decls.accept(this) + intExpr.intExpr.accept(this)) - */ - @Override - public Set visit(SumExpression intExpr) { - Set ret = lookup(intExpr); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(intExpr.decls().accept(this)); - ret.addAll(intExpr.intExpr().accept(this)); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intComp) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(intComp) | x != null => x, cache(intComp, - * intComp.left.accept(this) + intComp.right.accept(this)) - */ - @Override - public Set visit(IntComparisonFormula intComp) { - Set ret = lookup(intComp); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(intComp.left().accept(this)); - ret.addAll(intComp.right().accept(this)); - return cache(intComp, ret); - } - - /** - * Calls lookup(quantFormula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(quantFormula) | x != null => x, cache(quantFormula, - * quantFormula.declarations.accept(this) + - * quantFormula.formula.accept(this)) - */ - @Override - public Set visit(QuantifiedFormula quantFormula) { - Set ret = lookup(quantFormula); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(quantFormula.decls().accept(this)); - ret.addAll(quantFormula.formula().accept(this)); - return cache(quantFormula, ret); - } - - /** - * Calls lookup(formula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(formula) | x != null => x, cache(formula, - * formula.child(0).accept(this) + .. + - * formula.child(formula.size()-1).accept(this)) - */ - @Override - public Set visit(NaryFormula formula) { - Set ret = lookup(formula); - if (ret != null) - return ret; - ret = newSet(); - for (Formula child : formula) { - ret.addAll(child.accept(this)); - } - return cache(formula, ret); - } - - /** - * Calls lookup(binFormula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(binFormula) | x != null => x, cache(binFormula, - * binFormula.left.accept(this) + binFormula.right.accept(this)) - */ - @Override - public Set visit(BinaryFormula binFormula) { - Set ret = lookup(binFormula); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(binFormula.left().accept(this)); - ret.addAll(binFormula.right().accept(this)); - return cache(binFormula, ret); - } - - /** - * Calls lookup(not) and returns the cached value, if any. If no cached value - * exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(not) | x != null => x, cache(not, - * not.formula.accept(this)) - */ - @Override - public Set visit(NotFormula not) { - Set ret = lookup(not); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(not.formula().accept(this)); - return cache(not, ret); - } - - /** - * Returns Collections.EMPTY_SET - * - * @return Collections.EMPTY_SET - */ - @Override - @SuppressWarnings("unchecked" ) - public Set visit(ConstantFormula constant) { - return Collections.EMPTY_SET; - } - - /** - * Calls lookup(compFormula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the union of the children's return - * values and returns it. - * - * @return let x = lookup(compFormula) | x != null => x, - * cache(compFormula,compFormula.left.accept(this) + - * compFormula.right.accept(this)) - */ - @Override - public Set visit(ComparisonFormula compFormula) { - Set ret = lookup(compFormula); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(compFormula.left().accept(this)); - ret.addAll(compFormula.right().accept(this)); - return cache(compFormula, ret); - } - - /** - * Calls lookup(multFormula) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(multFormula) | x != null => x, cache(multFormula, - * multFormula.expression.accept(this)) - */ - @Override - public Set visit(MultiplicityFormula multFormula) { - Set ret = lookup(multFormula); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(multFormula.expression().accept(this)); - return cache(multFormula, ret); - } - - /** - * Calls lookup(predicate) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(predicate) | x != null => x, cache(predicate, some n: - * predicate.children | n.accept(this)) - */ - @Override - public Set visit(RelationPredicate pred) { - Set ret = lookup(pred); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(pred.relation().accept(this)); - switch (pred.name()) { - case ACYCLIC : - break; - case FUNCTION : - final RelationPredicate.Function fp = (RelationPredicate.Function) pred; - ret.addAll(fp.domain().accept(this)); - ret.addAll(fp.range().accept(this)); - break; - case TOTAL_ORDERING : - final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; - ret.addAll(tp.ordered().accept(this)); - ret.addAll(tp.first().accept(this)); - ret.addAll(tp.last().accept(this)); - break; - default : - throw new IllegalArgumentException("unknown relation predicate: " + pred.name()); - } - return cache(pred, ret); - } - - @Override - public Set visit(FixFormula fixFormula) { - Set ret = lookup(fixFormula); - if (ret != null) - return ret; - ret = newSet(); - ret.addAll(fixFormula.formula().accept(this)); - ret.addAll(fixFormula.condition().accept(this)); - return cache(fixFormula, ret); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractDetector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractDetector.java deleted file mode 100644 index bb911311f..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractDetector.java +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.visitor; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; - -/** - *

- * A depth first detector. Subclasses should override the methods in which - * detection is performed to return TRUE. For example, a Variable detector could - * be implemented simply by subclassing this implementation and overriding the - * {@link #visit(Variable) } method to return TRUE. - *

- * - * @specfield cached: set Node // result of visiting these nodes will be cached - * @specfield cache: Node -> lone Boolean - * @specfield cached in cache.Node - * @author Emina Torlak - */ -public abstract class AbstractDetector implements ReturnVisitor { - - protected final Map cache; - protected final Set cached; - - /** - * Constructs a depth first detector which will cache the results of visiting - * the given nodes and re-use them on subsequent visits. - * - * @ensures this.cached' = cached && no this.cache - */ - protected AbstractDetector(Set cached) { - this.cached = cached; - this.cache = new IdentityHashMap(cached.size()); - } - - /** - * Constructs a depth-first detector which will cache the results of visiting - * the given nodes in the given map, and re-use them on subsequent visits. - * - * @ensures this.cached' = cached && this.cache' = cache - */ - protected AbstractDetector(Set cached, Map cache) { - this.cached = cached; - this.cache = cache; - } - - /** - * If n has been visited and a value for it cached, the cached value is - * returned. Otherwise null is returned. - * - * @return this.cache[n] - */ - protected Boolean lookup(Node n) { - return cache.get(n); - } - - /** - * Caches the given value for the specified node, if this is a caching visitor, - * and returns Boolean.valueOf(val). - * - * @ensures n in this.cached => this.cache' = this.cache ++ - * n->Boolean.valueOf(val), this.cache' = this.cache - * @return Boolean.valueOf(val) - */ - protected Boolean cache(Node n, boolean val) { - final Boolean ret = Boolean.valueOf(val); - if (cached.contains(n)) - cache.put(n, ret); - return ret; - } - - /** - * Calls lookup(decls) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the disjunction of the children's return - * values and returns it. - * - * @return let x = lookup(decls) | x != null => x, cache(decls, some d: - * decls.declarations | d.accept(this)) - */ - @Override - public Boolean visit(Decls decls) { - final Boolean ret = lookup(decls); - if (ret != null) - return ret; - for (Decl d : decls) { - if (visit(d)) - return cache(decls, true); - } - return cache(decls, false); - } - - /** - * Calls lookup(decl) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the disjunction of the children's return - * values and returns it. - * - * @return let x = lookup(decl) | x != null => x, cache(decl, - * decl.variable.accept(this) || decl.expression.accept(this)) - */ - @Override - public Boolean visit(Decl decl) { - final Boolean ret = lookup(decl); - return (ret != null) ? ret : cache(decl, decl.variable().accept(this) || decl.expression().accept(this)); - } - - /** - * Returns FALSE. - * - * @return FALSE - */ - @Override - public Boolean visit(Relation relation) { - return Boolean.FALSE; - } - - /** - * Returns FALSE. - * - * @return FALSE - */ - @Override - public Boolean visit(Variable variable) { - return Boolean.FALSE; - } - - /** - * Returns FALSE. - * - * @return FALSE - */ - @Override - public Boolean visit(ConstantExpression expr) { - return Boolean.FALSE; - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the disjunction of the children's return - * values and returns it. - * - * @return let x = lookup(expr) | x != null => x, cache(expr, - * expr.child(0).accept(this) || ... || - * expr.child(expr.size()-1).accept(this)) - */ - @Override - public Boolean visit(NaryExpression expr) { - final Boolean ret = lookup(expr); - if (ret != null) - return ret; - for (Expression child : expr) { - if (child.accept(this)) - return cache(expr, true); - } - return cache(expr, false); - } - - /** - * Calls lookup(binExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(binExpr) | x != null => x, cache(binExpr, - * binExpr.left.accept(this) || binExpr.right.accept(this)) - */ - @Override - public Boolean visit(BinaryExpression binExpr) { - final Boolean ret = lookup(binExpr); - return (ret != null) ? ret : cache(binExpr, binExpr.left().accept(this) || binExpr.right().accept(this)); - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If no cached value - * exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(expr) | x != null => x, cache(expr, - * expr.expression.accept(this)) - */ - @Override - public Boolean visit(UnaryExpression expr) { - final Boolean ret = lookup(expr); - return (ret != null) ? ret : cache(expr, expr.expression().accept(this)); - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the disjunction of the children's return - * values and returns it. - * - * @return let x = lookup(expr) | x != null => x, cache(expr, - * expr.decls.accept(this) || expr.formula.accept(this)) - */ - @Override - public Boolean visit(Comprehension expr) { - final Boolean ret = lookup(expr); - return (ret != null) ? ret : cache(expr, expr.decls().accept(this) || expr.formula().accept(this)); - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If no cached value - * exists, visits each child, caches the disjunction of the children's return - * values and returns it. - * - * @return let x = lookup(expr) | x != null => x, cache(expr, - * expr.condition.accept(this) || expr.thenExpr.accept(this) || - * expr.elseExpr.accept(this)) - */ - @Override - public Boolean visit(IfExpression expr) { - final Boolean ret = lookup(expr); - return (ret != null) ? ret : cache(expr, expr.condition().accept(this) || expr.thenExpr().accept(this) || expr.elseExpr().accept(this)); - } - - /** - * Calls lookup(project) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(project) | x != null => x, cache(project, - * project.expression.accept(this) || project.columns[int].accept(this)) - */ - @Override - public Boolean visit(ProjectExpression project) { - final Boolean ret = lookup(project); - if (ret != null) - return ret; - if (project.expression().accept(this)) - return cache(project, true); - for (int i = 0, arity = project.arity(); i < arity; i++) { - if (project.column(i).accept(this)) - return cache(project, true); - } - return cache(project, false); - } - - /** - * Calls lookup(castExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(castExpr) | x != null => x, cache(intExpr, - * castExpr.intExpr.accept(this)) - */ - @Override - public Boolean visit(IntToExprCast castExpr) { - final Boolean ret = lookup(castExpr); - return (ret != null) ? ret : cache(castExpr, castExpr.intExpr().accept(this)); - } - - /** - * Returns FALSE. - * - * @return FALSE - */ - @Override - public Boolean visit(IntConstant intConst) { - return Boolean.FALSE; - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.condition.accept(this) || intExpr.thenExpr.accept(this) || - * intExpr.elseExpr.accept(this)) - */ - @Override - public Boolean visit(IfIntExpression intExpr) { - final Boolean ret = lookup(intExpr); - return (ret != null) ? ret : cache(intExpr, intExpr.condition().accept(this) || intExpr.thenExpr().accept(this) || intExpr.elseExpr().accept(this)); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.expression.accept(this)) - */ - @Override - public Boolean visit(ExprToIntCast intExpr) { - final Boolean ret = lookup(intExpr); - return (ret != null) ? ret : cache(intExpr, intExpr.expression().accept(this)); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.child(0).accept(this) || ... || - * intExpr.child(intExpr.size()-1).accept(this)) - */ - @Override - public Boolean visit(NaryIntExpression intExpr) { - final Boolean ret = lookup(intExpr); - if (ret != null) - return ret; - for (IntExpression child : intExpr) { - if (child.accept(this)) - return cache(intExpr, true); - } - return cache(intExpr, false); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.left.accept(this) || intExpr.right.accept(this)) - */ - @Override - public Boolean visit(BinaryIntExpression intExpr) { - final Boolean ret = lookup(intExpr); - return (ret != null) ? ret : cache(intExpr, intExpr.left().accept(this) || intExpr.right().accept(this)); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.expression.accept(this)) - */ - @Override - public Boolean visit(UnaryIntExpression intExpr) { - final Boolean ret = lookup(intExpr); - return (ret != null) ? ret : cache(intExpr, intExpr.intExpr().accept(this)); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, - * intExpr.decls.accept(this) || intExpr.intExpr.accept(this)) - */ - @Override - public Boolean visit(SumExpression intExpr) { - final Boolean ret = lookup(intExpr); - return (ret != null) ? ret : cache(intExpr, intExpr.decls().accept(this) || intExpr.intExpr().accept(this)); - } - - /** - * Calls lookup(intComp) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(intComp) | x != null => x, cache(intComp, - * intComp.left.accept(this) || intComp.right.accept(this)) - */ - @Override - public Boolean visit(IntComparisonFormula intComp) { - final Boolean ret = lookup(intComp); - return (ret != null) ? ret : cache(intComp, intComp.left().accept(this) || intComp.right().accept(this)); - } - - /** - * Calls lookup(quantFormula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(quantFormula) | x != null => x, cache(quantFormula, - * quantFormula.declarations.accept(this) - * ||quantFormula.formula.accept(this)) - */ - @Override - public Boolean visit(QuantifiedFormula quantFormula) { - final Boolean ret = lookup(quantFormula); - return (ret != null) ? ret : cache(quantFormula, quantFormula.decls().accept(this) || quantFormula.formula().accept(this)); - } - - /** - * Calls lookup(formula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(formula) | x != null => x, cache(formula, - * formula.child(0).accept(this) || ... || - * formula.child(formula.size()-1).accept(this)) - */ - @Override - public Boolean visit(NaryFormula formula) { - final Boolean ret = lookup(formula); - if (ret != null) - return ret; - for (Formula child : formula) { - if (child.accept(this)) - return cache(formula, true); - } - return cache(formula, false); - } - - /** - * Calls lookup(binFormula) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(binFormula) | x != null => x, cache(binFormula, - * binFormula.left.accept(this) || binFormula.right.accept(this)) - */ - @Override - public Boolean visit(BinaryFormula binFormula) { - final Boolean ret = lookup(binFormula); - return (ret != null) ? ret : cache(binFormula, binFormula.left().accept(this) || binFormula.right().accept(this)); - } - - /** - * Calls lookup(not) and returns the cached value, if any. If no cached value - * exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(not) | x != null => x, cache(not, - * not.formula.accept(this)) - */ - @Override - public Boolean visit(NotFormula not) { - final Boolean ret = lookup(not); - return (ret != null) ? ret : cache(not, not.formula().accept(this)); - } - - /** - * Returns FALSE. - * - * @return FALSE - */ - @Override - public Boolean visit(ConstantFormula constant) { - return Boolean.FALSE; - } - - /** - * Calls lookup(exprComp) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(exprComp) | x != null => x, - * cache(exprComp,exprComp.left.accept(this) || - * exprComp.right.accept(this)) - */ - @Override - public Boolean visit(ComparisonFormula exprComp) { - final Boolean ret = lookup(exprComp); - return (ret != null) ? ret : cache(exprComp, exprComp.left().accept(this) || exprComp.right().accept(this)); - } - - /** - * Calls lookup(multFormula) and returns the cached value, if any. If no cached - * value exists, visits the child, caches its return value and returns it. - * - * @return let x = lookup(multFormula) | x != null => x, cache(multFormula, - * multFormula.expression.accept(this)) - */ - @Override - public Boolean visit(MultiplicityFormula multFormula) { - final Boolean ret = lookup(multFormula); - return (ret != null) ? ret : cache(multFormula, multFormula.expression().accept(this)); - } - - /** - * Calls lookup(predicate) and returns the cached value, if any. If no cached - * value exists, visits each child, caches the disjunction of the children's - * return values and returns it. - * - * @return let x = lookup(predicate) | x != null => x, cache(predicate, some n: - * predicate.children | n.accept(this)) - */ - @Override - public Boolean visit(RelationPredicate predicate) { - final Boolean ret = lookup(predicate); - if (ret != null) - return ret; - if (predicate.relation().accept(this)) - return cache(predicate, true); - if (predicate.name() == RelationPredicate.Name.FUNCTION) { - final RelationPredicate.Function fp = (RelationPredicate.Function) predicate; - return cache(predicate, fp.domain().accept(this) || fp.range().accept(this)); - } else if (predicate.name() == RelationPredicate.Name.TOTAL_ORDERING) { - final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) predicate; - return cache(predicate, tp.ordered().accept(this) || tp.first().accept(this) || tp.last().accept(this)); - } - return cache(predicate, false); - } - - @Override - public Boolean visit(FixFormula fixFormula) { - final Boolean ret = lookup(fixFormula); - return (ret != null) ? ret : cache(fixFormula, fixFormula.formula().accept(this) || fixFormula.condition().accept(this)); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractReplacer.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractReplacer.java deleted file mode 100644 index d4007e354..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractReplacer.java +++ /dev/null @@ -1,746 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.visitor; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.Multiplicity; - -/** - * A depth first replacer. The default implementation returns the tree to which - * it is applied. Reference equality is used to determine if two nodes are the - * same. - * - * @specfield cached: set Node // result of visiting these nodes will be cached - * @specfield cache: Node ->lone Node - * @invariant cached in cache.Node - * @author Emina Torlak - */ -public abstract class AbstractReplacer implements ReturnVisitor { - - protected final Map cache; - protected final Set cached; - protected ReturnVisitor delegate; - - /** - * Constructs a depth-first replaces which will cache the results of visiting - * the given nodes and re-use them on subsequent visits. - * - * @ensures this.cached' = cached && no this.cache' - */ - protected AbstractReplacer(Set cached) { - this(cached, new IdentityHashMap(cached.size()), null); - } - - protected AbstractReplacer(Set cached, ReturnVisitor delegate) { - this(cached, new IdentityHashMap(cached.size()), delegate); - } - - protected AbstractReplacer(Set cached, Map cache) { - this(cached, cache, null); - } - - /** - * Constructs a depth-first replacer which will cache the results of visiting - * the given nodes in the given map, and re-use them on subsequent visits. - * - * @param delegate - * @ensures this.cached' = cached && this.cache' = cache - */ - protected AbstractReplacer(Set cached, Map cache, ReturnVisitor delegate) { - this.cached = cached; - this.cache = cache; - this.delegate = delegate == null ? this : delegate; - } - - /** - * If the given node has already been visited and its replacement cached, the - * cached value is returned. Otherwise, null is returned. - * - * @return this.cache[node] - */ - @SuppressWarnings("unchecked" ) - protected N lookup(N node) { - return (N) cache.get(node); - } - - /** - * Caches the given replacement for the specified node, if this is a caching - * visitor. Otherwise does nothing. The method returns the replacement node. - * - * @ensures node in this.cached => this.cache' = this.cache ++ - * node->replacement, this.cache' = this.cache - * @return replacement - */ - protected N cache(N node, N replacement) { - if (cached.contains(node)) { - cache.put(node, replacement); - } - return replacement; - } - - /** - * Calls lookup(decls) and returns the cached value, if any. If a replacement - * has not been cached, visits each of the children's variable and expression. - * If nothing changes, the argument is cached and returned, otherwise a - * replacement Decls object is cached and returned. - * - * @return { d: Decls | d.size = decls.size && all i: [0..d.size) | - * d.declarations[i] = decls.declarations[i].accept(delegate) } - */ - @Override - public Decls visit(Decls decls) { - Decls ret = lookup(decls); - if (ret != null) - return ret; - - Decls visitedDecls = null; - boolean allSame = true; - for (Decl decl : decls) { - Decls newDecl = visit(decl); - if (newDecl != decl) - allSame = false; - visitedDecls = (visitedDecls == null) ? newDecl : visitedDecls.and(newDecl); - } - ret = allSame ? decls : visitedDecls; - return cache(decls, ret); - } - - /** - * Calls lookup(decl) and returns the cached value, if any. If a replacement has - * not been cached, visits the declaration's variable and expression. If nothing - * changes, the argument is cached and returned, otherwise a replacement Decl - * object is cached and returned. - * - * @return { d: Declaration | d.variable = declaration.variable.accept(delegate) - * && d.multiplicity = decl.multiplicity && d.expression = - * declaration.expression.accept(delegate) - */ - @Override - public Decl visit(Decl decl) { - Decl ret = lookup(decl); - if (ret != null) - return ret; - - final Variable variable = (Variable) decl.variable().accept(delegate); - final Expression expression = decl.expression().accept(delegate); - ret = (variable == decl.variable() && expression == decl.expression()) ? decl : variable.declare(decl.multiplicity(), expression); - return cache(decl, ret); - } - - /** - * Calls lookup(relation) and returns the cached value, if any. If a replacement - * has not been cached, the relation is cached and returned. - * - * @return relation - */ - @Override - public Expression visit(Relation relation) { - final Expression ret = lookup(relation); - return ret == null ? cache(relation, relation) : ret; - } - - /** - * Calls lookup(variable) and returns the cached value, if any. If a replacement - * has not been cached, the variable is cached and returned. - * - * @return variable - */ - @Override - public Expression visit(Variable variable) { - final Expression ret = lookup(variable); - return ret == null ? cache(variable, variable) : variable; - } - - /** - * Calls lookup(constExpr) and returns the cached value, if any. If a - * replacement has not been cached, the constExpr is cached and returned. - * - * @return constExpr - */ - @Override - public Expression visit(ConstantExpression constExpr) { - final Expression ret = lookup(constExpr); - return ret == null ? cache(constExpr, constExpr) : constExpr; - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If a replacement has - * not been cached, visits the expr's children. If nothing changes, the argument - * is cached and returned, otherwise a replacement expr is cached and returned. - * - * @return { e: Expression | e.op = expr.op && #e.children = #expr.children && - * all i: [0..expr.children) | e.child(i) = - * expr.child(i).accept(delegate) } - */ - @Override - public Expression visit(NaryExpression expr) { - Expression ret = lookup(expr); - if (ret != null) - return ret; - - final Expression[] visited = new Expression[expr.size()]; - boolean allSame = true; - for (int i = 0; i < visited.length; i++) { - final Expression child = expr.child(i); - visited[i] = child.accept(delegate); - allSame = allSame && visited[i] == child; - } - - ret = allSame ? expr : Expression.compose(expr.op(), visited); - return cache(expr, ret); - } - - /** - * Calls lookup(binExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's children. If nothing changes, - * the argument is cached and returned, otherwise a replacement expression is - * cached and returned. - * - * @return { b: BinaryExpression | b.left = binExpr.left.accept(delegate) && - * b.right = binExpr.right.accept(delegate) && b.op = binExpr.op } - */ - @Override - public Expression visit(BinaryExpression binExpr) { - Expression ret = lookup(binExpr); - if (ret != null) - return ret; - - final Expression left = binExpr.left().accept(delegate); - final Expression right = binExpr.right().accept(delegate); - ret = (left == binExpr.left() && right == binExpr.right()) ? binExpr : left.compose(binExpr.op(), right); - return cache(binExpr, ret); - } - - /** - * Calls lookup(unaryExpr) and returns the cached value, if any. If a - * replacement has not been cached, visits the expression's child. If nothing - * changes, the argument is cached and returned, otherwise a replacement - * expression is cached and returned. - * - * @return { u: UnaryExpression | u.left = unaryExpr.expression.accept(delegate) - * && u.op = unaryExpr.op } - */ - @Override - public Expression visit(UnaryExpression unaryExpr) { - Expression ret = lookup(unaryExpr); - if (ret != null) - return ret; - - final Expression child = unaryExpr.expression().accept(delegate); - ret = (child == unaryExpr.expression()) ? unaryExpr : child.apply(unaryExpr.op()); - return cache(unaryExpr, ret); - } - - /** - * Calls lookup(comprehension) and returns the cached value, if any. If a - * replacement has not been cached, visits the expression's children. If nothing - * changes, the argument is cached and returned, otherwise a replacement - * expression is cached and returned. - * - * @return { c: Comprehension | c.declarations = - * comprehension.declarations.accept(delegate) && c.formula = - * comprehension.formula.accept(delegate) } - */ - @Override - public Expression visit(Comprehension comprehension) { - Expression ret = lookup(comprehension); - if (ret != null) - return ret; - - final Decls decls = comprehension.decls().accept(delegate); - final Formula formula = comprehension.formula().accept(delegate); - ret = (decls == comprehension.decls() && formula == comprehension.formula()) ? comprehension : formula.comprehension(decls); - return cache(comprehension, ret); - } - - /** - * Calls lookup(ifExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's children. If nothing changes, - * the argument is cached and returned, otherwise a replacement expression is - * cached and returned. - * - * @return { i: IfExpression | i.condition = ifExpr.condition.accept(delegate) - * && i.thenExpr = ifExpr.thenExpr.accept(delegate) && i.elseExpr = - * ifExpr.elseExpr.accept(delegate) } - */ - @Override - public Expression visit(IfExpression ifExpr) { - Expression ret = lookup(ifExpr); - if (ret != null) - return ret; - - final Formula condition = ifExpr.condition().accept(delegate); - final Expression thenExpr = ifExpr.thenExpr().accept(delegate); - final Expression elseExpr = ifExpr.elseExpr().accept(delegate); - ret = (condition == ifExpr.condition() && thenExpr == ifExpr.thenExpr() && elseExpr == ifExpr.elseExpr()) ? ifExpr : condition.thenElse(thenExpr, elseExpr); - return cache(ifExpr, ret); - } - - /** - * Calls lookup(decls) and returns the cached value, if any. If a replacement - * has not been cached, visits each of the children's variable and expression. - * If nothing changes, the argument is cached and returned, otherwise a - * replacement Decls object is cached and returned. - * - * @return { d: Decls | d.size = decls.size && all i: [0..d.size) | - * d.declarations[i] = decls.declarations[i].accept(delegate) } - */ - @Override - public Expression visit(ProjectExpression project) { - Expression ret = lookup(project); - if (ret != null) - return ret; - - final Expression expr = project.expression().accept(delegate); - final IntExpression[] cols = new IntExpression[project.arity()]; - boolean allSame = expr == project.expression(); - for (int i = 0, arity = project.arity(); i < arity; i++) { - cols[i] = project.column(i).accept(delegate); - allSame = allSame && (cols[i] == project.column(i)); - } - ret = allSame ? project : expr.project(cols); - return cache(project, ret); - } - - /** - * Calls lookup(castExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's child. If nothing changes, the - * argument is cached and returned, otherwise a replacement expression is cached - * and returned. - * - * @return { e: Expression | e = - * castExpr.intExpr.accept(delegate).toExpression() } - */ - @Override - public Expression visit(IntToExprCast castExpr) { - Expression ret = lookup(castExpr); - if (ret != null) - return ret; - - final IntExpression intExpr = castExpr.intExpr().accept(delegate); - ret = (intExpr == castExpr.intExpr()) ? castExpr : intExpr.cast(castExpr.op()); - return cache(castExpr, ret); - } - - /** - * Calls lookup(intconst) and returns the cached value, if any. If a replacement - * has not been cached, the constant is cached and returned. - * - * @return intconst - */ - @Override - public IntExpression visit(IntConstant intconst) { - IntExpression ret = lookup(intconst); - return ret == null ? cache(intconst, intconst) : intconst; - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's children. If nothing changes, - * the argument is cached and returned, otherwise a replacement expression is - * cached and returned. - * - * @return { i: IfIntExpression | i.condition = - * intExpr.condition.accept(delegate) && i.thenExpr = - * intExpr.thenExpr.accept(delegate) && i.elseExpr = - * intExpr.elseExpr.accept(delegate) } - */ - @Override - public IntExpression visit(IfIntExpression intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - - final Formula condition = intExpr.condition().accept(delegate); - final IntExpression thenExpr = intExpr.thenExpr().accept(delegate); - final IntExpression elseExpr = intExpr.elseExpr().accept(delegate); - ret = (condition == intExpr.condition() && thenExpr == intExpr.thenExpr() && elseExpr == intExpr.elseExpr()) ? intExpr : condition.thenElse(thenExpr, elseExpr); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's child. If nothing changes, the - * argument is cached and returned, otherwise a replacement expression is cached - * and returned. - * - * @return { i: ExprToIntCast | i.expression = - * intExpr.expression.accept(delegate) && i.op = intExpr.op} - */ - @Override - public IntExpression visit(ExprToIntCast intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - - final Expression expr = intExpr.expression().accept(delegate); - ret = expr == intExpr.expression() ? intExpr : expr.apply(intExpr.op()); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the intExpr's children. If nothing changes, the - * argument is cached and returned, otherwise a replacement intExpr is cached - * and returned. - * - * @return { e: IntExpression | e.op = intExpr.op && #e.children = - * #intExpr.children && all i: [0..intExpr.children) | e.child(i) = - * intExpr.child(i).accept(delegate) } - */ - @Override - public IntExpression visit(NaryIntExpression intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - - final IntExpression[] visited = new IntExpression[intExpr.size()]; - boolean allSame = true; - for (int i = 0; i < visited.length; i++) { - final IntExpression child = intExpr.child(i); - visited[i] = child.accept(delegate); - allSame = allSame && visited[i] == child; - } - - ret = allSame ? intExpr : IntExpression.compose(intExpr.op(), visited); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's children. If nothing changes, - * the argument is cached and returned, otherwise a replacement expression is - * cached and returned. - * - * @return { c: IntExpression | [[c]] = intExpr.left.accept(delegate) op - * intExpr.right.accept(delegate) } - */ - @Override - public IntExpression visit(BinaryIntExpression intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - - final IntExpression left = intExpr.left().accept(delegate); - final IntExpression right = intExpr.right().accept(delegate); - ret = (left == intExpr.left() && right == intExpr.right()) ? intExpr : left.compose(intExpr.op(), right); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's child. If nothing changes, the - * argument is cached and returned, otherwise a replacement expression is cached - * and returned. - * - * @return { u: UnaryIntExpression | u.expression = - * intExpr.expression.accept(delegate) && u.op = intExpr.op } - */ - @Override - public IntExpression visit(UnaryIntExpression intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - - final IntExpression child = intExpr.intExpr().accept(delegate); - ret = (child == intExpr.intExpr()) ? intExpr : child.apply(intExpr.op()); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a replacement - * has not been cached, visits the expression's children. If nothing changes, - * the argument is cached and returned, otherwise a replacement expression is - * cached and returned. - * - * @return { c: IntExpression | [[c]] = sum intExpr.decls.accept(delegate) | - * intExpr.intExpr.accept(delegate) } - */ - @Override - public IntExpression visit(SumExpression intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - - final Decls decls = intExpr.decls().accept(delegate); - final IntExpression expr = intExpr.intExpr().accept(delegate); - ret = (decls == intExpr.decls() && expr == intExpr.intExpr()) ? intExpr : expr.sum(decls); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intComp) and returns the cached value, if any. If a replacement - * has not been cached, visits the formula's children. If nothing changes, the - * argument is cached and returned, otherwise a replacement formula is cached - * and returned. - * - * @return { c: Formula | [[c]] = intComp.left.accept(delegate) op - * intComp.right.accept(delegate) } - */ - @Override - public Formula visit(IntComparisonFormula intComp) { - Formula ret = lookup(intComp); - if (ret != null) - return ret; - - final IntExpression left = intComp.left().accept(delegate); - final IntExpression right = intComp.right().accept(delegate); - ret = (left == intComp.left() && right == intComp.right()) ? intComp : left.compare(intComp.op(), right); - return cache(intComp, ret); - } - - /** - * Calls lookup(constant) and returns the cached value, if any. If a replacement - * has not been cached, the constant is cached and returned. - * - * @return constant - */ - @Override - public Formula visit(ConstantFormula constant) { - final Formula ret = lookup(constant); - return ret == null ? cache(constant, constant) : constant; - } - - /** - * Calls lookup(quantFormula) and returns the cached value, if any. If a - * replacement has not been cached, visits the formula's children. If nothing - * changes, the argument is cached and returned, otherwise a replacement formula - * is cached and returned. - * - * @return { q: QuantifiedFormula | q.declarations = - * quantFormula.declarations.accept(delegate) && q.formula = - * quantFormula.formula.accept(delegate) } - */ - @Override - public Formula visit(QuantifiedFormula quantFormula) { - Formula ret = lookup(quantFormula); - if (ret != null) - return ret; - - final Decls decls = quantFormula.decls().accept(delegate); - final Formula domain = quantFormula.domain().accept(delegate); - final Formula body = quantFormula.body().accept(delegate); - ret = (decls == quantFormula.decls() && domain == quantFormula.domain() && body == quantFormula.body()) ? quantFormula : body.quantify(quantFormula.quantifier(), decls, domain); - return cache(quantFormula, ret); - } - - /** - * Calls lookup(formula) and returns the cached value, if any. If a replacement - * has not been cached, visits the formula's children. If nothing changes, the - * argument is cached and returned, otherwise a replacement formula is cached - * and returned. - * - * @return { e: Expression | e.op = formula.op && #e.children = - * #formula.children && all i: [0..formula.children) | e.child(i) = - * formula.child(i).accept(delegate) } - */ - @Override - public Formula visit(NaryFormula formula) { - Formula ret = lookup(formula); - if (ret != null) - return ret; - - final Formula[] visited = new Formula[formula.size()]; - boolean allSame = true; - for (int i = 0; i < visited.length; i++) { - final Formula child = formula.child(i); - visited[i] = child.accept(delegate); - allSame = allSame && visited[i] == child; - } - - ret = allSame ? formula : Formula.compose(formula.op(), visited); - return cache(formula, ret); - } - - /** - * Calls lookup(binFormula) and returns the cached value, if any. If a - * replacement has not been cached, visits the formula's children. If nothing - * changes, the argument is cached and returned, otherwise a replacement formula - * is cached and returned. - * - * @return { b: BinaryFormula | b.left = binExpr.left.accept(delegate) && - * b.right = binExpr.right.accept(delegate) && b.op = binExpr.op } - */ - @Override - public Formula visit(BinaryFormula binFormula) { - Formula ret = lookup(binFormula); - if (ret != null) - return ret; - - final Formula left = binFormula.left().accept(delegate); - final Formula right = binFormula.right().accept(delegate); - ret = (left == binFormula.left() && right == binFormula.right()) ? binFormula : left.compose(binFormula.op(), right); - return cache(binFormula, ret); - } - - /** - * Calls lookup(binFormula) and returns the cached value, if any. If a - * replacement has not been cached, visits the formula's child. If nothing - * changes, the argument is cached and returned, otherwise a replacement formula - * is cached and returned. - * - * @return { n: NotFormula | n.child = not.child.accept(delegate) } - */ - @Override - public Formula visit(NotFormula not) { - Formula ret = lookup(not); - if (ret != null) - return ret; - - final Formula child = not.formula().accept(delegate); - ret = (child == not.formula()) ? not : child.not(); - return cache(not, ret); - } - - /** - * Calls lookup(compFormula) and returns the cached value, if any. If a - * replacement has not been cached, visits the formula's children. If nothing - * changes, the argument is cached and returned, otherwise a replacement formula - * is cached and returned. - * - * @return { c: ComparisonFormula | c.left = compFormula.left.accept(delegate) - * && c.right = compFormula.right.accept(delegate) && c.op = - * compFormula.op } - */ - @Override - public Formula visit(ComparisonFormula compFormula) { - Formula ret = lookup(compFormula); - if (ret != null) - return ret; - - final Expression left = compFormula.left().accept(delegate); - final Expression right = compFormula.right().accept(delegate); - ret = (left == compFormula.left() && right == compFormula.right()) ? compFormula : left.compare(compFormula.op(), right); - return cache(compFormula, ret); - } - - /** - * Calls lookup(multFormula) and returns the cached value, if any. If a - * replacement has not been cached, visits the formula's children. If nothing - * changes, the argument is cached and returned, otherwise a replacement formula - * is cached and returned. - * - * @return { m: MultiplicityFormula | m.multiplicity = multFormula.multiplicity - * && m.expression = multFormula.expression.accept(delegate) } - */ - @Override - public Formula visit(MultiplicityFormula multFormula) { - Formula ret = lookup(multFormula); - if (ret != null) - return ret; - - final Expression expression = multFormula.expression().accept(delegate); - ret = (expression == multFormula.expression()) ? multFormula : expression.apply(multFormula.multiplicity()); - return cache(multFormula, ret); - } - - /** - * Calls lookup(pred) and returns the cached value, if any. If a replacement has - * not been cached, visits the formula's children. If nothing changes, the - * argument is cached and returned, otherwise a replacement formula is cached - * and returned. - * - * @return { p: RelationPredicate | p.name = pred.name && p.relation = - * pred.relation.accept(delegate) && p.name = FUNCTION => p.targetMult = - * pred.targetMult && p.domain = pred.domain.accept(delegate) && p.range - * = pred.range.accept(delegate), p.name = TOTAL_ORDERING => p.ordered = - * pred.ordered.accept(delegate) && p.first = - * pred.first.accept(delegate) && p.last = pred.last.accept(delegate) } - */ - @Override - public Formula visit(RelationPredicate pred) { - Formula ret = lookup(pred); - if (ret != null) - return ret; - - final Relation r = (Relation) pred.relation().accept(delegate); - switch (pred.name()) { - case ACYCLIC : - ret = (r == pred.relation()) ? pred : r.acyclic(); - break; - case FUNCTION : - final RelationPredicate.Function fp = (RelationPredicate.Function) pred; - final Expression domain = fp.domain().accept(delegate); - final Expression range = fp.range().accept(delegate); - ret = (r == fp.relation() && domain == fp.domain() && range == fp.range()) ? fp : (fp.targetMult() == Multiplicity.ONE ? r.function(domain, range) : r.partialFunction(domain, range)); - break; - case TOTAL_ORDERING : - final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; - final Relation ordered = (Relation) tp.ordered().accept(delegate); - final Relation first = (Relation) tp.first().accept(delegate); - final Relation last = (Relation) tp.last().accept(delegate); - ret = (r == tp.relation() && ordered == tp.ordered() && first == tp.first() && last == tp.last()) ? tp : r.totalOrder(ordered, first, last); - break; - default : - throw new IllegalArgumentException("unknown relation predicate: " + pred.name()); - } - return cache(pred, ret); - } - - @Override - public Formula visit(FixFormula fixFormula) { - Formula ret = lookup(fixFormula); - if (ret != null) - return ret; - final Formula formula = fixFormula.formula().accept(delegate); - final Formula condition = fixFormula.condition().accept(delegate); - ret = (formula == fixFormula.formula() && condition == fixFormula.condition()) ? fixFormula : formula.fix(condition); - return cache(fixFormula, ret); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractVoidVisitor.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractVoidVisitor.java deleted file mode 100644 index 9b69d30fe..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AbstractVoidVisitor.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.visitor; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; - -/** - * Implements a depth first traversal of the kodkod AST. - * - * @author Emina Torlak - */ -public abstract class AbstractVoidVisitor implements VoidVisitor { - - protected AbstractVoidVisitor() {} - - /** - * Returns true if this node has already been visited. Otherwise returns false. - * - * @return true if this node has already been visited. - */ - protected abstract boolean visited(Node n); - - /** - * Visits all the children of the given declarations node if this.visited(decls) - * returns false. Otherwise does nothing. - * - * @ensures all d: declarations.declarations | d.variable.accept(this) && - * d.expression.accept(this) - */ - @Override - public void visit(Decls decls) { - if (visited(decls)) - return; - for (Decl decl : decls) { - decl.accept(this); - } - } - - /** - * Visits the variable and expression of this decl if this.visited(decl) returns - * false. Otherwise does nothing. - * - * @ensures decl.variable.accept(this) && decl.expression.accept(this) - */ - @Override - public void visit(Decl decl) { - if (visited(decl)) - return; - decl.variable().accept(this); - decl.expression().accept(this); - } - - /** - * Does nothing. - */ - @Override - public void visit(Relation relation) {} - - /** - * Does nothing. - */ - @Override - public void visit(Variable variable) {} - - /** - * Does nothing. - */ - @Override - public void visit(ConstantExpression constExpr) {} - - /** - * Visits the children if this.visited(expr) returns false. Otherwise does - * nothing. - * - * @ensures all i: [0..#expr.children) | expr.child(i).accept(this) - */ - @Override - public void visit(NaryExpression expr) { - if (visited(expr)) - return; - for (Expression child : expr) { - child.accept(this); - } - } - - /** - * Visits the left and right subexpressions if this.visited(binExpr) returns - * false. Otherwise does nothing. - * - * @ensures binExpr.left.accept(this) && binExpr.right.accept(this) - */ - @Override - public void visit(BinaryExpression binExpr) { - if (visited(binExpr)) - return; - binExpr.left().accept(this); - binExpr.right().accept(this); - } - - /** - * Visits the subexpression if this.visited(unaryExpr) returns false. Otherwise - * does nothing. - * - * @ensures unaryExpr.expression.accept(this) - */ - @Override - public void visit(UnaryExpression unaryExpr) { - if (visited(unaryExpr)) - return; - unaryExpr.expression().accept(this); - } - - /** - * Visits the declarations and the formula if this.visited(comprehension) - * returns false. Otherwise does nothing. - * - * @ensures comprehension.declarations.accept(this) && - * comprehension.formula.accept(this) - */ - @Override - public void visit(Comprehension comprehension) { - if (visited(comprehension)) - return; - comprehension.decls().accept(this); - comprehension.formula().accept(this); - } - - /** - * Visits the if-condition, the then-expression, and the else-expression if - * this.visited(ifExpr) returns false. Otherwise does nothing. - * - * @ensures ifExpr.condition.accept(this) && ifExpr.thenExpr.accept(this) && - * ifExpr.elseExpr.accept(this) - */ - @Override - public void visit(IfExpression ifExpr) { - if (visited(ifExpr)) - return; - ifExpr.condition().accept(this); - ifExpr.thenExpr().accept(this); - ifExpr.elseExpr().accept(this); - } - - /** - * Visits project.expression and project.columns if this.visited(project) - * returns false. Otherwise does nothing. - * - * @ensures project.expression.accept(this) && all i: project.arity | - * project.columns[i].accept(this) - */ - @Override - public void visit(ProjectExpression project) { - if (visited(project)) - return; - project.expression().accept(this); - for (int i = 0, arity = project.arity(); i < arity; i++) { - project.column(i).accept(this); - } - } - - /** - * Visits castExpr.intExpr if this.visited(castExpr) returns false. Otherwise - * does nothing. - * - * @ensures castExpr.expression.accept(this) - */ - @Override - public void visit(IntToExprCast castExpr) { - if (visited(castExpr)) - return; - castExpr.intExpr().accept(this); - } - - /** - * Does nothing. - */ - @Override - public void visit(IntConstant intConst) {} - - /** - * Visits the if-condition, the then-expression, and the else-expression if - * this.visited(intExpr) returns false. Otherwise does nothing. - * - * @ensures intExpr.condition.accept(this) && intExpr.thenExpr.accept(this) && - * intExpr.elseExpr.accept(this) - */ - @Override - public void visit(IfIntExpression intExpr) { - if (visited(intExpr)) - return; - intExpr.condition().accept(this); - intExpr.thenExpr().accept(this); - intExpr.elseExpr().accept(this); - } - - /** - * Visits intExpr.expression if this.visited(intExpr) returns false. Otherwise - * does nothing. - * - * @ensures intExpr.expression.accept(this) - */ - @Override - public void visit(ExprToIntCast intExpr) { - if (visited(intExpr)) - return; - intExpr.expression().accept(this); - } - - /** - * Visits the children if this.visited(intExpr) returns false. Otherwise does - * nothing. - * - * @ensures all i: [0..#intExpr.children) | intExpr.child(i).accept(this) - */ - @Override - public void visit(NaryIntExpression intExpr) { - if (visited(intExpr)) - return; - for (IntExpression child : intExpr) { - child.accept(this); - } - } - - /** - * Visits the children of the given integer expression if this.visited(intExpr) - * returns false. Otherwise does nothing. - * - * @ensures intExpr.left.accept(this) && intExpr.right.accept(this) - */ - @Override - public void visit(BinaryIntExpression intExpr) { - if (visited(intExpr)) - return; - intExpr.left().accept(this); - intExpr.right().accept(this); - } - - /** - * Visits the subexpression if this.visited(intExpr) returns false. Otherwise - * does nothing. - * - * @ensures unaryExpr.expression.accept(this) - */ - @Override - public void visit(UnaryIntExpression intExpr) { - if (visited(intExpr)) - return; - intExpr.intExpr().accept(this); - } - - /** - * Visits the children of the given sum expression if this.visited(intExpr) - * returns false. Otherwise does nothing. - * - * @ensures intExpr.decls.accept(this) && intExpr.intExpr.accept(this) - */ - @Override - public void visit(SumExpression intExpr) { - if (visited(intExpr)) - return; - intExpr.decls().accept(this); - intExpr.intExpr().accept(this); - } - - /** - * Visits the children of the given integer comparison formula if - * this.visited(intComp) returns false. Otherwise does nothing. - * - * @ensures intComp.left.accept(this) && intComp.right.accept(this) - */ - @Override - public void visit(IntComparisonFormula intComp) { - if (visited(intComp)) - return; - intComp.left().accept(this); - intComp.right().accept(this); - } - - /** - * Visits the declarations and the formula if this.visited(quantFormula) returns - * false. Otherwise does nothing. - * - * @ensures quantFormula.declarations.accept(this) && - * quantFormula.formula.accept(this) - */ - @Override - public void visit(QuantifiedFormula quantFormula) { - if (visited(quantFormula)) - return; - quantFormula.decls().accept(this); - quantFormula.formula().accept(this); - } - - /** - * Visits the children if this.visited(formula) returns false. Otherwise does - * nothing. - * - * @ensures all i: [0..#formula.children) | formula.child(i).accept(this) - */ - @Override - public void visit(NaryFormula formula) { - if (visited(formula)) - return; - for (Formula child : formula) { - child.accept(this); - } - } - - /** - * Visits the left and right children if this.visited(binFormula) returns false. - * Otherwise does nothing. - * - * @ensures binFormula.left.accept(this) && binFormula.right.accept(this) - */ - @Override - public void visit(BinaryFormula binFormula) { - if (visited(binFormula)) - return; - binFormula.left().accept(this); - binFormula.right().accept(this); - } - - /** - * Visits the subformula if this.visited(not) returns false. Otherwise does - * nothing. - * - * @ensures not.formula.accept(this) - */ - @Override - public void visit(NotFormula not) { - if (visited(not)) - return; - not.formula().accept(this); - } - - /** - * Does nothing. - */ - @Override - public void visit(ConstantFormula constant) {} - - /** - * Visits the left and right children if this.visited(compFormula) returns - * false. Otherwise does nothing. - * - * @ensures compFormula.left.accept(this) && compFormula.right.accept(this) - */ - @Override - public void visit(ComparisonFormula compFormula) { - if (visited(compFormula)) - return; - compFormula.left().accept(this); - compFormula.right().accept(this); - } - - /** - * Visits the formula if this.visited(multFormula) returns false. Otherwise does - * nothing. - * - * @ensures multFormula.expression.accept(this) - */ - @Override - public void visit(MultiplicityFormula multFormula) { - if (visited(multFormula)) - return; - multFormula.expression().accept(this); - } - - /** - * Visits the children of the predicate if this.visited(pred) returns false. - * Otherwise does nothing. - * - * @ensures pred.relation.accept(this) && (pred.name = FUNCTION => - * pred.domain.accept(this) && pred.range.accept(this)) && (pred.name = - * TOTAL_ORDERING => pred.ordered.accept(this) && - * pred.first.accept(this) && pred.last.accept(this) ) - */ - @Override - public void visit(RelationPredicate pred) { - if (visited(pred)) - return; - pred.relation().accept(this); - if (pred.name() == RelationPredicate.Name.FUNCTION) { - final RelationPredicate.Function fp = (RelationPredicate.Function) pred; - fp.domain().accept(this); - fp.range().accept(this); - } else if (pred.name() == RelationPredicate.Name.TOTAL_ORDERING) { - final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; - tp.ordered().accept(this); - tp.first().accept(this); - tp.last().accept(this); - } - } - - @Override - public void visit(FixFormula fixFormula) { - if (visited(fixFormula)) - return; - fixFormula.formula().accept(this); - fixFormula.condition().accept(this); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AspectReturnVisitor.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AspectReturnVisitor.java deleted file mode 100644 index 00ba58295..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/AspectReturnVisitor.java +++ /dev/null @@ -1,222 +0,0 @@ -package kodkod.ast.visitor; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.FixFormula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; - -public abstract class AspectReturnVisitor implements ReturnVisitor { - - protected final ReturnVisitor visitor; - - public AspectReturnVisitor(ReturnVisitor visitor) { - this.visitor = visitor; - } - - protected void start(Node n) {} - - protected T end(Node n, T ans) { - return ans; - } - - @Override - public D visit(Decls decls) { - start(decls); - return end(decls, visitor.visit(decls)); - } - - @Override - public D visit(Decl decl) { - start(decl); - return end(decl, visitor.visit(decl)); - } - - @Override - public E visit(Relation relation) { - start(relation); - return end(relation, visitor.visit(relation)); - } - - @Override - public E visit(Variable variable) { - start(variable); - return end(variable, visitor.visit(variable)); - } - - @Override - public E visit(ConstantExpression constExpr) { - start(constExpr); - return end(constExpr, visitor.visit(constExpr)); - } - - @Override - public E visit(NaryExpression expr) { - start(expr); - return end(expr, visitor.visit(expr)); - } - - @Override - public E visit(BinaryExpression binExpr) { - start(binExpr); - return end(binExpr, visitor.visit(binExpr)); - } - - @Override - public E visit(UnaryExpression unaryExpr) { - start(unaryExpr); - return end(unaryExpr, visitor.visit(unaryExpr)); - } - - @Override - public E visit(Comprehension comprehension) { - start(comprehension); - return end(comprehension, visitor.visit(comprehension)); - } - - @Override - public E visit(IfExpression ifExpr) { - start(ifExpr); - return end(ifExpr, visitor.visit(ifExpr)); - } - - @Override - public E visit(ProjectExpression project) { - start(project); - return end(project, visitor.visit(project)); - } - - @Override - public E visit(IntToExprCast castExpr) { - start(castExpr); - return end(castExpr, visitor.visit(castExpr)); - } - - @Override - public I visit(IntConstant intConst) { - start(intConst); - return end(intConst, visitor.visit(intConst)); - } - - @Override - public I visit(IfIntExpression intExpr) { - start(intExpr); - return end(intExpr, visitor.visit(intExpr)); - } - - @Override - public I visit(ExprToIntCast intExpr) { - start(intExpr); - return end(intExpr, visitor.visit(intExpr)); - } - - @Override - public I visit(NaryIntExpression intExpr) { - start(intExpr); - return end(intExpr, visitor.visit(intExpr)); - } - - @Override - public I visit(BinaryIntExpression intExpr) { - start(intExpr); - return end(intExpr, visitor.visit(intExpr)); - } - - @Override - public I visit(UnaryIntExpression intExpr) { - start(intExpr); - return end(intExpr, visitor.visit(intExpr)); - } - - @Override - public I visit(SumExpression intExpr) { - start(intExpr); - return end(intExpr, visitor.visit(intExpr)); - } - - @Override - public F visit(IntComparisonFormula intComp) { - start(intComp); - return end(intComp, visitor.visit(intComp)); - } - - @Override - public F visit(ConstantFormula constant) { - start(constant); - return end(constant, visitor.visit(constant)); - } - - @Override - public F visit(QuantifiedFormula quantFormula) { - start(quantFormula); - return end(quantFormula, visitor.visit(quantFormula)); - } - - @Override - public F visit(NaryFormula formula) { - start(formula); - return end(formula, visitor.visit(formula)); - } - - @Override - public F visit(BinaryFormula binFormula) { - start(binFormula); - return end(binFormula, visitor.visit(binFormula)); - } - - @Override - public F visit(NotFormula not) { - start(not); - return end(not, visitor.visit(not)); - } - - @Override - public F visit(ComparisonFormula compFormula) { - start(compFormula); - return end(compFormula, visitor.visit(compFormula)); - } - - @Override - public F visit(MultiplicityFormula multFormula) { - start(multFormula); - return end(multFormula, visitor.visit(multFormula)); - } - - @Override - public F visit(RelationPredicate pred) { - start(pred); - return end(pred, visitor.visit(pred)); - } - - @Override - public F visit(FixFormula fixFormula) { - start(fixFormula); - return end(fixFormula, visitor.visit(fixFormula)); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/ReturnVisitor.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/ReturnVisitor.java deleted file mode 100644 index 6d3c98f0e..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/ReturnVisitor.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.visitor; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.FixFormula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; - -/** - * A visitor that visits every node in the AST, returning some value for each. - * The methods that visit an {@link kodkod.ast.Expression expression}, - * {@link kodkod.ast.Formula formula}, {@link kodkod.ast.Decls declarations}, - * and {@link kodkod.ast.IntExpression integer expression} and return values of - * types E, F, D, and I respectively. - * - * @author Emina Torlak - */ -public interface ReturnVisitor { - - /** - * Visits the given sequence of declarations and returns the result. - * - * @return the result of visiting decls - **/ - public D visit(Decls decls); - - /** - * Visits the given declaration and returns the result. - * - * @return the result of visiting decl - **/ - public D visit(Decl decl); - - /** - * Visits the given relation and returns the result. - * - * @return the result of visiting relation - **/ - public E visit(Relation relation); - - /** - * Visits the given variable and returns the result. - * - * @return the result of visiting variable - **/ - public E visit(Variable variable); - - /** - * Visits the given constant expression and returns the result. - * - * @return the result of visiting constExpr - **/ - public E visit(ConstantExpression constExpr); - - /** - * Visits the given unary expression and returns the result. - * - * @return the result of visiting unaryExpr - **/ - public E visit(UnaryExpression unaryExpr); - - /** - * Visits the given binary expression and returns the result. - * - * @return the result of visiting binExpr - **/ - public E visit(BinaryExpression binExpr); - - /** - * Visits the given nary expression and returns the result. - * - * @return the result of visiting expr - **/ - public E visit(NaryExpression expr); - - /** - * Visits the given comprehension and returns the result. - * - * @return the result of visiting comprehension - **/ - public E visit(Comprehension comprehension); - - /** - * Visits the given if-then expression and returns the result. - * - * @return the result of visiting ifExpr - **/ - public E visit(IfExpression ifExpr); - - /** - * Visits the given projection expression and returns the result. - * - * @return the result of visiting project - */ - public E visit(ProjectExpression project); - - /** - * Visits the given cast expression expression and returns the result. - * - * @return the result of visiting castExpr - **/ - public E visit(IntToExprCast castExpr); - - /** - * Visits the given integer constant and returns the result. - * - * @return the result of visiting intConst - */ - public I visit(IntConstant intConst); - - /** - * Visits the given if-int-expression and returns the result. - * - * @return the result of visiting intExpr - */ - public I visit(IfIntExpression intExpr); - - /** - * Visits the given unary integer expression and returns the result. - * - * @return the result of visiting intExpr - */ - public I visit(ExprToIntCast intExpr); - - /** - * Visits the given nary expression and returns the result. - * - * @return the result of visiting intExpr - **/ - public I visit(NaryIntExpression intExpr); - - /** - * Visits the given binary integer expression and returns the result. - * - * @return the result of visiting intExpr - */ - public I visit(BinaryIntExpression intExpr); - - /** - * Visits the given unary integer expression and returns the result. - * - * @return the result of visiting intExpr - */ - public I visit(UnaryIntExpression intExpr); - - /** - * Visits the given sum expression and returns the result. - * - * @return the result of visiting intExpr - */ - public I visit(SumExpression intExpr); - - /** - * Visits the given integer comparison formula and returns the result. - * - * @return the result of visiting intcomp - */ - public F visit(IntComparisonFormula intComp); - - /** - * Visits the given quantified formula and returns the result. - * - * @return the result of visiting quantFormula - **/ - public F visit(QuantifiedFormula quantFormula); - - /** - * Visits the given nary formula and returns the result. - * - * @return the result of visiting formula - **/ - public F visit(NaryFormula formula); - - /** - * Visits the given binary formula and returns the result. - * - * @return the result of visiting binFormula - **/ - public F visit(BinaryFormula binFormula); - - /** - * Visits the given negation and returns the result. - * - * @return the result of visiting not - **/ - public F visit(NotFormula not); - - /** - * Visits the given constant formula and returns the result. - * - * @return the result of visiting constant - **/ - public F visit(ConstantFormula constant); - - /** - * Visits the given comparison formula and returns the result. - * - * @return the result of visiting compFormula - **/ - public F visit(ComparisonFormula compFormula); - - /** - * Visits the given multiplicity formula and returns the result. - * - * @return the result of visiting multFormula - **/ - public F visit(MultiplicityFormula multFormula); - - /** - * Visits the given relation predicate and returns the result. - * - * @return the result of visiting predicate - */ - public F visit(RelationPredicate predicate); - - public F visit(FixFormula fixFormula); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/VoidVisitor.java b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/VoidVisitor.java deleted file mode 100644 index f804108fb..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/VoidVisitor.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.ast.visitor; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.FixFormula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; - -/** - * A visitor that visits every node in the AST. - * - * @author Emina Torlak - */ -public interface VoidVisitor { - - /** - * Visits the given sequence of declarations. - **/ - public void visit(Decls decls); - - /** - * Visits the given declaration. - **/ - public void visit(Decl decl); - - /** - * Visits the given relation. - **/ - public void visit(Relation relation); - - /** - * Visits the given variable. - **/ - public void visit(Variable variable); - - /** - * Visits the given constant expression. - **/ - public void visit(ConstantExpression constExpr); - - /** - * Visits the given unary expression. - **/ - public void visit(UnaryExpression unaryExpr); - - /** - * Visits the given binary expression. - **/ - public void visit(BinaryExpression binExpr); - - /** - * Visits the given nary expression. - **/ - public void visit(NaryExpression expr); - - /** - * Visits the given comprehension. - **/ - public void visit(Comprehension comprehension); - - /** - * Visits the given if-then expression. - **/ - public void visit(IfExpression ifExpr); - - /** - * Visits the given projection expression. - */ - public void visit(ProjectExpression project); - - /** - * Visits the given integer cast expression. - */ - public void visit(IntToExprCast castExpr); - - /** - * Visits the given integer constant. - */ - public void visit(IntConstant intConst); - - /** - * Visits the given unary integer expression. - */ - public void visit(ExprToIntCast intExpr); - - /** - * Visits the given if-int-expression. - */ - public void visit(IfIntExpression intExpr); - - /** - * Visits the given nary int expression. - **/ - public void visit(NaryIntExpression intExpr); - - /** - * Visits the given binary integer expression. - */ - public void visit(BinaryIntExpression intExpr); - - /** - * Visits the given unary integer expression. - */ - public void visit(UnaryIntExpression intExpr); - - /** - * Visits the given sum expression. - */ - public void visit(SumExpression intExpr); - - /** - * Visits the given integer comparison formula. - */ - public void visit(IntComparisonFormula intComp); - - /** - * Visits the given quantified formula. - **/ - public void visit(QuantifiedFormula quantFormula); - - /** - * Visits the given nary formula. - **/ - public void visit(NaryFormula formula); - - /** - * Visits the given binary formula. - **/ - public void visit(BinaryFormula binFormula); - - /** - * Visits the given negation. - **/ - public void visit(NotFormula not); - - /** - * Visits the given constant formula. - **/ - public void visit(ConstantFormula constant); - - /** - * Visits the given comparison formula. - **/ - public void visit(ComparisonFormula compFormula); - - /** - * Visits the given multiplicity formula. - **/ - public void visit(MultiplicityFormula multFormula); - - /** - * Visits the given relation predicate. - */ - public void visit(RelationPredicate predicate); - - public void visit(FixFormula fixFormula); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/package.html deleted file mode 100644 index 5698cc132..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/package.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - -Contains visitors for Kodkod formulas, expressions, and integer expressions. - -

Package Specification

- -

Provides two interfaces for traversing the Kodkod AST using -the visitor pattern. A {@linkplain kodkod.ast.visitor.VoidVisitor} visits the nodes but returns no values. A -{@linkplain kodkod.ast.visitor.ReturnVisitor} can be parametrized to return values of specific types for -{@linkplain kodkod.ast.Decls}, {@linkplain kodkod.ast.Expression}, {@linkplain kodkod.ast.IntExpression}, -and {@linkplain kodkod.ast.Formula} nodes.

- -

Several skeletal implementations of the VoidVisitor and ReturnVisitor interfaces -are also provided. These traverse the AST in a depth-first manner and optionally cache -the results of visiting specified nodes. The caching functionality makes it convenient -to implement visitors that visit shared nodes only once.

- -

Related Documentation

- -@see kodkod.ast.visitor.VoidVisitor -@see kodkod.ast.visitor.ReturnVisitor - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/ast/visitor/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/AbortedException.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/AbortedException.java deleted file mode 100644 index 6a025eab9..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/AbortedException.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -/** - * Indicates that a solving or evaluation task has been aborted. - * - * @author Emina Torlak - */ -public final class AbortedException extends RuntimeException { - - private static final long serialVersionUID = 201522560152091247L; - - /** - * Constructs an aborted exception with no message. - */ - AbortedException() {} - - /** - * Constructs an aborted exception with the given message. - */ - AbortedException(String message) { - super(message); - } - - /** - * Constructs an aborted exception with the given cause. - */ - AbortedException(Throwable cause) { - super(cause); - } - - /** - * Constructs an aborted exception with the given message and cause. - */ - AbortedException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/CapacityExceededException.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/CapacityExceededException.java deleted file mode 100644 index 79da353eb..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/CapacityExceededException.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import kodkod.util.ints.IntVector; - -/** - * Indicates that a problem construction or translation task failed because the - * capacity of the index representation was exceeded. - * - * @specfield dims: IntVector // contains a vector of dimensions which exceed - * the representation capacity - * @author Emina Torlak - */ -public final class CapacityExceededException extends RuntimeException { - - private static final long serialVersionUID = -8098615204149641969L; - private final IntVector dims; - - /** - * Constructs a CapacityExceededException from the given dimensions. - */ - public CapacityExceededException(IntVector dims) { - this.dims = dims; - } - - /** - * Constructs a CapacityExceededException with the given message and dimensions. - */ - public CapacityExceededException(String arg0, IntVector dims) { - super(arg0); - this.dims = dims; - } - - /** - * Constructs a CapacityExceededException with the given cause. - */ - public CapacityExceededException(Throwable arg0, IntVector dims) { - super(arg0); - this.dims = dims; - } - - /** - * Constructs a CapacityExceededException with the given message and cause. - */ - public CapacityExceededException(String arg0, Throwable arg1, IntVector dims) { - super(arg0, arg1); - this.dims = dims; - } - - /** - * Returns the vector of dimensions which, when multiplied together, exceed the - * representation capacity. - * - * @return this.dims - */ - public final IntVector dims() { - return dims; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Evaluator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Evaluator.java deleted file mode 100644 index 554181c73..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Evaluator.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntExpression; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.Int; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.Translator; -import kodkod.instance.Instance; -import kodkod.instance.TupleSet; - -/** - * An evaluator for relational formulas and expressions with respect to a given - * {@link kodkod.instance.Instance instance} and - * {@link kodkod.engine.config.Options options}. - *

- * Note: you may observe surprising (though correct) evaluator behavior - * if you do not use the same set of integer options (i.e. - * {@link kodkod.engine.config.Options#intEncoding() intEncoding} and - * {@link kodkod.engine.config.Options#bitwidth() bitwidth} when evaluating and - * solving a formula. For example, suppose that that an Instance i is a solution - * to a formula f found using options o. If you create an evaluator e such that - * e.instance = i, but e.options is an Options object with different integer - * settings than o, e.evalate(f) may return false. - *

- * - * @specfield options: Options - * @specfield instance: Instance - * @author Emina Torlak - */ -public final class Evaluator { - - private final Instance instance; - private final Options options; - private boolean wasOverflow; // [AM] was overflow detected during - // evaluation - - /** - * Constructs a new Evaluator for the given instance, using a default Options - * object. - * - * @ensures this.instance' = instance && this.options' = new Options() - * @throws NullPointerException instance = null - */ - public Evaluator(Instance instance) { - this(instance, new Options()); - } - - /** - * Constructs a new Evaluator for the given instance and options - * - * @ensures this.instance' = instance && this.options' = options - * @throws NullPointerException instance = null || options = null - */ - public Evaluator(Instance instance, Options options) { - if (instance == null || options == null) - throw new NullPointerException(); - this.instance = instance; - this.options = options; - } - - /** - * Returns the Options object used by this evaluator. - * - * @return this.options - */ - public Options options() { - return options; - } - - /** - * Returns this.instance. Any modifications to the returned object will be - * reflected in the behavior of the evaluate methods. - * - * @return this.instance - */ - public Instance instance() { - return instance; - } - - /** - * Evaluates the specified formula with respect to the relation-tuple mappings - * given by this.instance and using this.options. - * - * @return true if formula is true with respect to this.instance and - * this.options; otherwise returns false - * @throws kodkod.engine.fol2sat.HigherOrderDeclException the formula contains a - * higher order declaration - * @throws kodkod.engine.fol2sat.UnboundLeafException the formula contains an - * undeclared variable or a relation not mapped by this.instance - */ - public boolean evaluate(Formula formula) { - if (formula == null) - throw new NullPointerException("formula"); - return Translator.evaluate(formula, instance, options).booleanValue(); - } - - /** - * Evaluates the specified expession with respect to the relation-tuple mappings - * given by this.instance and using this.options. - * - * @return {@link kodkod.instance.TupleSet set} of tuples to which the - * expression evaluates given the mappings in this.instance and the - * options in this.options. - * @throws kodkod.engine.fol2sat.HigherOrderDeclException the expression - * contains a higher order declaration - * @throws kodkod.engine.fol2sat.UnboundLeafException the expression contains an - * undeclared variable or a relation not mapped by this.instance - */ - public TupleSet evaluate(Expression expression) { - if (expression == null) - throw new NullPointerException("expression"); - final BooleanMatrix sol = Translator.evaluate(expression, instance, options); - this.wasOverflow = sol.defCond().getAccumOverflow() == BooleanConstant.TRUE; - return instance.universe().factory().setOf(expression.arity(), sol.denseIndices()); - } - - /** - * Evaluates the specified int expession with respect to the relation-tuple - * mappings given by this.instance and using this.options. - * - * @return the integer to which the expression evaluates given the mappings in - * this.instance and the options in this.options. - * @throws kodkod.engine.fol2sat.HigherOrderDeclException intExpr contains a - * higher order declaration - * @throws kodkod.engine.fol2sat.UnboundLeafException intExpr contains an - * undeclared variable or a relation not mapped by this.instance - */ - public int evaluate(IntExpression intExpr) { - if (intExpr == null) - throw new NullPointerException("intexpression"); - final Int sol = Translator.evaluate(intExpr, instance, options); - this.wasOverflow = sol.defCond().getAccumOverflow() == BooleanConstant.TRUE; - return sol.value(); - } - - /** - * Returns whether overflow was detected during evaluation - */ // [AM] - public boolean wasOverflow() { - return wasOverflow; - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return options + "\n" + instance; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/HOLSolver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/HOLSolver.java deleted file mode 100644 index 4b123b815..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/HOLSolver.java +++ /dev/null @@ -1,195 +0,0 @@ -package kodkod.engine; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import kodkod.ast.Formula; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.SymmetryDetector; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.hol.HOLTranslation; -import kodkod.engine.hol.HOLTranslator; -import kodkod.engine.hol.Proc; -import kodkod.engine.satlab.SATAbortedException; -import kodkod.instance.Bounds; - -public final class HOLSolver implements KodkodSolver { - - private final Options options; - private HOLTranslation translation; - private Boolean outcome; - - private HOLSolver() { - this(new Options()); - } - - /** - * Initializes the solver with the given options. - * - * @ensures no this.solution' && no this.formulas' && no this.bounds'&& - * this.options' = options - */ - private HOLSolver(Options options) { - this.options = options; - this.outcome = null; - } - - public static HOLSolver solver() { - return solver(new Options()); - } - - /** - * Returns a new {@link IncrementalSolver} using the given options. - * - * @requires options.solver.incremental() && options.logTranslation = 0 - * @return some s: IncrementalSolver | no s.formulas && no s.bounds && s.options - * = options.clone() - * @throws NullPointerException any of the arguments are null - * @throws IllegalArgumentException any of the preconditions on options are - * violated - */ - public static HOLSolver solver(Options options) { - Translator.checkIncrementalOptions(options); - return new HOLSolver(options.clone()); - } - - /** - * Adds the specified formula and bounds to the solver's state, modifies the - * current solution to reflect the updated state (if needed), and returns this - * solver. This solver should not be used again if a call to this method results - * in an exception. - * - * @requires this.{@link #usable() usable}() - * @requires f.*components & Relation in (this.bounds + b).relations - * @requires some this.bounds => this.bounds.universe = b.universe && no - * b.intBound && no (this.bounds.relations & b.relations) - * @requires some this.bounds => all s: - * {@link SymmetryDetector#partition(Bounds) partition}(this.bounds) | - * some p: {@link SymmetryDetector#partition(Bounds) partition}(b) | - * s.elements in p.elements - * @ensures this.formulas' = this.formulas + f - * @ensures some this.bounds => (this.bounds.relations' = this.bounds.relations - * + b.relations && this.bounds.upperBound' = this.bounds.upperBound + - * b.upperBound && this.bounds.lowerBound' = this.bounds.lowerBound + - * b.lowerBound) else (this.bounds' = bounds) - * @return some sol: Solution | sol.instance() = null => UNSAT(this.formulas', - * this.bounds', this.options) else sol.instance() in - * MODELS(Formula.and(this.formulas'), this.bounds', this.options) - * @throws IllegalStateException a prior call returned an UNSAT solution or - * resulted in an exception - * @throws NullPointerException any of the arguments are null - * @throws UnboundLeafException the formula refers to an undeclared variable or - * a relation not mapped by this.bounds + b - * @throws HigherOrderDeclException the formula contains a higher order - * declaration - * @throws IllegalArgumentException any of the remaining preconditions on - * {@code f} and {@code b} are violated - * @throws AbortedException this solving task has been aborted - */ - @Override - public Solution solve(Formula f, Bounds b) throws HigherOrderDeclException, UnboundLeafException, AbortedException { - if (outcome == Boolean.FALSE) - throw new IllegalStateException("Cannot use this solver since a prior call to solve(...) produced an UNSAT solution."); - - if (outcome != null && translation == null) - throw new IllegalStateException("Cannot use this solver since a prior call to solve(...) resulted in an exception."); - - try { - final long startProcTransl = System.currentTimeMillis(); - Proc proc = Translator.translate2proc(f, b, options); - final long endProcTransl = System.currentTimeMillis(); - - final long startTransl = System.currentTimeMillis(); - translation = HOLTranslator.proc2transl(proc, options); - final long endTransl = System.currentTimeMillis(); - - // final long startTransl = System.currentTimeMillis(); - // translation = Translator.translateHOL(f, b, options); - // final long endTransl = System.currentTimeMillis(); - - return toSolution(endProcTransl - startProcTransl, endTransl - startTransl, translation); - } catch (SATAbortedException sae) { - free(); - throw new AbortedException(sae); - } catch (RuntimeException e) { - free(); - throw e; - } - } - - private Solution toSolution(final long procTranslTime, final long translTime, final HOLTranslation translation) { - Solution sol = Solver.solveTranslation(translTime, translation); - sol.stats().setProcTranslTime(procTranslTime); - sol.stats().setNumCandidates(translation.numCandidates()); - outcome = sol.sat() ? Boolean.TRUE : Boolean.FALSE; - if (outcome == Boolean.FALSE) - free(); - return sol; - } - - public Solution solveNext() { - HOLTranslation tr = translation.next(); - return toSolution(0, 0, tr); - } - - @Override - public Iterator solveAll(final Formula formula, final Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { - return new Iterator() { - - private Solution lastSol = null; - - @Override - public boolean hasNext() { - return lastSol == null || lastSol.sat(); - } - - @Override - public Solution next() { - if (!hasNext()) - throw new NoSuchElementException(); - lastSol = (lastSol == null) ? solve(formula, bounds) : solveNext(); - return lastSol; - } - - @Override - public void remove() { - throw new IllegalStateException("can't remove solution"); - } - }; - } - - /** - * Returns true iff this solver has neither returned an UNSAT solution so far - * nor thrown an exception during solving. - * - * @return true iff this solver has neither returned an UNSAT solution so far - * nor thrown an exception during solving - */ - public boolean usable() { - return (outcome == Boolean.TRUE && translation != null) || (outcome == null); - } - - /** - * Returns a copy of {@code this.options}. - * - * @return this.options.clone() - */ - @Override - public Options options() { - return options; - } - - /** - * Releases the resources, if any, associated with this solver. - */ - @Override - public void free() { - if (translation != null) { - // TODO: translation.cnf().free(); - translation = null; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/IncrementalSolver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/IncrementalSolver.java deleted file mode 100644 index 4d2b241b3..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/IncrementalSolver.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2012, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import java.util.Iterator; - -import kodkod.ast.Formula; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.SymmetryDetector; -import kodkod.engine.fol2sat.Translation; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATAbortedException; -import kodkod.engine.satlab.SATFactory; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.Universe; - -/** - * A computational engine for solving a sequence of related relational - * {@linkplain Formula formulas} and {@linkplain Bounds bounds} (e.g., generated - * by a software verification or synthesis tool) with respect to a given set of - * configuration {@link kodkod.engine.config.Options options}. - *

- * An incremental Kodkod solver is initialized with an options instance - * opt which cannot be modified further during the lifetime of the - * solver instance. If the first problem (f0, b0, opt) passed to - * the solver via the {@link #solve(Formula, Bounds) solve} method is - * satisfiable, the resulting {@linkplain Solution solution} and the underlying - * incremental {@linkplain SATSolver SAT solver} are saved. When the - * {@linkplain #solve(Formula, Bounds) solve} method is called again with a new - * formula f1 and bounds b1, the translation of - * (f1, b1, opt) is added to the stored SAT solver, which is then - * called to obtain a solution for the problem f0 && f1 and - * b0 + b1. We define b0 + b1 to be a disjoint union - * of the bindings in b0 and b1, where - * {@code b0.universe = b1.universe}, {@code b1.intBound} is empty, and - * {@code b1} contains no bindings for relations that are bound by {@code b0}. - * This process can be repeated until the solver yields UNSAT. Calling - * {@linkplain #solve(Formula, Bounds) solve} on a solver that has already - * returned UNSAT or that has thrown an exception during a prior call to - * {@linkplain #solve(Formula, Bounds) solve} will result in an - * {@link IllegalStateException}. - *

- *

- * To simplify the implementation, an {@linkplain IncrementalSolver} currently - * places the following restriction on the sequence of bounds passed to its - * {@linkplain #solve(Formula, Bounds)} method: the equivalence classes on the - * {@linkplain Universe universe} of interpretation that are induced by the - * initial bounds b0 must refine the equivalence classes induced by - * all subsequent bounds. In particular, let { s0, ..., sn } be the - * coarsest partition of b0.universe such that every tupleset in - * b0.lowerBound, b0.upperBound, and - * b0.intBound can be expressed as a union of cross-products of - * sets drawn from { s0, ..., sn }. Then, for each bound - * bi with which the solver's {@linkplain #solve(Formula, Bounds) - * solve} method is called in the future, it must also be the case that each - * tupleset in bi.lowerBound, bi.upperBound and - * bi.intBound can be expressed in the same way, as a union of - * cross-products of sets drawn from { s0, ..., sn }. - *

- *

- * The above requirement can be satisfied by making sure that b0 - * contains a set of unary relations { r0, ..., rn } such that the - * lower/upper bounds on all other relations that will ever be introduced can be - * expressed as a union of cross-products of a subset of b0's - * lower/upper bounds on { r0, ..., rn }. One can think of the - * bounds on { r0, ..., rn } as representing sorts or types, and - * every relation's bounds should be expressible in terms of these types. Note - * that having each atom in the universe appear in a lower/upper bound by itself - * (e.g., b0.lowerBound[ri] = b0.upperBound[ri] = {<ai>}) - * will trivially satisfy this requirement, but it is better to group related - * atoms into sets to enable symmetry breaking. - *

- *

- * We additionally require {@linkplain Options#logTranslation() - * opt.logTranslation} to be {@linkplain Options#setLogTranslation(int) - * disabled} and {@linkplain Options#solver() opt.solver} to specify an - * {@linkplain SATFactory#incremental() incremental} SAT solver. Note that these - * restrictions prevent unsat core extraction. - *

- * - * @specfield options: {@link Options} - * @specfield bounds: lone {@link Bounds} - * @specfield formulas: set {@link Formula} - * @invariant formulas.*components & Relation in bounds.relations - * @invariant some formulas iff some bounds - * @invariant options.solver.incremental() && options.logTranslation = 0 - * @see SymmetryDetector - * @see kodkod.engine.fol2sat.Translation.Incremental - * @see Translator#translateIncremental(Formula, Bounds, Options) - * @see Translator#translateIncremental(Formula, Bounds, - * kodkod.engine.fol2sat.Translation.Incremental) - * @author Emina Torlak - */ -public final class IncrementalSolver implements KodkodSolver { - - private final Options options; - private Translation.Incremental translation; - private Boolean outcome; - - /** - * Initializes the solver with the given options. - * - * @ensures no this.solution' && no this.formulas' && no this.bounds'&& - * this.options' = options - */ - private IncrementalSolver(Options options) { - this.options = options; - this.outcome = null; - } - - /** - * Returns a new {@link IncrementalSolver} using the given options. - * - * @requires options.solver.incremental() && options.logTranslation = 0 - * @return some s: IncrementalSolver | no s.formulas && no s.bounds && s.options - * = options.clone() - * @throws NullPointerException any of the arguments are null - * @throws IllegalArgumentException any of the preconditions on options are - * violated - */ - public static IncrementalSolver solver(Options options) { - Translator.checkIncrementalOptions(options); - return new IncrementalSolver(options.clone()); - } - - /** - * Adds the specified formula and bounds to the solver's state, modifies the - * current solution to reflect the updated state (if needed), and returns this - * solver. This solver should not be used again if a call to this method results - * in an exception. - * - * @requires this.{@link #usable() usable}() - * @requires f.*components & Relation in (this.bounds + b).relations - * @requires some this.bounds => this.bounds.universe = b.universe && no - * b.intBound && no (this.bounds.relations & b.relations) - * @requires some this.bounds => all s: - * {@link SymmetryDetector#partition(Bounds) partition}(this.bounds) | - * some p: {@link SymmetryDetector#partition(Bounds) partition}(b) | - * s.elements in p.elements - * @ensures this.formulas' = this.formulas + f - * @ensures some this.bounds => (this.bounds.relations' = this.bounds.relations - * + b.relations && this.bounds.upperBound' = this.bounds.upperBound + - * b.upperBound && this.bounds.lowerBound' = this.bounds.lowerBound + - * b.lowerBound) else (this.bounds' = bounds) - * @return some sol: Solution | sol.instance() = null => UNSAT(this.formulas', - * this.bounds', this.options) else sol.instance() in - * MODELS(Formula.and(this.formulas'), this.bounds', this.options) - * @throws IllegalStateException a prior call returned an UNSAT solution or - * resulted in an exception - * @throws NullPointerException any of the arguments are null - * @throws UnboundLeafException the formula refers to an undeclared variable or - * a relation not mapped by this.bounds + b - * @throws HigherOrderDeclException the formula contains a higher order - * declaration - * @throws IllegalArgumentException any of the remaining preconditions on - * {@code f} and {@code b} are violated - * @throws AbortedException this solving task has been aborted - */ - @Override - public Solution solve(Formula f, Bounds b) throws HigherOrderDeclException, UnboundLeafException, AbortedException { - if (outcome == Boolean.FALSE) - throw new IllegalStateException("Cannot use this solver since a prior call to solve(...) produced an UNSAT solution."); - - if (outcome != null && translation == null) - throw new IllegalStateException("Cannot use this solver since a prior call to solve(...) resulted in an exception."); - - final Solution solution; - try { - final long startTransl = System.currentTimeMillis(); - translation = translation == null ? Translator.translateIncremental(f, b, options) : Translator.translateIncremental(f, b, translation); - final long endTransl = System.currentTimeMillis(); - - if (translation.trivial()) { - final Statistics stats = new Statistics(translation, endTransl - startTransl, 0); - if (translation.cnf().solve()) { - solution = Solution.triviallySatisfiable(stats, translation.interpret()); - } else { - solution = Solution.triviallyUnsatisfiable(stats, null); - } - } else { - final SATSolver cnf = translation.cnf(); - - translation.options().reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses()); - final long startSolve = System.currentTimeMillis(); - final boolean sat = cnf.solve(); - final long endSolve = System.currentTimeMillis(); - - final Statistics stats = new Statistics(translation, endTransl - startTransl, endSolve - startSolve); - if (sat) { - solution = Solution.satisfiable(stats, translation.interpret()); - } else { - solution = Solution.unsatisfiable(stats, null); - } - } - } catch (SATAbortedException sae) { - free(); - throw new AbortedException(sae); - } catch (RuntimeException e) { - free(); - throw e; - } - - if (solution.sat()) { - outcome = Boolean.TRUE; - } else { - outcome = Boolean.FALSE; - free(); - } - - return solution; - } - - @Override - public Iterator solveAll(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { - throw new RuntimeException("not implemented"); - } - - /** - * Returns true iff this solver has neither returned an UNSAT solution so far - * nor thrown an exception during solving. - * - * @return true iff this solver has neither returned an UNSAT solution so far - * nor thrown an exception during solving - */ - public boolean usable() { - return (outcome == Boolean.TRUE && translation != null) || (outcome == null); - } - - /** - * Returns a copy of {@code this.options}. - * - * @return this.options.clone() - */ - @Override - public Options options() { - return options.clone(); - } - - /** - * Releases the resources, if any, associated with this solver. - */ - @Override - public void free() { - if (translation != null) { - translation.cnf().free(); - translation = null; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/KodkodSolver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/KodkodSolver.java deleted file mode 100644 index ed2a729b5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/KodkodSolver.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2012, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import java.util.Iterator; - -import kodkod.ast.Formula; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; - -/** - * A computational engine for solving relational satisfiability problems. Such a - * problem is described by a {@link kodkod.ast.Formula formula} in first order - * relational logic; finite {@link kodkod.instance.Bounds bounds} on the value - * of each {@link Relation relation} constrained by the formula; and a set of - * {@link kodkod.engine.config.Options options} specifying, among other global - * parameters, the length of bitvectors that describe the meaning of - * {@link IntExpression integer expressions} in the given formula. The options - * are usually reused between invocations to the - * {@linkplain #solve(Formula, Bounds) solve} methods, so they are specified as - * a part of the {@linkplain KodkodSolver solver} state. - *

- * A {@link KodkodSolver} takes as input a relational problem and produces a - * satisfying model or an {@link Instance instance} of it, if one exists. Some - * implementation of this interface can also produce a {@link Proof proof} of - * unsatisfiability, if the given problem has no models. - *

- * - * @specfield options: Options - * @author Emina Torlak - */ -public interface KodkodSolver { - - /** - * Returns the Options object used by this solver. - * - * @return this.options - */ - public Options options(); - - /** - * Attempts to satisfy the given {@code formula} and {@code bounds} with respect - * to {@code this.options} or, optionally, prove the problem's unsatisfiability. - * If the method completes normally, the result is a {@linkplain Solution - * solution} containing either an {@linkplain Instance instance} of the given - * problem or, optionally, a {@linkplain Proof proof} of its unsatisfiability. - * - * @return some sol: {@link Solution} | sol.satisfiable() => sol.instance() in - * MODELS(formula, bounds, this.options) else UNSAT(formula, bound, - * this.options) - * @throws NullPointerException formula = null || bounds = null - * @throws UnboundLeafException the formula contains an undeclared variable or a - * relation not mapped by the given bounds - * @throws HigherOrderDeclException the formula contains a higher order - * declaration that cannot be skolemized, or it can be skolemized - * but {@code this.options.skolemDepth} is insufficiently large - * @throws AbortedException this solving task was aborted - */ - public Solution solve(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException; - - public Iterator solveAll(Formula fgoal, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException; - - // /** - // * Attempts to find a set of solutions to the given {@code formula} and - // {@code bounds} with respect to - // * {@code this.options} or, optionally, to prove the formula's - // unsatisfiability. - // * If the operation is successful, the method returns an iterator over - // {@link Solution} objects. - // * If there is more than one solution, the outcome of all of them is SAT - // or trivially SAT. If the problem - // * is unsatisfiable, the iterator will produce a single {@link Solution} - // whose outcome is UNSAT - // * or trivially UNSAT. The set of returned solutions must be non-empty, - // but it is not required to be complete; - // * a solver could simply return a singleton set containing just the first - // available solution. - // * - // * @return some sols: some {@link Solution} | - // * (#sols > 1 => (all s: sols | s.satisfiable())) && - // * (all s: sols | s.satisfiable() => s.instance() in MODELS(formula, - // bounds, this.options) else UNSAT(formula, bound, this.options)) - // * - // * @throws NullPointerException formula = null || bounds = null - // * @throws UnboundLeafException the formula contains an undeclared - // variable or a relation not mapped by the given bounds - // * @throws HigherOrderDeclException the formula contains a higher order - // declaration that cannot - // * be skolemized, or it can be skolemized but {@code - // this.options.skolemDepth} is insufficiently large - // * @throws AbortedException this solving task was aborted - // */ - // public Iterator solveAll(Formula formula, Bounds bounds) - // throws HigherOrderDeclException, UnboundLeafException, AbortedException; - - /** - * Releases the resources, if any, associated with this solver. - */ - public void free(); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Proof.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Proof.java deleted file mode 100644 index fe155118d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Proof.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import java.util.Iterator; -import java.util.Map; - -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.TranslationRecord; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.util.nodes.Nodes; - -/** - * Contains a proof of unsatisfiability of a given FOL formula. - * - * @specfield log: TranslationLog // log of the translation of this.formula with - * respect to this.bounds - */ -public abstract class Proof { - - private final TranslationLog log; - - /** - * Constructs a new Proof of unsatisfiability for log.formula. - * - * @ensures this.log = log - */ - Proof(TranslationLog log) { - this.log = log; - } - - /** - * Minimizes the proof of this.log.formula's unsatisfiability using the - * specified proof reduction strategy. The strategy argument is ignored (it can - * be null) if this.formula is trivially unsatisfiable with respect to - * this.bounds. In that case, the core is reduced using the trivial strategy - * that does one of the following: (1) if there is a root that simplified to - * FALSE, sets the minimal core to that root; or (2) if not, then there must be - * two roots that translated to x and -x, where x is a boolean literal, so we - * pick those two as the minimal core. - *

- * Note: the core minimization is performed at the level of the - * transformed formula, not the original formula if the problem was translated - * with a non-zero {@linkplain Options#coreGranularity() core granularity} - * setting. In other words, after this method has been called, - * {@linkplain #highLevelCore() highLevelCore()} returns a map M such that - * M.keySet() is a minimal core with respect to this.log.bounds. In contrast, - * {@linkplain Nodes#allRoots(Formula, java.util.Collection) - * Nodes.roots(this.log.originalFormula, M.values())} is unsatisfiable with - * respect this.log.originalBounds. These formulas, however, do not necessarily - * form a minimal core of this.log.originalFormula if the original problem was - * translated with a non-zero {@linkplain Options#coreGranularity() core - * granularity} setting. - *

- * - * @ensures minimizes the proof of this.log.formula's unsatisfiability using the - * specified proof reduction strategy (or the trivial strategy if - * this.formula is trivially unsatisfiable with respect to - * this.bounds). - * @see kodkod.engine.satlab.ReductionStrategy - */ - public abstract void minimize(ReductionStrategy strategy); - - /** - * Returns an iterator over the {@link TranslationRecord log records} for the - * nodes that are in the unsatisfiable core of this.log.formula. The record - * objects returned by the iterator are not guaranteed to be immutable. In - * particular, the state of a record object returned by next() is - * guaranteed to remain the same only until the subsequent call to - * next(). - * - * @return an iterator over the {@link TranslationRecord log records} for the - * nodes that are in the unsatisfiable core of this.log.formula. - */ - public abstract Iterator core(); - - /** - * Returns a map whose key set is the unsatisfiable subset of the top-level - * conjunctions of this.log.formula as given by {@linkplain #core() - * this.core()}. Each formula in the key set is mapped to the descendant of - * this.log.originalFormula from which it was derived by skolemization or by - * some other optimization. - * - * @return a map whose key set is the unsatisfiable subset of the top-level - * conjunctions of this.log.formula, as given by {@linkplain #core() - * this.core()}. Each formula in the key set is mapped to the descendant - * of this.log.originalFormula from which it was derived by - * skolemization or by some other optimization. - * @see #minimize(ReductionStrategy) - */ - public abstract Map highLevelCore(); - - /** - * Returns the log of the translation that resulted in this proof. - * - * @return log of the translation that resulted in this proof - */ - public final TranslationLog log() { - return log; - } - - /** - * Returns a string representation of this proof. - * - * @return a string representation of this proof. - * @see java.lang.Object#toString() - */ - // public String toString() { - // final StringBuilder ret = new StringBuilder(); - // for(Formula f : highLevelCore()) { - // ret.append(" "); - // ret.append(f); - // ret.append("\n"); - // } - // return ret.toString(); - // } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ResolutionBasedProof.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ResolutionBasedProof.java deleted file mode 100644 index 69b7853f9..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ResolutionBasedProof.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.ast.visitor.AbstractVoidVisitor; -import kodkod.engine.fol2sat.RecordFilter; -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.TranslationRecord; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.engine.satlab.SATProver; -import kodkod.engine.ucore.StrategyUtils; -import kodkod.instance.TupleSet; -import kodkod.util.collections.IdentityHashSet; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; - -/** - * A proof of unsatisfiability based on a {@linkplain ResolutionTrace resolution - * trace} produced by a {@linkplain SATProver SATProver}. - * - * @author Emina Torlak - */ -final class ResolutionBasedProof extends Proof { - - private SATProver solver; - private RecordFilter coreFilter; - private Map coreRoots; - - /** - * Constructs a new ResolutionRefutation that will extract the unsatisfiable - * core for log.formula from the given solver. - * - * @requires solver.solve() has been called and it returned false. - * @requires log.formula is the formula whose translation resulted in the given - * SATProver - * @ensures this.formula' = log.formula - */ - ResolutionBasedProof(SATProver solver, TranslationLog log) { - super(log); - this.solver = solver; - this.coreFilter = null; - this.coreRoots = null; - } - - /** - * Returns the connected core based on the given set of core variables. - * - * @requires coreVar = StrategyUtils.coreVars(solver.proof()); - * @return let formulas = (this.log.records[int] & literal.{i: int | abs(i) in - * coreVars}).formula | connected = {f: formulas | some s: set coreNodes - * | f + this.log.formula in s and (s - this.log.formula).~components in - * s } - */ - private Set connectedCore(final IntSet coreVars) { - final Set coreNodes = new IdentityHashSet(); - final RecordFilter filter = new RecordFilter() { - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return coreVars.contains(StrictMath.abs(literal)); - } - }; - for (Iterator itr = log().replay(filter); itr.hasNext();) { - coreNodes.add(itr.next().translated()); - } - final Set connected = new IdentityHashSet(); - final AbstractVoidVisitor traverser = new AbstractVoidVisitor() { - - final Set visited = new IdentityHashSet(); - - /** - * Returns true if the given node has been visited before or if it is not - * contained in this.nodes set. Otherwise adds the node to the connected set and - * returns false. - * - * @ensures this.visited' = this.visited + n - * @ensures n !in this.visited && n in coreNodes => connected' = connected + n - * else connected' = connected - * @return n in visited || n !in coreNodes - */ - @Override - protected boolean visited(Node n) { - if (visited.add(n) && coreNodes.contains(n)) { - connected.add((Formula) n); - return false; - } - return true; - } - }; - for (Formula root : log().roots()) { - root.accept(traverser); - } - return connected; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.Proof#core() - */ - @Override - public final Iterator core() { - if (coreFilter == null) { - coreFilter = new RecordFilter() { - - final IntSet coreVariables = StrategyUtils.coreVars(solver.proof()); - final Set coreNodes = connectedCore(coreVariables); - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return coreNodes.contains(translated) && coreVariables.contains(StrictMath.abs(literal)); - } - }; - } - return log().replay(coreFilter); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.Proof#highLevelCore() - */ - @Override - public final Map highLevelCore() { - if (coreRoots == null) { - final RecordFilter unitFilter = new RecordFilter() { - - final IntSet coreUnits = StrategyUtils.coreUnits(solver.proof()); - final Set roots = log().roots(); - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return roots.contains(translated) && coreUnits.contains(Math.abs(literal)); - } - - }; - coreRoots = new LinkedHashMap(); - final IntSet seenUnits = new IntTreeSet(); - for (Iterator itr = log().replay(unitFilter); itr.hasNext();) { - // it is possible that two top-level formulas have identical - // meaning, - // and are represented with the same core unit; in that case, we - // want only - // one of them in the core. - final TranslationRecord rec = itr.next(); - if (seenUnits.add(rec.literal())) { - coreRoots.put(rec.translated(), rec.node()); - } - } - coreRoots = Collections.unmodifiableMap(coreRoots); - } - return coreRoots; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.Proof#minimize(kodkod.engine.satlab.ReductionStrategy) - */ - @Override - public void minimize(ReductionStrategy strategy) { - solver.reduce(strategy); - coreFilter = null; - coreRoots = null; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Solution.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Solution.java deleted file mode 100644 index 65d65190c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Solution.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import kodkod.instance.Instance; - -/** - * Represents the full solution to a formula: an instance if the formula is - * satisfiable or a proof of unsatisfiability if not. - * - * @specfield formula: Formula // the formula being solved - * @specfield bounds: Bounds // the bounds on the formula - * @author Emina Torlak - */ -public final class Solution { - - private final Outcome outcome; - private final Statistics stats; - private final Instance instance; - private final Proof proof; - - /** - * Constructs a Solution from the given values. - * - * @requires outcome != null && stats != null - * @requires outcome = SATISFIABLE || TRIVIALLY_SATISFIABLE => instance != null - */ - private Solution(Outcome outcome, Statistics stats, Instance instance, Proof proof) { - assert outcome != null && stats != null; - this.outcome = outcome; - this.stats = stats; - this.instance = instance; - this.proof = proof; - } - - /** - * Returns a new Solution with a SATISFIABLE outcome, given stats and instance. - * - * @return {s: Solution | s.outcome() = SATISFIABLE && s.stats() = stats && - * s.instance() = instance } - */ - public static Solution satisfiable(Statistics stats, Instance instance) { - return new Solution(Outcome.SATISFIABLE, stats, instance, null); - } - - /** - * Returns a new Solution with a TRIVIALLY_SATISFIABLE outcome, given stats and - * instance. - * - * @return {s: Solution | s.outcome() = TRIVIALLY_SATISFIABLE && s.stats() = - * stats && s.instance() = instance } - */ - static Solution triviallySatisfiable(Statistics stats, Instance instance) { - return new Solution(Outcome.TRIVIALLY_SATISFIABLE, stats, instance, null); - } - - /** - * Returns a new Solution with a UNSATISFIABLE outcome, given stats and proof. - * - * @return {s: Solution | s.outcome() = UNSATISFIABLE && s.stats() = stats && - * s.proof() = proof } - */ - static Solution unsatisfiable(Statistics stats, Proof proof) { - return new Solution(Outcome.UNSATISFIABLE, stats, null, proof); - } - - /** - * Returns a new Solution with a TRIVIALLY_UNSATISFIABLE outcome, given stats - * and proof. - * - * @return {s: Solution | s.outcome() = TRIVIALLY_UNSATISFIABLE && s.stats() = - * stats && s.proof() = proof } - */ - static Solution triviallyUnsatisfiable(Statistics stats, Proof proof) { - return new Solution(Outcome.TRIVIALLY_UNSATISFIABLE, stats, null, proof); - } - - /** - * Returns the outcome of the attempt to find a model for this.formula. If the - * outcome is SATISFIABLE or TRIVIALLY_SATISFIABLE, a satisfying instance can be - * obtained by calling {@link #instance()}. If the formula is UNSATISFIABLE, a - * proof of unsatisfiability can be obtained by calling {@link #proof()} - * provided that translation logging was enabled and the unsatisfiability was - * determined using a core extracting {@link kodkod.engine.satlab.SATSolver sat - * solver}. Lastly, if the returned Outcome is or TRIVIALLY_UNSATISFIABLE, a - * proof of unsatisfiability can be obtained by calling {@link #proof()} - * provided that translation logging was enabled. - * - * @return an Outcome instance designating the satisfiability of this.formula - * with respect to this.bounds - */ - public Outcome outcome() { - return outcome; - } - - /** - * Returns true iff this solution has a (trivially) satisfiable outcome. - * - * @return this.outcome = Outcome.SATISFIABLE || this.outcome = - * Outcome.TRIVIALLY_SATISFIABLE - */ - public final boolean sat() { - return outcome == Outcome.SATISFIABLE || outcome == Outcome.TRIVIALLY_SATISFIABLE; - } - - /** - * Returns true iff this solution has a (trivially) unsatisfiable outcome. - * - * @return this.outcome = Outcome.UNSATISFIABLE || this.outcome = - * Outcome.TRIVIALLY_UNSATISFIABLE - */ - public final boolean unsat() { - return outcome == Outcome.UNSATISFIABLE || outcome == Outcome.TRIVIALLY_UNSATISFIABLE; - } - - /** - * Returns a satisfiying instance for this.formula, if the value returned by - * {@link #outcome() this.outcome()} is either SATISFIABLE or - * TRIVIALLY_SATISFIABLE. Otherwise returns null. - * - * @return a satisfying instance for this.formula, if one exists. - */ - public Instance instance() { - return instance; - } - - /** - * Returns a proof of this.formula's unsatisfiability if the value returned by - * {@link #outcome() this.outcome()} is UNSATISFIABLE or - * TRIVIALLY_UNSATISFIABLE, translation logging was enabled during solving, and - * a core extracting {@link kodkod.engine.satlab.SATProver sat solver} (if any) - * was used to determine unsatisfiability. Otherwise, null is returned. - * - * @return a proof of this.formula's unsatisfiability, if one is available. - */ - public Proof proof() { - return proof; - } - - /** - * Returns the statistics gathered while solving this.formula. - * - * @return the statistics gathered while solving this.formula. - */ - public Statistics stats() { - return stats; - } - - /** - * Returns a string representation of this Solution. - * - * @return a string representation of this Solution. - */ - @Override - public String toString() { - final StringBuilder b = new StringBuilder(); - b.append("---OUTCOME---\n"); - b.append(outcome); - b.append("\n"); - if (instance != null) { - b.append("\n---INSTANCE---\n"); - b.append(instance); - b.append("\n"); - } - if (proof != null) { - b.append("\n---PROOF---\n"); - b.append(proof); - b.append("\n"); - } - b.append("\n---STATS---\n"); - b.append(stats); - b.append("\n"); - return b.toString(); - } - - /** - * Enumerates the possible outcomes of an attempt to find a model for a FOL - * formula. - */ - public static enum Outcome { - /** - * The formula is satisfiable with respect to the specified bounds. - */ - SATISFIABLE, - /** - * The formula is unsatisfiable with respect to the specified bounds. - */ - UNSATISFIABLE, - /** - * The formula is trivially satisfiable with respect to the specified bounds: a - * series of simple transformations reduces the formula to the constant TRUE. - **/ - TRIVIALLY_SATISFIABLE, - /** - * The formula is trivially unsatisfiable with respect to the specified bounds: - * a series of simple transformations reduces the formula to the constant FALSE. - */ - TRIVIALLY_UNSATISFIABLE - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/SolutionIterator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/SolutionIterator.java deleted file mode 100644 index ae38a3c20..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/SolutionIterator.java +++ /dev/null @@ -1,181 +0,0 @@ -package kodkod.engine; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.Translation; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.SATAbortedException; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.TupleSet; - -/** - * An iterator over all solutions of a model. - * - * @author Emina Torlak - */ -public final class SolutionIterator implements Iterator { - - private Translation.Whole translation; - private long translTime; - private int trivial; - - /** - * Constructs a solution iterator for the given formula, bounds, and options. - */ - SolutionIterator(Formula formula, Bounds bounds, Options options) { - this.translTime = System.currentTimeMillis(); - this.translation = Translator.translate(formula, bounds, options); - this.translTime = System.currentTimeMillis() - translTime; - this.trivial = 0; - } - - /** - * Returns true if there is another solution. - * - * @see java.util.Iterator#hasNext() - */ - @Override - public boolean hasNext() { - return translation != null; - } - - /** - * Returns the next solution if any. - * - * @see java.util.Iterator#next() - */ - @Override - public Solution next() { - if (!hasNext()) - throw new NoSuchElementException(); - try { - return translation.trivial() ? nextTrivialSolution() : nextNonTrivialSolution(); - } catch (SATAbortedException sae) { - translation.cnf().free(); - throw new AbortedException(sae); - } - } - - /** @throws UnsupportedOperationException */ - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Solves {@code translation.cnf} and adds the negation of the found model to - * the set of clauses. The latter has the effect of forcing the solver to come - * up with the next solution or return UNSAT. If - * {@code this.translation.cnf.solve()} is false, sets {@code this.translation} - * to null. - * - * @requires this.translation != null - * @ensures this.translation.cnf is modified to eliminate the current solution - * from the set of possible solutions - * @return current solution - */ - private Solution nextNonTrivialSolution() { - final Translation.Whole transl = translation; - - final SATSolver cnf = transl.cnf(); - final int primaryVars = transl.numPrimaryVariables(); - - transl.options().reporter().solvingCNF(primaryVars, cnf.numberOfVariables(), cnf.numberOfClauses()); - - final long startSolve = System.currentTimeMillis(); - final boolean isSat = cnf.solve(); - final long endSolve = System.currentTimeMillis(); - - final Statistics stats = new Statistics(transl, translTime, endSolve - startSolve); - final Solution sol; - - if (isSat) { - // extract the current solution; can't use the sat(..) method - // because it frees the sat solver - sol = Solution.satisfiable(stats, transl.interpret()); - // add the negation of the current model to the solver - final int[] notModel = new int[primaryVars]; - for (int i = 1; i <= primaryVars; i++) { - notModel[i - 1] = cnf.valueOf(i) ? -i : i; - } - cnf.addClause(notModel); - } else { - sol = Solver.unsat(transl, stats); // this also frees up solver - // resources, if any - translation = null; // unsat, no more solutions - } - return sol; - } - - /** - * Returns the trivial solution corresponding to the trivial translation stored - * in {@code this.translation}, and if {@code this.translation.cnf.solve()} is - * true, sets {@code this.translation} to a new translation that eliminates the - * current trivial solution from the set of possible solutions. The latter has - * the effect of forcing either the translator or the solver to come up with the - * next solution or return UNSAT. If {@code this.translation.cnf.solve()} is - * false, sets {@code this.translation} to null. - * - * @requires this.translation != null - * @ensures this.translation is modified to eliminate the current trivial - * solution from the set of possible solutions - * @return current solution - */ - private Solution nextTrivialSolution() { - final Translation.Whole transl = this.translation; - - final Solution sol = Solver.trivial(transl, translTime); // this also - // frees up - // solver - // resources, - // if unsat - - if (sol.instance() == null) { - translation = null; // unsat, no more solutions - } else { - trivial++; - - final Bounds bounds = transl.bounds(); - final Bounds newBounds = bounds.clone(); - final List changes = new ArrayList(); - - for (Relation r : bounds.relations()) { - final TupleSet lower = bounds.lowerBound(r); - - if (lower != bounds.upperBound(r)) { // r may change - if (lower.isEmpty()) { - changes.add(r.some()); - } else { - final Relation rmodel = Relation.nary(r.name() + "_" + trivial, r.arity()); - newBounds.boundExactly(rmodel, lower); - changes.add(r.eq(rmodel).not()); - } - } - } - - // nothing can change => there can be no more solutions (besides the - // current trivial one). - // note that transl.formula simplifies to the constant true with - // respect to - // transl.bounds, and that newBounds is a superset of transl.bounds. - // as a result, finding the next instance, if any, for - // transl.formula.and(Formula.or(changes)) - // with respect to newBounds is equivalent to finding the next - // instance of Formula.or(changes) alone. - final Formula formula = changes.isEmpty() ? Formula.FALSE : Formula.or(changes); - - final long startTransl = System.currentTimeMillis(); - translation = Translator.translate(formula, newBounds, transl.options()); - translTime += System.currentTimeMillis() - startTransl; - } - return sol; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Solver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Solver.java deleted file mode 100644 index 9982503b5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Solver.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import java.util.Iterator; - -import kodkod.ast.Formula; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.Translation; -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATAbortedException; -import kodkod.engine.satlab.SATProver; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; - -/** - * A computational engine for solving relational satisfiability problems. Such a - * problem is described by a {@link kodkod.ast.Formula formula} in first order - * relational logic; finite {@link kodkod.instance.Bounds bounds} on the value - * of each {@link Relation relation} constrained by the formula; and a set of - * {@link kodkod.engine.config.Options options} specifying, among other global - * parameters, the length of bitvectors that describe the meaning of - * {@link IntExpression integer expressions} in the given formula. The options - * are usually reused between invocations to the - * {@linkplain #solve(Formula, Bounds) solve} methods, so they are specified as - * a part of the {@linkplain KodkodSolver solver} state. - *

- * A {@link Solver} takes as input a relational problem and produces a - * satisfying model or an {@link Instance instance} of it, if one exists. It can - * also produce a {@link Proof proof} of unsatisfiability for problems with no - * models, if the {@link kodkod.engine.config.Options options} specify the use - * of a {@linkplain SATProver proof logging SAT solver}. - *

- * - * @specfield options: Options - * @author Emina Torlak - */ -public final class Solver implements KodkodSolver { - - private final Options options; - - /** - * Constructs a new Solver with the default options. - * - * @ensures this.options' = new Options() - */ - public Solver() { - this.options = new Options(); - } - - /** - * Constructs a new Solver with the given options. - * - * @ensures this.options' = options - * @throws NullPointerException options = null - */ - public Solver(Options options) { - if (options == null) - throw new NullPointerException(); - this.options = options; - } - - /** - * Returns the Options object used by this Solver to guide translation of - * formulas from first-order logic to cnf. - * - * @return this.options - */ - @Override - public Options options() { - return options; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.KodkodSolver#free() - */ - @Override - public void free() {} - - /** - * Attempts to satisfy the given {@code formula} and {@code bounds} with respect - * to {@code this.options} or, optionally, prove the problem's unsatisfiability. - * If the method completes normally, the result is a {@linkplain Solution - * solution} containing either an {@linkplain Instance instance} of the given - * problem or, optionally, a {@linkplain Proof proof} of its unsatisfiability. - * An unsatisfiability proof will be constructed iff {@code this.options.solver} - * specifies a {@linkplain SATProver} and - * {@code this.options.logTranslation > 0}. - * - * @return some sol: {@link Solution} | some sol.instance() => sol.instance() in - * MODELS(formula, bounds, this.options) else UNSAT(formula, bound, - * this.options) - * @throws NullPointerException formula = null || bounds = null - * @throws UnboundLeafException the formula contains an undeclared variable or a - * relation not mapped by the given bounds - * @throws HigherOrderDeclException the formula contains a higher order - * declaration that cannot be skolemized, or it can be skolemized - * but {@code this.options.skolemDepth} is insufficiently large - * @throws AbortedException this solving task was aborted - * @see Options - * @see Solution - * @see Instance - * @see Proof - */ - @Override - public Solution solve(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { - final long startTransl = System.currentTimeMillis(); - - try { - final Translation.Whole translation = Translator.translate(formula, bounds, options); - final long endTransl = System.currentTimeMillis(); - - if (translation.trivial()) - return trivial(translation, endTransl - startTransl); - - final SATSolver cnf = translation.cnf(); - - options.reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses()); - final long startSolve = System.currentTimeMillis(); - final boolean isSat = cnf.solve(); - final long endSolve = System.currentTimeMillis(); - - final Statistics stats = new Statistics(translation, endTransl - startTransl, endSolve - startSolve); - return isSat ? sat(translation, stats) : unsat(translation, stats); - - } catch (SATAbortedException sae) { - throw new AbortedException(sae); - } - } - - /** - * Attempts to find all solutions to the given formula with respect to the - * specified bounds or to prove the formula's unsatisfiability. If the operation - * is successful, the method returns an iterator over n Solution objects. The - * outcome of the first n-1 solutions is SAT or trivially SAT, and the outcome - * of the nth solution is UNSAT or tirivally UNSAT. Note that an - * unsatisfiability proof will be constructed for the last solution iff - * this.options specifies the use of a core extracting SATSolver. Additionally, - * the CNF variables in the proof can be related back to the nodes in the given - * formula iff this.options has variable tracking enabled. Translation logging - * also requires that there are no subnodes in the given formula that are both - * syntactically shared and contain free variables. - * - * @return an iterator over all the Solutions to the formula with respect to the - * given bounds - * @throws NullPointerException formula = null || bounds = null - * @throws kodkod.engine.fol2sat.UnboundLeafException the formula contains an - * undeclared variable or a relation not mapped by the given bounds - * @throws kodkod.engine.fol2sat.HigherOrderDeclException the formula contains a - * higher order declaration that cannot be skolemized, or it can be - * skolemized but this.options.skolemize is false. - * @throws AbortedException this solving task was interrupted with a call to - * Thread.interrupt on this thread - * @throws IllegalStateException !this.options.solver().incremental() - * @see Solution - * @see Options - * @see Proof - */ - @Override - public Iterator solveAll(final Formula formula, final Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { - // if (Options.isDebug()) flushFormula(formula, bounds); //[AM] - if (!options.solver().incremental()) - throw new IllegalArgumentException("cannot enumerate solutions without an incremental solver."); - return new SolutionIterator(formula, bounds, options); - } - - // //[AM] - // private void flushFormula(Formula formula, Bounds bounds) { - // try { - // File f = new File(System.getProperty("java.io.tmpdir"), "kk.txt"); - // OutputStream os = new BufferedOutputStream(new FileOutputStream(f)); - // os.write(PrettyPrinter.print(formula, 2).getBytes()); - // os.write("\n================\n".getBytes()); - // os.write(bounds.toString().getBytes()); - // os.flush(); - // os.close(); - // } catch (Exception e) { - // } - // } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return options.toString(); - } - - /** - * Returns the result of solving a sat formula. - * - * @param bounds Bounds with which solve() was called - * @param translation the translation - * @param stats translation / solving stats - * @return the result of solving a sat formula. - */ - private static Solution sat(Translation.Whole translation, Statistics stats) { - final Solution sol = Solution.satisfiable(stats, translation.interpret()); - translation.cnf().free(); - return sol; - } - - /** - * Returns the result of solving an unsat formula. - * - * @param translation the translation - * @param stats translation / solving stats - * @return the result of solving an unsat formula. - */ - static Solution unsat(Translation.Whole translation, Statistics stats) { - final SATSolver cnf = translation.cnf(); - final TranslationLog log = translation.log(); - if (cnf instanceof SATProver && log != null) { - return Solution.unsatisfiable(stats, new ResolutionBasedProof((SATProver) cnf, log)); - } else { // can free memory - final Solution sol = Solution.unsatisfiable(stats, null); - cnf.free(); - return sol; - } - } - - /** - * Returns the result of solving a trivially (un)sat formula. - * - * @param translation trivial translation produced as the result of - * {@code translation.formula} simplifying to a constant with respect - * to {@code translation.bounds} - * @param translTime translation time - * @return the result of solving a trivially (un)sat formula. - */ - static Solution trivial(Translation.Whole translation, long translTime) { - final Statistics stats = new Statistics(0, 0, 0, translTime, 0); - final Solution sol; - if (translation.cnf().solve()) { - sol = Solution.triviallySatisfiable(stats, translation.interpret()); - } else { - sol = Solution.triviallyUnsatisfiable(stats, trivialProof(translation.log())); - } - translation.cnf().free(); - return sol; - } - - /** - * Returns a proof for the trivially unsatisfiable log.formula, provided that - * log is non-null. Otherwise returns null. - * - * @requires log != null => log.formula is trivially unsatisfiable - * @return a proof for the trivially unsatisfiable log.formula, provided that - * log is non-null. Otherwise returns null. - */ - private static Proof trivialProof(TranslationLog log) { - return log == null ? null : new TrivialProof(log); - } - - public static Solution solveTranslation(final long translTime, final Translation translation) { - final Solution solution; - if (translation.trivial()) { - final Statistics stats = new Statistics(translation, translTime, 0); - if (translation.cnf().solve()) { - solution = Solution.triviallySatisfiable(stats, translation.interpret()); - } else { - solution = Solution.triviallyUnsatisfiable(stats, null); - } - } else { - final SATSolver cnf = translation.cnf(); - - translation.options().reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses()); - final long startSolve = System.currentTimeMillis(); - final boolean sat = cnf.solve(); - final long endSolve = System.currentTimeMillis(); - - final Statistics stats = new Statistics(translation, translTime, endSolve - startSolve); - if (sat) { - solution = Solution.satisfiable(stats, translation.interpret()); - } else { - solution = Solution.unsatisfiable(stats, null); - } - } - return solution; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Statistics.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Statistics.java deleted file mode 100644 index 368861e2e..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/Statistics.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import kodkod.engine.fol2sat.Translation; - -/** - * Stores the statistics gathered while solving a given formula. - * - * @specfield formula: Formula // the formula being solved - * @specfield bounds: Bounds // the bounds on the formula - */ -public final class Statistics { - - private static final String NEW_LINE = System.getProperty("line.separator"); - - private final int vars, pVars, clauses; - private final long translation, solving; - - private long procTranslTime = 0; - private int numCandidates = 1; - - /** - * Constructs a new Statistics object using the provided values. - */ - Statistics(int primaryVariables, int variables, int clauses, long translationTime, long solvingTime) { - this.pVars = primaryVariables; - this.vars = variables; - this.clauses = clauses; - this.translation = translationTime; - this.solving = solvingTime; - } - - /** - * Constructs a new Statistics object using the provided values. - */ - Statistics(Translation translation, long translationTime, long solvingTime) { - this(translation.numPrimaryVariables(), translation.cnf().numberOfVariables(), translation.cnf().numberOfClauses(), translationTime, solvingTime); - } - - /** - * Returns the number of variables needed to encode this.formula in CNF. - * - * @return the number of variables needed to encode this.formula in CNF. - */ - public int variables() { - return vars; - } - - /** - * Returns the number of primary variables used in the encoding of this.formula; - * i.e. the variables allocated to all the relations at the leaves of - * this.formula. - * - * @return the number of primary variables used in the encoding of this.formula - */ - public int primaryVariables() { - return pVars; - } - - /** - * Returns the number of clauses needed to encode this.formula in CNF. - * - * @return the number of variables needed to encode this.formula in CNF. - */ - public int clauses() { - return clauses; - } - - /** - * Returns the number of miliseconds spent on translation this.formula to CNF. - * - * @return the number of miliseconds spent on translation this.formula to CNF. - */ - public long translationTime() { - return translation; - } - - /** - * Returns the number of miliseconds spent on solving the CNF encoding of - * this.formula. - * - * @return the number of miliseconds spent on solving the CNF encoding of - * this.formula. - */ - public long solvingTime() { - return solving; - } - - public void setProcTranslTime(long procTranslTime) { - this.procTranslTime = procTranslTime; - } - - public void setNumCandidates(int numCandidates) { - this.numCandidates = numCandidates; - } - - public long procTranslTime() { - return this.procTranslTime; - } - - public int numCandidates() { - return this.numCandidates; - } - - /** - * Returns a string representation of this Statistics object. - * - * @return a string representation of this Statistics object. - */ - @Override - public String toString() { - final StringBuilder ret = new StringBuilder(); - ret.append("p cnf "); - ret.append(vars); - ret.append(" "); - ret.append(clauses); - ret.append(NEW_LINE); - ret.append("primary variables: "); - ret.append(pVars); - ret.append(NEW_LINE); - ret.append("translation time: "); - ret.append(translation); - ret.append(" ms").append(NEW_LINE); - ret.append("solving time: "); - ret.append(solving); - ret.append(" ms"); - return ret.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/TrivialProof.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/TrivialProof.java deleted file mode 100644 index 6aed358b5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/TrivialProof.java +++ /dev/null @@ -1,416 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Formula; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.RelationPredicate; -import kodkod.ast.Variable; -import kodkod.ast.visitor.AbstractVoidVisitor; -import kodkod.engine.fol2sat.RecordFilter; -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.TranslationRecord; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.instance.TupleSet; -import kodkod.util.collections.IdentityHashSet; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - * A proof of unsatisfiability for a trivially unsatisfiable formula. A formula - * is considered trivally unsatisfiable if its unsatisfiability is discovered - * through translation alone. - * - * @author Emina Torlak - */ -final class TrivialProof extends Proof { - - private Map coreRoots; - private RecordFilter coreFilter; - - /** - * Constructs a proof of unsatisfiability for the trivially unsatisfiable - * formula whose translation is recorded in the given log. - * - * @requires log != null - * @ensures this.formula' = log.formula - */ - TrivialProof(TranslationLog log) { - super(log); - this.coreFilter = null; - this.coreRoots = null; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.Proof#core() - */ - @Override - public final Iterator core() { - if (coreFilter == null) { - coreFilter = new RecordFilter() { - - final Set coreNodes = NodePruner.relevantNodes(log(), coreRoots == null ? log().roots() : coreRoots.keySet()); - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return coreNodes.contains(translated); - } - }; - } - return log().replay(coreFilter); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.Proof#highLevelCore() - */ - @Override - public final Map highLevelCore() { - if (coreRoots == null) { - final Iterator itr = core(); - final Set roots = log().roots(); - coreRoots = new LinkedHashMap(); - while (itr.hasNext()) { - TranslationRecord rec = itr.next(); - if (roots.contains(rec.translated())) - coreRoots.put(rec.translated(), rec.node()); - } - coreRoots = Collections.unmodifiableMap(coreRoots); - } - return coreRoots; - } - - /** - * Minimizes the current core using the trivial strategy that does one of the - * following: (1) if there is a root that simplified to FALSE, sets the minimal - * core to that root; or (2) if not, there must be two roots that translated to - * x and -x, where x is a boolean literal, so we pick those two as the minimal - * core. The strategy argument is ignored (it can be null). - * - * @see Proof#minimize(ReductionStrategy) - */ - @Override - public void minimize(ReductionStrategy strategy) { - final Map rootLits = new LinkedHashMap(); - final Map rootNodes = new LinkedHashMap(); - final Set roots = log().roots(); - - for (Iterator itr = core(); itr.hasNext();) { - final TranslationRecord rec = itr.next(); - if (roots.contains(rec.translated())) { - // simply record the most recent output value for each formula: - // this is guaranteed to be the final output value for that - // formula because of the translation log guarantee that the - // log is replayed in the order of translation: i.e. a child's - // output value is always recorded before the parent's - int[] val = rootLits.get(rec.translated()); - if (val == null) { - val = new int[1]; - rootLits.put(rec.translated(), val); - } - val[0] = rec.literal(); - rootNodes.put(rec.translated(), rec.node()); - } - } - - final SparseSequence lits = new TreeSequence(); - for (Map.Entry entry : rootLits.entrySet()) { - final int lit = entry.getValue()[0]; - if (lit == -Integer.MAX_VALUE) { - coreRoots = Collections.singletonMap(entry.getKey(), rootNodes.get(entry.getKey())); - break; - } else if (lits.containsIndex(-lit)) { - final Formula f0 = lits.get(-lit); - final Formula f1 = entry.getKey(); - coreRoots = new LinkedHashMap(3); - coreRoots.put(f0, rootNodes.get(f0)); - coreRoots.put(f1, rootNodes.get(f1)); - coreRoots = Collections.unmodifiableMap(coreRoots); - break; - } else { - lits.put(lit, entry.getKey()); - } - } - - coreFilter = null; - assert coreRoots.size() == 1 && rootLits.get(coreRoots.keySet().iterator().next())[0] == -Integer.MAX_VALUE || coreRoots.size() == 2; - } - - /** - * Given a translation log for a trivially unsatisfiable formula, finds the - * nodes necessary for proving the formula's unsatisfiability. Instances of this - * visitor should be constructed and applied using the - * {@linkplain #relevantNodes(TranslationLog)} - * - * @specfield log: TranslationLog - * @author Emina Torlak - */ - private static final class NodePruner extends AbstractVoidVisitor { - - private final Set visited, relevant; - private final Map constNodes; - - /** - * Constructs a proof finder for the given log. - * - * @ensures this.log' = log - */ - NodePruner(TranslationLog log) { - visited = new IdentityHashSet(); - relevant = new IdentityHashSet(); - - final RecordFilter filter = new RecordFilter() { - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return env.isEmpty(); - } - }; - - constNodes = new LinkedHashMap(); - for (Iterator itr = log.replay(filter); itr.hasNext();) { - TranslationRecord rec = itr.next(); - int lit = rec.literal(); - if (Math.abs(lit) != Integer.MAX_VALUE) { - constNodes.remove(rec.translated()); - } else if (lit == Integer.MAX_VALUE) { - constNodes.put(rec.translated(), Boolean.TRUE); - } else { - constNodes.put(rec.translated(), Boolean.FALSE); - } - } - } - - /** - * Returns the nodes necessary for proving the trivial unsatisfiability of - * log.formula. - * - * @requires some r: log.records | r.node = log.formula && r.literal = - * BooleanConstant.FALSE.label - * @requires highLevelCore in log.roots() and unsatisfiable(highLevelCore, - * log.bounds, log.options) - * @return nodes necessary for proving the trivial unsatisfiability of - * log.formula. - */ - static Set relevantNodes(TranslationLog log, Set highLevelCore) { - final NodePruner finder = new NodePruner(log); - for (Formula root : highLevelCore) { - if (!finder.isTrue(root)) { - root.accept(finder); - } - } - return finder.relevant; - } - - /** - * Returns true if the given node has been visited before. - * - * @ensures this.visited' = this.visited + n - * @return n in this.visited - */ - @Override - protected boolean visited(Node n) { - return !visited.add(n); - } - - /** - * Returns true if the node was simplified to TRUE during translation. - * - * @return some r: this.log.records | r.node = node && no r.env && r.literal = - * BooleanConstant.TRUE.label - */ - final boolean isTrue(Node node) { - return constNodes.get(node) == Boolean.TRUE; - } - - @Override - public void visit(Decl decl) { - if (visited(decl)) - return; - relevant.add(decl); - } - - @Override - public void visit(QuantifiedFormula quantFormula) { - if (visited(quantFormula)) - return; - relevant.add(quantFormula); - } - - @Override - public void visit(ComparisonFormula compFormula) { - if (visited(compFormula)) - return; - relevant.add(compFormula); - } - - @Override - public void visit(MultiplicityFormula multFormula) { - if (visited(multFormula)) - return; - relevant.add(multFormula); - } - - @Override - public void visit(RelationPredicate pred) { - if (visited(pred)) - return; - relevant.add(pred); - } - - @Override - public void visit(IntComparisonFormula intComp) { - if (visited(intComp)) - return; - relevant.add(intComp); - } - - @Override - public void visit(ConstantFormula formula) { - relevant.add(formula); - } - - /** - * If the argument node has been been visited, adds it to this.relevant and - * visits its child. - */ - @Override - public void visit(NotFormula not) { - if (visited(not)) - return; - relevant.add(not); - not.formula().accept(this); - } - - /** - * If this formula should be visited, then we visit its children only if they - * could have contributed to the unsatisfiability of the top-level formula. For - * example, let binFormula = "p && q", binFormula simplified to FALSE, p - * simplified to FALSE and q was not simplified, then only p should be visited - * since p caused binFormula's reduction to FALSE. - */ - @Override - public void visit(BinaryFormula binFormula) { - if (visited(binFormula)) - return; - relevant.add(binFormula); - - final Formula l = binFormula.left(), r = binFormula.right(); - final Boolean lval = constNodes.get(l), rval = constNodes.get(r); - final boolean lvisit, rvisit; - - switch (binFormula.op()) { - case AND : - lvisit = (lval == Boolean.FALSE || (lval == null && rval != Boolean.FALSE)); - rvisit = (rval != Boolean.TRUE && lval != Boolean.FALSE); - break; - case OR : - lvisit = (lval == Boolean.TRUE || (lval == null && rval != Boolean.TRUE)); - rvisit = (rval != Boolean.FALSE && lval != Boolean.TRUE); - break; - case IMPLIES : // !l || r - lvisit = (lval == Boolean.FALSE || (lval == null && rval != Boolean.TRUE)); - rvisit = (rval != Boolean.FALSE && lval != Boolean.FALSE); - break; - case IFF : // (!l || r) && (l || !r) - lvisit = rvisit = true; - break; - default : - throw new IllegalArgumentException("Unknown operator: " + binFormula.op()); - } - - if (lvisit) { - l.accept(this); - } - if (rvisit) { - r.accept(this); - } - } - - /** - * If this formula should be visited, then we visit its children only if they - * could have contributed to the unsatisfiability of the top-level formula. For - * example, let binFormula = "p && q", binFormula simplified to FALSE, p - * simplified to FALSE and q was not simplified, then only p should be visited - * since p caused binFormula's reduction to FALSE. - */ - @Override - public void visit(NaryFormula formula) { - if (visited(formula)) - return; - relevant.add(formula); - - final Boolean val = constNodes.get(formula); - final Boolean cancel; - - switch (formula.op()) { - case AND : - cancel = Boolean.FALSE; - break; - case OR : - cancel = Boolean.TRUE; - break; - default : - throw new IllegalArgumentException("Unknown nary operator: " + formula.op()); - } - - final Boolean iden = Boolean.valueOf(!cancel); - if (val != iden) { - for (Formula child : formula) { - if (constNodes.get(child) == cancel) { - child.accept(this); - return; - } - } - for (Formula child : formula) { - if (constNodes.get(child) != iden) { - child.accept(this); - } - } - return; - } - - for (Formula child : formula) { - child.accept(this); - } - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BinaryGate.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BinaryGate.java deleted file mode 100644 index e56d85505..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BinaryGate.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Set; - -/** - * A logic gate with two inputs. - * - * @invariant #this.inputs = 2 - * @invariant digest = sum(inputs.digest(this.op)) - */ -final class BinaryGate extends MultiGate { - - private final BooleanFormula low, high; - - /** - * Constructs a new binary gate with the given operator, label, and inputs. - * - * @requires components.h = components.l && l.label < h.label - * @ensures this.op' = op && this.inputs' = l + h && this.label' = label - */ - BinaryGate(Operator.Nary op, int label, int hashcode, BooleanFormula l, BooleanFormula h) { - super(op, label, hashcode); - assert l.label() < h.label(); - this.low = l; - this.high = h; - } - - /** - * Returns an integer k' such that 0 < |k'| < k and |k'| is the number of - * flattening steps that need to be taken to determine that this circuit has (or - * does not have) an input with the given label. A positive k' indicates that f - * is found to be an input to this circuit in k' steps. A negative k' indicates - * that f is not an input to this circuit, when it is flattened using at most k - * steps. - * - * @requires k > 0 - * @return the number of flattening steps that need to be taken to determine - * that f is (not) an input to this circuit - */ - @Override - int contains(Operator op, int f, int k) { - assert k > 0; - if (f == label()) - return 1; - else if (this.op != op || k < 2 || f > label() || -f > label()) - return -1; - else { - final int l = low.contains(op, f, k - 1); - if (l > 0) - return l; - else { - final int h = high.contains(op, f, k - l); - return h > 0 ? h - l : h + l; - } - } - } - - /** - * Flattens this circuit with respect to the given operator into the provided - * set. Specifically, the method modifies the set so that it contains the - * elements f_0, ..., f_k' where k' <= k elements and [[this]] = op(f_0, ..., - * f_k'). The default implementation simply adds this to the set. - * - * @requires k > 0 - * @ensures 1 <= k' <= k && some f_0,..., f_k' : flat.elts' | [[this]] = - * op([[f_0]], ..., [[f_k']]) - */ - @Override - void flatten(Operator op, Set flat, int k) { - assert k > 0; - if (this.op == op && k > 1) { - final int oldsize = flat.size(); - low.flatten(op, flat, k - 1); - high.flatten(op, flat, k - (flat.size() - oldsize)); - } else { - flat.add(this); - } - } - - /** - * Returns 2. - * - * @return 2 - */ - @Override - public int size() { - return 2; - } - - /** - * Returns an iterator over the inputs to this gate, in the increasing label - * order. - * - * @return an iterator over this.inputs. - */ - @Override - public Iterator iterator() { - return new Iterator() { - - int next = 0; - - @Override - public boolean hasNext() { - return next < 2; - } - - @Override - public BooleanFormula next() { - if (!hasNext()) - throw new NoSuchElementException(); - return (next++ == 0 ? low : high); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - /** - * Returns the ith input to this gate. - * - * @return this.inputs[i] - * @requires 0 <= i < size - * @throws IndexOutOfBoundsException i < 0 || i >= #this.inputs - */ - @Override - public BooleanFormula input(int i) { - switch (i) { - case 0 : - return low; - case 1 : - return high; - default : - throw new IndexOutOfBoundsException(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanAccumulator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanAccumulator.java deleted file mode 100644 index 75d382d77..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanAccumulator.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; - -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - * An accumulator for easy construction of gates with multiple inputs. An - * accumulator cannot be combined with other boolean values using BooleanFactory - * methods. To use the circuit represented by an accumulator, one must first - * convert it into a gate by calling - * {@link BooleanFactory#accumulate(BooleanAccumulator)}. - * - * @specfield components: set BooleanValue - * @specfield op: Operator.Nary - * @author Emina Torlak - */ -public final class BooleanAccumulator extends BooleanValue implements Iterable { - - final Operator.Nary op; - private final SparseSequence inputs; - // private final List inputs; - - /** - * Constructs a new accumulator with the given operator. - * - * @requires op != null - * @ensures this.op' = op && this.label' = label - */ - private BooleanAccumulator(Operator.Nary op) { - this.op = op; - inputs = new TreeSequence(); - // inputs = new ArrayList(); - } - - /** - * Returns a tree based implementation of BooleanAccumulator. The addInput - * operation executes in O(lg n) time where n is the number of gate inputs. - * - * @return an empty tree based BooleanAccumulator with the given operator. - * @throws NullPointerException op = null - */ - public static BooleanAccumulator treeGate(Operator.Nary op) { - if (op == null) - throw new NullPointerException(); - return new BooleanAccumulator(op); - } - - /** - * Returns a tree based implementation of BooleanAccumulator, initialized with - * the given inputs. The addInput operation executes in O(lg n) time where n is - * the number of gate inputs. - * - * @return a tree based BooleanAccumulator with the given operator, initialized - * with the given inputs - * @throws NullPointerException op = null || inputs = null - */ - public static BooleanAccumulator treeGate(Operator.Nary op, BooleanValue... inputs) { - if (op == null) - throw new NullPointerException(); - final BooleanAccumulator ret = new BooleanAccumulator(op); - for (BooleanValue v : inputs) { - if (ret.add(v) != ret) - break; - } - return ret; - } - - /** - * Returns the operator for this accumulator. - * - * @return this.op - */ - @Override - public Operator.Nary op() { - return op; - } - - /** - * Adds the given value to this.components and returns the result. Specifically, - * if the addition of the value causes the gate to evaluate to op.shortCircuit, - * then this.inputs is set to op.shortCircuit. If the given value has already - * been added or it is equal to this.op.identity, nothing changes. Otherwise, v - * is added to this.input. The method returns this.op.shortCircuit if - * this.inputs contains it after the addition, otherwise it returns the gate - * itself. - * - * @ensures v = this.op.shortCircuit || v.negation in this.components => - * this.components' = this.op.shortCircuit, v !in BooleanConstant => - * this.components' = this.components + v, this.components' = - * this.components - * @return this.components' = op.shortCircuit => op.shortCircuit, this - */ - public BooleanValue add(BooleanValue v) { - if (isShortCircuited()) - return op.shortCircuit(); - else { - final int lit = v.label(); - if (v == op.shortCircuit() || inputs.containsIndex(-lit)) { - inputs.clear(); - inputs.put(op.shortCircuit().label, op.shortCircuit()); - return op.shortCircuit(); - } - if (v != op.identity() && !inputs.containsIndex(lit)) { - inputs.put(lit, v); - } - // if (v==op.shortCircuit()) { - // inputs.clear(); - // inputs.add(op.shortCircuit()); - // return op.shortCircuit(); - // } - // if (v!=op.identity()) { inputs.add(v); } - return this; - } - } - - /** - * Returns true if this gate is short circuited; that is, its inputs are reduced - * to this.op.shortCircuit. - * - * @return this.inputs = this.op.shortCircuit - */ - public boolean isShortCircuited() { - return inputs.size() == 1 && inputs.first().value() == op.shortCircuit(); - // return inputs.size()==1 && inputs.get(0)==op.shortCircuit(); - } - - /** - * Throws an IllegalArgumentException if op != this.op, otherwise returns the - * sum of digests of this gate's inputs with respect to the given operator. - * - * @return op = this.op => sum(this.inputs.digest(op)) - * @throws IllegalArgumentException op != this.op - * @throws ClassCastException some this.inputs & BooleanConstant - */ - int digest(Operator op) { - if (this.op != op) - throw new IllegalArgumentException(); - int d = 0; - for (Iterator inputs = iterator(); inputs.hasNext();) { - d += ((BooleanFormula) inputs.next()).hash(op); - } - return d; - } - - /** - * Returns the size of this accumulator. - * - * @return #this.inputs - */ - public int size() { - return inputs.size(); - } - - /** - * Returns an iterator over this.components, in the increasing order of labels. - * The returned iterator does not support removal. - * - * @return an iterator over this.components, in the increasing order of labels. - */ - @Override - public Iterator iterator() { - return new Iterator() { - - final Iterator> iter = inputs.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public BooleanValue next() { - return iter.next().value(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - }; - // return inputs.iterator(); - } - - /** - * Throws an unsupported operation exception. - * - * @throws UnsupportedOperationException - */ - @Override - BooleanValue negation() { - throw new UnsupportedOperationException(); - } - - /** - * Returns 0. - * - * @return 0. - */ - @Override - public int label() { - return 0; - } - - @Override - public String toString() { - return inputs.toString(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanConstant.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanConstant.java deleted file mode 100644 index 34eb32d99..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanConstant.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -/** - * A boolean constant, true or false. The integer label of the true and false - * constants are Integer.MAX_VALUE and -Integer.MAX_VALUE, respectively. The two - * boolean constants, TRUE and FALSE, are shared among all factories. - * - * @specfield value: boolean - * @invariant this.op = Operator.CONST - * @invariant value => Integer.MAX_VALUE, -Integer.MAX_VALUE - * @author Emina Torlak - */ -public final class BooleanConstant extends BooleanValue { - - final int label; - - public static final BooleanConstant TRUE = new BooleanConstant(true); - public static final BooleanConstant FALSE = new BooleanConstant(false); - - /** - * Constructs a BooleanConstant that represent the given boolean value. - * - * @ensures value => this.label' = Integer.MAX_VALUE, this.label' = - * -Integer.MAX_VALUE - */ - private BooleanConstant(boolean value) { - this.label = (value ? Integer.MAX_VALUE : -Integer.MAX_VALUE); - } - - /** - * Returns the negation of this value. - * - * @return c: BooleanConstant | [[c]] = ![[this]] - */ - @Override - BooleanValue negation() { - return this == TRUE ? FALSE : TRUE; - } - - /** - * Returns the primitive boolean representation of this label. - * - * @return this.label == Integer.MAX_VALUE - */ - public boolean booleanValue() { - return label > 0; - } - - /** - * Returns the BooleanConstant that represents the given boolean value. - * - * @return {c: BooleanConstant | value => c.label = Integer.MAX_VALUE, c.label = - * -Integer.MAX_VALUE } - */ - public static BooleanConstant constant(boolean value) { - return value ? TRUE : FALSE; - } - - /** - * Returns the label for this value. - * - * @return this.label - */ - @Override - public int label() { - return label; - } - - /** - * Returns a string representation of this boolean value. - * - * @return a string representation of this boolean value. - */ - @Override - public String toString() { - return label > 0 ? "T" : "F"; - } - - /** - * Returns Operator.CONST. - * - * @return Operator.CONST - */ - @Override - public Operator op() { - return Operator.CONST; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanFactory.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanFactory.java deleted file mode 100644 index eade639fd..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanFactory.java +++ /dev/null @@ -1,556 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import static kodkod.engine.bool.Operator.AND; -import static kodkod.engine.bool.Operator.OR; - -import java.util.Collection; -import java.util.Iterator; - -import kodkod.engine.config.Options; -import kodkod.engine.config.Options.IntEncoding; -import kodkod.engine.config.Options.OverflowPolicy; -import kodkod.util.ints.IntSet; - -/** - * A factory for creating {@link kodkod.engine.bool.BooleanValue boolean - * values}, {@link kodkod.engine.bool.BooleanMatrix matrices}, and - * {@link kodkod.engine.bool.Int ints}. - * - * @specfield comparisonDepth: int // the depth to which circuits should be - * checked for equality - * @specfield intEncoding: {@link IntEncoding} // the encoding used for - * generating integers ({@link #integer(int)} - * @specfield bitwidth: int // the bitwidth used for integer computations - * @specfield components: set {@link BooleanValue} - * @invariant {@link BooleanConstant} in components - * @invariant no f1, f2: BooleanFactory | f1 != f2 => f1.components & - * f2.components = {@link BooleanConstant} - * @invariant let formulas = (components & {@link BooleanFormula}) - - * {@link NotGate} | min(formulas.label) = 1 && max(formulas.label) = - * #formulas - * @author Emina Torlak - */ -public abstract class BooleanFactory { - - /** - * A circuit factory used internally to assemble circuits. - */ - private final CBCFactory circuits; - - private int numVars; - - /** The bitwidth used for integer computations */ - final int bitwidth; - - /** Whether or not it should forbid overflows */ // [AM] - final OverflowPolicy noOverflow; - - /** - * Constructs a boolean factory with the given number of input variables. Gates - * are checked for semantic equality down to the given depth. Integers are - * represented using the given number of bits. The noOverflow bit tells whether - * or not to forbid overflows. - * - * @requires 0 <= numVars < Integer.MAX_VALUE - * @requires checkToDepth >= 0 && bitwidth > 0 - * @ensures #this.components' = numInputVariables && this.components' in - * BooleanVariable - * @ensures this.bitwidth' = bitwidth - * @ensures this.comparisonDepth' = comparisonDepth - */ - private BooleanFactory(int numVars, int comparisonDepth, int bitwidth, OverflowPolicy overflowPolicy) { - this.circuits = new CBCFactory(numVars, 1 << comparisonDepth); - this.bitwidth = bitwidth; - this.numVars = numVars; - this.noOverflow = overflowPolicy; - } - - /** - * Returns a boolean factory, initialized to contain the given number of boolean - * variables. - *

- * Gates are checked for semantic equality down to the depth given by - * options.sharing when checking for cached values. In general, setting the - * comparison depth to a higher value will result in more subcomponents being - * shared. However, it will also slow down gate construction. - *

- *

- * Integers are created/manipulated according to the specifications in the given - * Options object. - *

- * - * @return {f: BooleanFactory | #(f.components & BooleanVariable) = numVars && - * BooleanConstant in f.components && f.components in BooleanVariable + - * BooleanConstant && f.comparisonDepth = options.sharing && f.bitwidth - * = options.bitwidth && f.intEncoding = options.intEncoding && (all i: - * [1..numVars] | one f.components.label & i }} - * @throws IllegalArgumentException numVars < 0 || numVars = Integer.MAX_VALUE - * @throws NullPointerException options = null - */ - public static BooleanFactory factory(int numVars, Options options) { - switch (options.intEncoding()) { - case TWOSCOMPLEMENT : - return new TwosComplementFactory(numVars, options.sharing(), options.bitwidth(), options.overflowPolicy()); - default : - throw new IllegalArgumentException("unknown encoding: " + options.intEncoding()); - } - } - - /** - * Returns a BooleanFactory with no variables; the returned factory can - * manipulate only constants. - * - * @return {f: BooleanFactory | f.components = BooleanConstant && - * f.comparisonDepth = options.sharing && f.bitwidth = options.bitwidth - * && f.intEncoding = options.intEncoding } - * @throws NullPointerException options = null - */ - public static BooleanFactory constantFactory(Options options) { - return factory(0, options); - } - - /** - * Returns the depth (from the root) to which components are checked for - * semantic equality during gate construction. - * - * @return this.comparisonDepth - */ - public final int comparisonDepth() { - return Integer.numberOfTrailingZeros(circuits.cmpMax()); - } - - /** - * Sets the comparison depth to the given value. Setting the comparison depth to - * a high value will result in more subcomponents being shared. However, it will - * also slow down gate construction. - * - * @ensures this.comparisonDepth' = newDepth - * @throws IllegalArgumentException newDepth < 1 - */ - public final void setComparisonDepth(int newDepth) { - if (newDepth < 1) - throw new IllegalArgumentException("newDepth < 1: " + newDepth); - circuits.setCmpMax(1 << newDepth); - } - - /** - * Returns the bitwidth used for integer representation. - * - * @return this.bitwidth - */ - public final int bitwidth() { - return bitwidth; - } - - /** Returns the noOverflow flag */ // [AM] - public final OverflowPolicy noOverflow() { - return noOverflow; - } - - /** - * Returns the encoding used by this factory to represent integers. - * - * @return this.intEncoding - */ - public abstract Options.IntEncoding intEncoding(); - - /** - * Returns true if v is in this.components. - * - * @return v in this.components - * @throws NullPointerException v = null - */ - public final boolean contains(BooleanValue v) { - return circuits.canAssemble(v); - } - - /** - * Returns the maximum label of a {@link BooleanVariable variable} in - * {@code this.components}. - * - * @return max((this.components & BooleanVariable).label) - */ - public final int maxVariable() { - return circuits.maxVariable(); - } - - /** - * Returns the maximum label of a {@link BooleanFormula formula} in - * {@code this.components}. Note that {@link #maxFormula()} >= - * {@link #maxVariable()} since variables themselves are formulas. - * - * @return max((this.components & BooleanFormula).label) - */ - public final int maxFormula() { - return circuits.maxFormula(); - } - - /** - * Returns the variable with the given label. - * - * @requires 0 < label <= numberOfVariables() - * @return (this.components & BooleanVariable).label - */ - public final BooleanVariable variable(int label) { - return circuits.variable(label); - } - - /** - * Adds the specified number of fresh variables to {@code this.components}. - * - * @requires numVars >= 0 - * @ensures let diff = this.components' - this.components | diff in - * BooleanVariable && #diff = numVars && diff.label = { i: int | - * this.maxFormula() < i <= this.maxFormula() + numVars } - */ - public final void addVariables(int numVars) { - if (numVars < 0) { - throw new IllegalArgumentException("Expected numVars >= 0, given numVars = " + numVars); - } else if (numVars > 0) { - circuits.addVariables(numVars); - this.numVars += numVars; - } // else do nothing - } - - /** - * Returns the number of variables in this factory. - * - * @return #(this.components & BooleanVariable) - */ - public final int numberOfVariables() { - return numVars; - } - - /** - * Returns the negation of the given boolean value. - * - * @return {n: BooleanValue | n.label = -v.label && [[n]] = ![[v]] } - * @ensures (components.v).components' = (components.v).components + n - * @throws NullPointerException v = null - */ - public final BooleanValue not(BooleanValue v) { - return v.negation(); - } - - /** - * Returns a boolean value whose meaning is the conjunction of the input - * components. The behavior of this method is unspecified if v0 or v1 are not - * components of this factory. - * - * @requires v0 + v1 in this.components - * @return {v: BooleanValue | [[v]] = [[v0]] AND [[v1]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue and(BooleanValue v0, BooleanValue v1) { - return circuits.assemble(AND, v0, v1); - } - - /** - * Returns a boolean value whose meaning is the disjunction of the input - * components. The behavior of this method is unspecified if v0 or v1 are not - * components of this factory. - * - * @requires v0 + v1 in this.components - * @return {v: BooleanValue | [[v]] = [[v0]] OR [[v1]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - * @throws IllegalArgumentException v0 + v1 !in this.components - */ - public final BooleanValue or(BooleanValue v0, BooleanValue v1) { - return circuits.assemble(OR, v0, v1); - } - - /** - * Returns a boolean value whose meaning is [[v0]] ^ [[v1]]. The behavior of - * this method is unspecified if v0 or v1 are not components of this factory. - * - * @requires v0 + v1 in this.components - * @return { v: BooleanValue | [[v]] = [[v0]] xor [[v1]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue xor(BooleanValue v0, BooleanValue v1) { - return circuits.assemble(v0, v1.negation(), v1); - } - - /** - * Returns a boolean value whose meaning is [[v0]] => [[v1]]. The behavior of - * this method is unspecified if v0 or v1 are not components of this factory. - * - * @requires v0 + v1 in this.components - * @return { v: BooleanValue | [[v]] = [[v0]] => [[v1]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue implies(BooleanValue v0, BooleanValue v1) { - return circuits.assemble(OR, v0.negation(), v1); - } - - /** - * Returns a boolean value whose meaning is [[v0]] <=> [[v1]]. The behavior of - * this method is unspecified if v0 or v1 are not components of this factory. - * - * @requires v0 + v1 in this.components - * @return { v: BooleanValue | [[v]] = [[v0]] iff [[v1]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue iff(BooleanValue v0, BooleanValue v1) { - return circuits.assemble(v0, v1, v1.negation()); - } - - /** - * Returns a boolean value whose meaning is [[i]] ? [[t]] : [[e]]. The behavior - * of this method is unspecified if i, t, or e are not components of this - * factory. - * - * @requires i + t + e in this.components - * @return { v: BooleanValue | [[v]] = [[i]] ? [[t]] : [[e]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue ite(BooleanValue i, BooleanValue t, BooleanValue e) { - return circuits.assemble(i, t, e); - } - - /** - * Returns a boolean value whose meaning is the sum bit of a full binary adder. - * The behavior of this method is unspecified if v0, v1, or cin are not - * components of this factory. - * - * @requires v0 + v1 + cin in this.components - * @return { v: BooleanValue | [[v]] = [[cin]] xor [[v0]] xor [[v1]] } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue sum(BooleanValue v0, BooleanValue v1, BooleanValue cin) { - return xor(cin, xor(v0, v1)); - } - - /** - * Returns a boolean value whose meaning is the carry out bit of a full binary - * adder. The behavior of this method is unspecified if v0, v1, or cin are not - * components of this factory. - * - * @requires v0 + v1 + cin in this.components - * @return { v: BooleanValue | [[v]] = ([[v0]] and [[v1]]) or ([[cin]] and - * ([[v0]] xor [[v1]])) } - * @ensures this.components' = this.components + v - * @throws NullPointerException any of the arguments are null - */ - public final BooleanValue carry(BooleanValue v0, BooleanValue v1, BooleanValue cin) { - return or(and(v0, v1), and(cin, xor(v0, v1))); - } - - /** - * Converts the given accumulator into an immutable boolean value and adds it to - * this.components. This method requires that all of g's inputs are in - * this.components. If g has no inputs, its operator's identity constant is - * returned. If g has one input, that input is returned. Otherwise, an immutable - * value that is semantically equivalent to g is returned. The behavior of this - * method is unspecified if the components of g are not components of this - * factory. - * - * @requires g.components in this.components - * @return no g.inputs => g.op.identity(), one g.inputs => g.inputs, {g' : - * BooleanValue - BooleanAccumulator | [[g']] = [[g]] } - * @ensures this.components' = this.components + g' - */ - public final BooleanValue accumulate(BooleanAccumulator g) { - return circuits.assemble(g); - } - - /** - * Returns an Int that represents the given number using this.intEncoding. - * - * @return { i: Int | [[i]] = number && i.encoding && this.intEncoding && - * i.factory = this} - * @throws IllegalArgumentException the number cannot be represented using the - * specified encoding - */ - public abstract Int integer(int number); - - /** - * Returns an Int that represents 0 or the given number, depending on the value - * of the given bit. The behavior of this method is unspecified if the bit is - * not a component of this factory. - * - * @return { i: Int | [[bit]] => [[i]] = number, [[i]] = 0 && i.encoding = - * this.intEncoding && i.factory = this} - */ - public abstract Int integer(int number, BooleanValue bit); - - /** - * Returns an Int that represents the sum of the elements returned by the - * iterator, using this.intEncoding. - * - * @param lo the first element of the current partial sum. Initial should be 0. - * @param hi the last element of the current partial sum. Initial should be - * size-1, where size is the total number of elements returned by the - * iterator. - * @return an Int that represents the sum of the elements returned by the - * iterator, using this.intEncoding. - */ - private Int sum(Iterator values, int low, int high) { - if (low > high) - return integer(0); - else if (low == high) - return integer(1, values.next()); - else { - final int mid = (low + high) / 2; - final Int lsum = sum(values, low, mid); - final Int hsum = sum(values, mid + 1, high); - return lsum.plus(hsum); - } - } - - /** - * Returns an Int that represents the sum of all values in the given collection. - * - * @return an Int that represents the sum of all values in the given collection. - */ - public final Int sum(Collection bits) { - return sum(bits.iterator(), 0, bits.size() - 1); - } - - /** - * Returns a BooleanMatrix with the given dimensions and this as the factory for - * its non-FALSE components. The returned matrix can store any value from - * this.components at all indices between 0, inclusive, and d.capacity(), - * exclusive. - * - * @throws NullPointerException d = null - * @return { m: BooleanMatrix | m.factory = this && m.dimensions = d && - * m.elements = [0..d.capacity) -> one FALSE } - */ - public final BooleanMatrix matrix(Dimensions d) { - if (d == null) - throw new NullPointerException(); - return new BooleanMatrix(d, this); - } - - /** - * @throws IllegalArgumentException indices !in [0..d.capacity()) - */ - private static void validate(IntSet indices, Dimensions d) { - if (!indices.isEmpty()) { - if (!d.validate(indices.min()) || !d.validate(indices.max())) - throw new IllegalArgumentException(); - } - } - - /** - * Returns a BooleanMatrix m with the given dimensions, this as its - * factory, and the indices from the set trueIndices initialized to - * TRUE. An IndexOutOfBoundsException may be thrown if - * {@link BooleanMatrix#set(int, BooleanValue)} is called on m with an - * index not contained in allIndices. If - * allIndices.equals(trueIndices), m may be a constant matrix; - * that is, an IllegalArgumentException may be thrown if - * {@link BooleanMatrix#set(int, BooleanValue)} is called on m with a - * non-constant value. Finally, if cloning trueIndices results in an - * immutable set, then {@link BooleanMatrix#set(int, BooleanValue) m.set(int, - * BooleanValue)} may throw an UnsupportedOperationException when called with a - * member of trueIndices. - * - * @requires allIndices.containsAll(trueIndices) - * @return { m: BooleanMatrix | m.factory = this && m.dimensions = dims && - * m.elements = [0..d.capacity()-1] ->one FALSE ++ indices->TRUE } - * @throws IllegalArgumentException allIndices !in [0..d.capacity()) - * @throws IllegalArgumentException one of the input sets is not cloneable - * @throws NullPointerException d = null || allIndices = null || trueIndices = - * null - */ - public final BooleanMatrix matrix(Dimensions d, IntSet allIndices, IntSet trueIndices) { - assert allIndices.size() >= trueIndices.size(); // sanity check - validate(allIndices, d); - validate(trueIndices, d); - try { - return new BooleanMatrix(d, this, allIndices, trueIndices.clone()); - } catch (CloneNotSupportedException e) { - throw new IllegalArgumentException(); - } - - } - - /** - * BooleanFactory that produces TwosComplementInts. - * - * @invariant encoding = TwosComplement - * @author Emina Torlak - */ - private static final class TwosComplementFactory extends BooleanFactory { - - /** - * Constructs a boolean factory with the given number of input variables. Gates - * are checked for semantic equality down to the given depth. Integers are - * represented using the given number of bits. - * - * @requires 0 <= numVars < Integer.MAX_VALUE - * @requires checkToDepth >= 0 && bitwidth > 0 - * @ensures #this.components' = numInputVariables && this.components' in - * BooleanVariable - * @ensures this.bitwidth' = bitwidth - * @ensures this.comparisonDepth' = comparisonDepth - * @ensures this.intEncoding' = BINARY - */ - TwosComplementFactory(int numVars, int comparisonDepth, int bitwidth, OverflowPolicy ofPolicy) { - super(numVars, comparisonDepth, bitwidth, ofPolicy); - } - - /** - * Returns TWOSCOMPLEMENT. - * - * @return TWOSCOMPLEMENT - * @see kodkod.engine.bool.BooleanFactory#intEncoding() - */ - @Override - public IntEncoding intEncoding() { - return IntEncoding.TWOSCOMPLEMENT; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.BooleanFactory#integer(int) - */ - @Override - public Int integer(int number) { - return new TwosComplementInt(this, number, BooleanConstant.TRUE); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.BooleanFactory#integer(int, - * kodkod.engine.bool.BooleanValue) - */ - @Override - public Int integer(int number, BooleanValue bit) { - return new TwosComplementInt(this, number, bit); - } - - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanFormula.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanFormula.java deleted file mode 100644 index 83daab69b..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanFormula.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; -import java.util.Set; - -/** - * A non-constant boolean value with zero or more inputs. - * - * @specfield op: Operator - * @specfield size: int - * @specfield inputs: [0..size) -> one BooleanFormula - * @invariant size >= 0 - * @author Emina Torlak - */ -public abstract class BooleanFormula extends BooleanValue implements Iterable { - - private BooleanFormula negation; - - /** - * Constructs a boolean formula with the given negation. - */ - BooleanFormula(BooleanFormula negation) { - this.negation = negation; - } - - /** - * Returns an integer hash of this formula, used to compute the hash of the - * composition of this and some other formula with the given operator. - * - * @return an integer hash of this formula when acting as an input to a - * multigate with the given operator. - */ - abstract int hash(Operator op); - - /** - * Returns an integer k' such that 0 < |k'| < k and |k'| is the number of - * flattening steps that need to be taken to determine that this circuit has (or - * does not have) an input with the given label. A positive k' indicates that f - * is found to be an input to this circuit in k' steps. A negative k' indicates - * that f is not an input to this circuit, when it is flattened using at most k - * steps. - * - * @requires k > 0 - * @return the number of flattening steps that need to be taken to determine - * that f is (not) an input to this circuit - */ - int contains(Operator op, int f, int k) { - return f == label() ? 1 : -1; - } - - /** - * Flattens this circuit with respect to the given operator into the provided - * set. Specifically, the method modifies the set so that it contains the - * elements f_0, ..., f_k' where k' <= k elements and [[this]] = op(f_0, ..., - * f_k'). The default implementation simply adds this to the set. - * - * @requires k > 0 - * @ensures 1 <= k' <= k && some f_0,..., f_k' : flat.elts' | [[this]] = - * op([[f_0]], ..., [[f_k']]) - */ - void flatten(Operator op, Set flat, int k) { - assert k > 0; - flat.add(this); - } - - /** - * Returns the negation of this formula if it has already been computed. - * Otherwise, computes, caches and returns the negation of this formula. - * - * @return !this - * @see kodkod.engine.bool.BooleanValue#negation() - */ - @Override - final BooleanFormula negation() { - if (negation == null) { - negation = new NotGate(this); - } - return negation; - } - - /** - * Returns true if the negation of this formula has already been computed. - * - * @return true if the negation of this formula has already been computed. - */ - final boolean hasNegation() { - return negation != null; - } - - /** - * Passes this value and the given argument value to the visitor, and returns - * the resulting value. - * - * @return the value produced by the visitor when visiting this node with the - * given argument. - */ - public abstract T accept(BooleanVisitor visitor, A arg); - - /** - * Returns an iterator over the inputs to this gate. - * - * @return an iterator over this.inputs. - */ - @Override - public abstract Iterator iterator(); - - /** - * Returns the number of inputs to this gate. - * - * @return #this.inputs - */ - public abstract int size(); - - /** - * Returns the ith input to this gate. - * - * @return this.inputs[i] - * @requires 0 <= i < size - * @throws IndexOutOfBoundsException i < 0 || i >= #this.inputs - */ - public abstract BooleanFormula input(int i); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanMatrix.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanMatrix.java deleted file mode 100644 index 6e280d039..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanMatrix.java +++ /dev/null @@ -1,1175 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import static kodkod.engine.bool.BooleanConstant.FALSE; -import static kodkod.engine.bool.BooleanConstant.TRUE; -import static kodkod.engine.bool.Operator.AND; -import static kodkod.engine.bool.Operator.OR; - -import java.util.Iterator; - -import kodkod.engine.fol2sat.Environment; -import kodkod.util.collections.Containers; -import kodkod.util.ints.ArraySequence; -import kodkod.util.ints.HomogenousSequence; -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; -import kodkod.util.ints.RangeSequence; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - *

- * An n-dimensional matrix of {@link kodkod.engine.bool.BooleanValue boolean - * values}. Boolean matrices are indexed using flat integer indeces. For - * example, let m be a the 2 x 3 matrix of boolean variables identifed by labels - * [0 4 1; 5 10 2]. Then, m[0] = 0, m[3] = 5, m[5] = 2, etc. - *

- *

- * All values stored in the same matrix must be created by the same - * {@link kodkod.engine.bool.BooleanFactory circuit factory}. All methods that - * accept another BooleanMatrix as an input will throw an - * IllegalArgumentException if the values in the input matrix do not belong to - * the same factory as the values in the receiver matrix. - *

- *

- * Some instances can store only constant values, or can only store values at - * particular indices (see - * {@link kodkod.engine.bool.BooleanFactory#matrix(Dimensions, IntSet, IntSet)}). - * If this is the case, an attempt to call {@link #set(int, BooleanValue) } with - * invalid parameters will cause an IllegalArgumentException or an - * IndexOutOfBoundsException. - *

- * - * @specfield dimensions: Dimensions - * @specfield factory: BooleanFactory - * @specfield elements: [0..dimensions.capacity) -> one factory.components - * @author Emina Torlak - */ -public final class BooleanMatrix implements Iterable>, Cloneable { - - private IDefCond defCond = new DefCond(); - - private final Dimensions dims; - private final BooleanFactory factory; - private final SparseSequence cells; - - /** - * Constructs a new matrix with the given dimensions, factory, and entries. - * - * @requires dimensions != null && factory != null && seq != null - * @requires seq.indices() in [0..dimensions.capacity) - * @ensures this.dimensions' = dimensions && this.factory' = factory && - * this.elements' = [0..dimensions.capacity)->one FALSE - */ - private BooleanMatrix(Dimensions dimensions, BooleanFactory factory, SparseSequence seq) { - this.dims = dimensions; - this.factory = factory; - this.cells = seq; - } - - /** - * Constructs a new matrix with the given dimensions and factory, backed by a - * sparse sequence which can most efficiently hold the elements storable in the - * sparse sequences s0 and s1. - * - * @ensures this.dimensions' = dimensions && this.factory' = factory && - * this.elements' = [0..dimensions.capacity)->one FALSE - */ - private BooleanMatrix(Dimensions d, BooleanFactory f, SparseSequence s0, SparseSequence s1) { - this.dims = d; - this.factory = f; - final Class< ? > c0 = s0.getClass(), c1 = s1.getClass(); - if (c0 != c1 || c0 == RangeSequence.class) - this.cells = new RangeSequence(); - else if (c0 == HomogenousSequence.class) - this.cells = new HomogenousSequence(TRUE, Ints.bestSet(d.capacity())); - else - this.cells = new TreeSequence(); - } - - /** - * Constructs a new matrix with the given dimensions and factory, backed by a - * sparse sequence which can most efficiently hold the elements storable in the - * matrices m and rest. - * - * @requires null !in d + m + rest[int] - * @requires m.factory = rest[int].factory - * @requires d.equals(m.dims) => d.equals(rest[int].dims) - * @ensures this.dimensions' = dimensions && this.factory' = m.factory && - * this.elements' = [0..dimensions.capacity)->one FALSE - * @throws IllegalArgumentException m.factory != rest[int].factory - * @throws IllegalArgumentException !(d.equals(m.dims) => - * d.equals(rest[int].dims)) - */ - private BooleanMatrix(Dimensions d, BooleanMatrix m, BooleanMatrix... rest) { - this.dims = d; - this.factory = m.factory; - - final Class< ? > h = HomogenousSequence.class, t = TreeSequence.class; - final boolean sameDim = d.equals(m); - - Class< ? > c = m.cells.getClass(); - int cId = c == h ? 1 : c == t ? 2 : 4; - - for (BooleanMatrix other : rest) { - checkFactory(factory, other.factory); - if (sameDim) - checkDimensions(d, other.dims); - - c = other.cells.getClass(); - cId |= c == h ? 1 : c == t ? 2 : 4; - } - - switch (cId) { - case 1 : - this.cells = new HomogenousSequence(TRUE, Ints.bestSet(d.capacity())); - break; - case 2 : - this.cells = new TreeSequence(); - break; - default : - this.cells = new RangeSequence(); - } - - mergeDefConds(m); - mergeDefConds(rest); - } - - /** - * Constructs a new matrix with the given dimensions and factory. The - * constructed matrix can store any kind of BooleanValue. - * - * @requires dimensions != null && factory != null - * @ensures this.dimensions' = dimensions && this.factory' = factory && - * this.elements' = [0..dimensions.capacity)->one FALSE - */ - BooleanMatrix(Dimensions dims, BooleanFactory factory) { - this.dims = dims; - this.factory = factory; - this.cells = new RangeSequence(); - } - - /** - * Constructs a new matrix with the given dimensions and factory, and - * initializes the indices in the given set to TRUE. The constructed matrix will - * be capable of storing only constants iff trueIndeces.equals(allIndices). - * Otherwise, it will be able to store any kind of BooleanValue ONLY at the - * indices given by allIndices. Any attempt to call - * {@link #set(int, BooleanValue) } on an index outside of allIndices may result - * in an IndexOutOfBoundsException. - * - * @requires allIndices.containsAll(trueIndices) - * @requires trueIndices is not modifiable using an external handle - * @requires dimensions != null && factory != null && trueIndices != null && - * allIndices != null - * @requires dimensions.validate(allIndices.min()) && - * dimensions.validate(allIndices.max()) - * @ensures this.dimensions' = dimensions && this.factory' = factory && - * this.elements' = [0..dimensions.capacity)->one FALSE ++ trueIndices - * -> one TRUE - */ - BooleanMatrix(Dimensions dims, BooleanFactory factory, IntSet allIndices, IntSet trueIndices) { - this.dims = dims; - this.factory = factory; - final int tsize = trueIndices.size(), asize = allIndices.size(); - if (tsize == asize) - this.cells = new HomogenousSequence(TRUE, trueIndices); - else { - this.cells = tsize == 0 || asize / tsize >= 2 ? new ArraySequence(allIndices) : new RangeSequence(); - for (IntIterator iter = trueIndices.iterator(); iter.hasNext();) { - cells.put(iter.next(), TRUE); - } - } - } - - private void mergeDefConds(BooleanMatrix... bms) { - mergeDefConds(FALSE, bms); - } - - private void mergeDefConds(BooleanValue of, BooleanMatrix... bms) { - IDefCond[] dcs = new IDefCond[1 + bms.length]; - dcs[0] = this.defCond(); - for (int i = 0; i < bms.length; i++) { - dcs[i + 1] = bms[i].defCond(); - this.defCond().addVars(bms[i].defCond().vars()); - } - this.defCond().setOverflows(of, DefCond.merge(factory, dcs)); - } - - /** - * Returns the dimensions of this matrix. - * - * @return this.dimensions - */ - public final Dimensions dimensions() { - return dims; - } - - /** - * Returns the factory used to construct all the non-constant entries in this - * matrix. - * - * @return this.factory - */ - public final BooleanFactory factory() { - return factory; - } - - /** - * Returns this.defCond - * - * @return this.defCond - */ - public final IDefCond defCond() { - return defCond; - } - - public void setDefCond(IDefCond dc) { - this.defCond = dc; - } - - /** - * Returns the number of non-FALSE entries in this matrix. - * - * @return #this.elements.(BooleanValue - FALSE) - */ - public final int density() { - return cells.size(); - } - - /** - * Returns an IndexedEntry-based view of the non-FALSE entries in this matrix. - * The returned iterator enumerates indexed entries that represent the non-FALSE - * entries in the matrix, in the ascending order of indeces. For example, - * suppose that the elements of this are 0->FALSE, 1->(a & b), 2->FALSE, 3->(c | - * d). Then, the Iterator will return two IndexedEntries, c1 then c2, such that - * c1.index=1 && c1.value = a & b and c2.index=3 && c.value = c | d. Calling - * {@link Iterator#remove()} on the returned iterator has the same effect as - * setting the entry obtained through the last call to {@link Iterator#next()} - * to FALSE. - * - * @return an iterator over IndexedEntries representing the non-FALSE entries in - * this matrix. - */ - @Override - public final Iterator> iterator() { - return cells.iterator(); - } - - /** - * Returns the set of all indices in this matrix that contain non-FALSE values. - * - * @return the set of all indices in this matrix that contain non-FALSE values. - */ - public final IntSet denseIndices() { - return cells.indices(); - } - - /** - * Return FALSE if value is null; otherwise return value itself. - * - * @return FALSE if value is null; otherwise return value itself. - */ - private final BooleanValue maskNull(BooleanValue value) { - return value == null ? FALSE : value; - } - - /** - * Returns the value at the given index, without checking that the index is in - * bounds. - * - * @return this.elements[index] - */ - private final BooleanValue fastGet(final int index) { - return maskNull(cells.get(index)); - } - - /** - * Returns the element at the specified index. - * - * @return this.elements[index] - * @throws IndexOutOfBoundsException index < 0 || index >= - * this.dimensions.capacity - */ - public final BooleanValue get(final int index) { - if (!dims.validate(index)) - throw new IndexOutOfBoundsException(index + " is not a valid index."); - return maskNull(cells.get(index)); - } - - /** - * Returns a new matrix each of whose entries is a negation of the corresponding - * entry in this matrix. - * - * @return { m: BooleanMatrix | m.dimensions=this.dimensions && m.factory = - * this.factory && all i: [0..m.dimensions.capacity) | m.elements[i] = - * !this.elements[i] } - */ - public final BooleanMatrix not() { - final BooleanMatrix negation = new BooleanMatrix(dims, factory, cells, cells); - negation.mergeDefConds(this); - - for (int i = 0, max = dims.capacity(); i < max; i++) { - BooleanValue v = cells.get(i); - if (v == null) - negation.cells.put(i, TRUE); - else if (v != TRUE) - negation.cells.put(i, v.negation()); - } - - return negation; - } - - /** - * @throws IllegalArgumentException f != this.factory - */ - private static final void checkFactory(BooleanFactory f0, BooleanFactory f1) { - if (f0 != f1) - throw new IllegalArgumentException("Incompatible factories: " + f0 + " and " + f1); - } - - /** - * @throws IllegalArgumentException !d0.equals(d1) - */ - private static final void checkDimensions(Dimensions d0, Dimensions d1) { - if (!d0.equals(d1)) - throw new IllegalArgumentException("Incompatible dimensions: " + d0 + " and " + d1); - } - - /** - * Returns a new matrix such that an entry in the returned matrix represents a - * conjunction of the corresponding entries in this and other matrix. The effect - * of this method is the same as calling this.compose(ExprOperator.Binary.AND, - * other). - * - * @return { m: BooleanMatrix | m.dimensions = this.dimensions && m.factory = - * this.factory && all i: [0..m.dimensions.capacity) | m.elements[i] = - * this.elements[i] AND other.elements[i] } - * @throws NullPointerException other = null - * @throws IllegalArgumentException !other.dimensions.equals(this.dimensions) || - * this.factory != other.factory - */ - public final BooleanMatrix and(BooleanMatrix other) { - checkFactory(this.factory, other.factory); - checkDimensions(this.dims, other.dims); - - final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells); - ret.mergeDefConds(this, other); - - final SparseSequence s1 = other.cells; - if (cells.isEmpty() || s1.isEmpty()) - return ret; - for (IndexedEntry e0 : cells) { - BooleanValue v1 = s1.get(e0.index()); - if (v1 != null) - ret.fastSet(e0.index(), factory.and(e0.value(), v1)); - } - return ret; - } - - /** - * Returns a new matrix such that an entry in the returned matrix represents a - * conjunction of the corresponding entries in this and other matrices. - * - * @requires all i: [0..others.length) | others[i].dimensions = this.dimensions - * && others[i].factory = this.factory - * @return others.length = 0 => m else { m: BooleanMatrix | m.dimensions = - * this.dimensions && m.factory = this.factory && all i: - * [0..m.dimensions.capacity) | m.elements[i] = AND(this.elements[i], - * others[int].elements[i]) } - * @throws NullPointerException others = null - * @throws IllegalArgumentException some m: others[int] | - * !m.dimensions.equals(this.dimensions) || m.factory != - * this.factory - */ - public final BooleanMatrix and(final BooleanMatrix... others) { - final BooleanMatrix ret = new BooleanMatrix(dims, this, others); - - for (IndexedEntry cell : cells) { - final BooleanAccumulator acc = BooleanAccumulator.treeGate(AND, cell.value()); - for (BooleanMatrix other : others) { - if (acc.add(other.fastGet(cell.index())) == BooleanConstant.FALSE) - break; - } - if (!acc.isShortCircuited()) { - ret.fastSet(cell.index(), factory.accumulate(acc)); - } - } - return ret; - } - - /** - * Returns a new matrix such that an entry in the returned matrix represents a - * combination of the corresponding entries in this and other matrix. The effect - * of this method is the same as calling this.compose(ExprOperator.Binary.OR, - * other). - * - * @return { m: BooleanMatrix | m.dimensions = this.dimensions && m.factory = - * this.factory && all i: [0..m.dimensions.capacity) | m.elements[i] = - * this.elements[i] OR other.elements[i] } - * @throws NullPointerException other = null - * @throws IllegalArgumentException !other.dimensions.equals(this.dimensions) || - * this.factory != other.factory - */ - public final BooleanMatrix or(BooleanMatrix other) { - checkFactory(this.factory, other.factory); - checkDimensions(this.dims, other.dims); - if (this.cells.isEmpty()) - return other.clone(); - else if (other.cells.isEmpty()) - return this.clone(); - - final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells); - ret.mergeDefConds(this, other); - - final SparseSequence retSeq = ret.cells; - for (IndexedEntry e0 : cells) { - BooleanValue v1 = other.cells.get(e0.index()); - if (v1 == null) - retSeq.put(e0.index(), e0.value()); - else - retSeq.put(e0.index(), factory.or(e0.value(), v1)); - } - for (IndexedEntry e1 : other.cells) { - if (!cells.containsIndex(e1.index())) - retSeq.put(e1.index(), e1.value()); - } - return ret; - } - - /** - * Returns a new matrix such that an entry in the returned matrix represents a - * disjunction of the corresponding entries in this and other matrices. - * - * @requires all i: [0..others.length) | others[i].dimensions = this.dimensions - * && others[i].factory = this.factory - * @return others.length = 0 => m else { m: BooleanMatrix | m.dimensions = - * this.dimensions && m.factory = this.factory && all i: - * [0..m.dimensions.capacity) | m.elements[i] = OR(this.elements[i], - * others[int].elements[i]) } - * @throws NullPointerException others = null - * @throws IllegalArgumentException some m: others[int] | - * !m.dimensions.equals(this.dimensions) || m.factory != - * this.factory - */ - public final BooleanMatrix or(final BooleanMatrix... others) { - final BooleanMatrix ret = new BooleanMatrix(dims, this, others); - - for (IndexedEntry cell : cells) { - final BooleanAccumulator acc = BooleanAccumulator.treeGate(OR, cell.value()); - for (BooleanMatrix other : others) { - if (acc.add(other.fastGet(cell.index())) == BooleanConstant.TRUE) - break; - } - ret.fastSet(cell.index(), factory.accumulate(acc)); - } - - for (int i = 0, length = others.length; i < length; i++) { - for (IndexedEntry cell : others[i].cells) { - if (ret.cells.containsIndex(cell.index())) - continue; - final BooleanAccumulator acc = BooleanAccumulator.treeGate(OR, cell.value()); - for (int j = i + 1; j < length; j++) { - if (acc.add(others[j].fastGet(cell.index())) == BooleanConstant.TRUE) - break; - } - ret.fastSet(cell.index(), factory.accumulate(acc)); - } - } - - return ret; - } - - /** - * Returns the cross product of this and other matrix, using conjunction instead - * of multiplication. - * - * @return { m: BooleanMatrix | m = this x other } - * @throws NullPointerException other = null - * @throws IllegalArgumentException this.factory != other.factory - */ - public final BooleanMatrix cross(final BooleanMatrix other) { - checkFactory(this.factory, other.factory); - - final BooleanMatrix ret = new BooleanMatrix(dims.cross(other.dims), factory, cells, other.cells); - ret.mergeDefConds(this, other); - - if (cells.isEmpty() || other.cells.isEmpty()) - return ret; - - final int ocap = other.dims.capacity(); - for (IndexedEntry e0 : cells) { - int i = ocap * e0.index(); - for (IndexedEntry e1 : other.cells) { - BooleanValue conjunction = factory.and(e0.value(), e1.value()); - if (conjunction != FALSE) - ret.cells.put(i + e1.index(), conjunction); - } - } - - return ret; - } - - /** - * Updates the itrs and idxs arrays for the next step of the cross-product - * computation and returns a partial index based on the updated idxs values. - * - * @requires matrices.length = itrs.length = idxs.length - * @requires all m: matrices[int] | m.density() > 0 - * @requires currentIdx is a partial index based on the current value of idxs - * @ensures updates the itrs and idxs arrays for the next step cross-product - * computation - * @return a partial index based on the freshly updated idxs values. - */ - private static int nextCross(final BooleanMatrix[] matrices, final IntIterator[] itrs, final int[] idxs, int currentIdx) { - - int mult = 1; - for (int i = itrs.length - 1; i >= 0; i--) { - if (itrs[i].hasNext()) { - final int old = idxs[i]; - idxs[i] = itrs[i].next(); - return currentIdx - mult * old + mult * idxs[i]; - } else { - itrs[i] = matrices[i].cells.indices().iterator(); - final int old = idxs[i]; - idxs[i] = itrs[i].next(); - currentIdx = currentIdx - mult * old + mult * idxs[i]; - mult *= matrices[i].dims.capacity(); - } - } - - return -1; - } - - /** - * Initializes the itrs and idxs arrays for cross-product computation and - * returns a partial index based on the freshly computed idxs values. - * - * @requires matrices.length = itrs.length = idxs.length - * @requires all m: matrices[int] | m.density() > 0 - * @ensures initializes the itrs and idxs arrays for cross-product computation - * @return a partial index based on the freshly computed idxs values. - */ - private static int initCross(final BooleanMatrix[] matrices, final IntIterator[] itrs, final int[] idxs) { - int mult = 1, idx = 0; - for (int i = matrices.length - 1; i >= 0; i--) { - itrs[i] = matrices[i].cells.indices().iterator(); - idxs[i] = itrs[i].next(); - idx += mult * idxs[i]; - mult *= matrices[i].dims.capacity(); - } - return idx; - } - - /** - * Returns the cross product of this and other matrices, using conjunction - * instead of multiplication. - * - * @requires this.factory = others[int].factory - * @return others.length=0 => { m: BooleanMatrix | m.dimensions = - * this.dimensions && no m.elements } else { m: BooleanMatrix | m = this - * x others[0] x ... x others[others.length-1] } - * @throws NullPointerException others = null - * @throws IllegalArgumentException this.factory != others[int].factory - */ - public final BooleanMatrix cross(final BooleanMatrix... others) { - Dimensions retDims = dims; - boolean empty = cells.isEmpty(); - for (BooleanMatrix other : others) { - retDims = retDims.cross(other.dims); - empty = empty || other.cells.isEmpty(); - } - - final BooleanMatrix ret = new BooleanMatrix(retDims, this, others); - if (empty) - return ret; - - final IntIterator[] itrs = new IntIterator[others.length]; - final int[] otherIdxs = new int[others.length]; - - final int ocap = retDims.capacity() / dims.capacity(); - - for (IndexedEntry cell : cells) { - final int idx = ocap * cell.index(); - for (int restIdx = initCross(others, itrs, otherIdxs); restIdx >= 0; restIdx = nextCross(others, itrs, otherIdxs, restIdx)) { - final BooleanAccumulator acc = BooleanAccumulator.treeGate(AND, cell.value()); - for (int i = others.length - 1; i >= 0; i--) { - if (acc.add(others[i].fastGet(otherIdxs[i])) == BooleanConstant.FALSE) - break; - } - if (!acc.isShortCircuited()) { - ret.fastSet(idx + restIdx, factory.accumulate(acc)); - } - } - - } - - return ret; - } - - /** - * Sets the value at the specified index to the given value; returns the value - * previously at the specified position. It performs no index or null checking. - * - * @ensures this.elements'[index] = formula - */ - private final void fastSet(final int index, final BooleanValue formula) { - if (formula == FALSE) - cells.remove(index); - else - cells.put(index, formula); - } - - /** - * Returns the dot product of this and other matrix, using conjunction instead - * of multiplication and disjunction instead of addition. - * - * @return { m: BooleanMatrix | m = this*other } - * @throws NullPointerException other = null - * @throws IllegalArgumentException this.factory != other.factory - * @throws IllegalArgumentException dimensions incompatible for multiplication - */ - public final BooleanMatrix dot(final BooleanMatrix other) { - checkFactory(this.factory, other.factory); - - final BooleanMatrix ret = new BooleanMatrix(dims.dot(other.dims), factory, cells, other.cells); - ret.mergeDefConds(this, other); - - if (cells.isEmpty() || other.cells.isEmpty()) - return ret; - - final SparseSequence mutableCells = ret.clone().cells; - final int b = other.dims.dimension(0); - final int c = other.dims.capacity() / b; - - for (IndexedEntry e0 : cells) { - int i = e0.index(); - BooleanValue iVal = e0.value(); - int rowHead = (i % b) * c, rowTail = rowHead + c - 1; - for (Iterator> iter1 = other.cells.iterator(rowHead, rowTail); iter1.hasNext();) { - IndexedEntry e1 = iter1.next(); - BooleanValue retVal = factory.and(iVal, e1.value()); - if (retVal != FALSE) { - int k = (i / b) * c + e1.index() % c; - if (retVal == TRUE) - mutableCells.put(k, TRUE); - else { - BooleanValue kVal = mutableCells.get(k); - if (kVal != TRUE) { - if (kVal == null) { - kVal = BooleanAccumulator.treeGate(OR); - mutableCells.put(k, kVal); - } - ((BooleanAccumulator) kVal).add(retVal); - } - } - } - } - } - - // make mutable gates immutable - for (IndexedEntry e : mutableCells) { - if (e.value() != TRUE) { - ret.fastSet(e.index(), factory.accumulate((BooleanAccumulator) e.value())); - } else { - ret.fastSet(e.index(), TRUE); - } - } - - return ret; - } - - /** - * Returns a formula stating that the entries in this matrix are a subset of the - * entries in the given matrix; i.e. the value of every entry in this matrix - * implies the value of the corresponding entry in the given matrix. - * - * @return { f: BooleanValue | f <=> (this.elements[0]=>other.elements[0]) AND - * ... AND - * (this.elements[this.dimensions.capacity-1]=>other.elements[this.dimensions.capacity-1])) - * @throws NullPointerException other = null - * @throws IllegalArgumentException !other.dimensions.equals(this.dimensions) || - * this.factory != other.factory - */ - public final BooleanValue subset(BooleanMatrix other, Environment< ? , ? > env) { - checkFactory(this.factory, other.factory); - checkDimensions(this.dims, other.dims); - final BooleanAccumulator a = BooleanAccumulator.treeGate(AND); - for (IndexedEntry e0 : cells) { - if (a.add(factory.or(e0.value().negation(), other.fastGet(e0.index()))) == FALSE) - return FALSE; - } - BooleanValue val = factory.accumulate(a); - return DefCond.ensureDef(factory, env, val, this.defCond(), other.defCond()); - } - - /** - * Returns a formula stating that the entries in this matrix are equivalent to - * the entries in the given matrix; i.e. the value of every entry in this matrix - * is true if and only if the value of the corresponding entry in the given - * matrix is true. The same formula can be obtained by calling - * factory.and(this.subset(other), other.subset(this)), but this method performs - * the operation more efficiently. - * - * @return { f: BooleanValue | f <=> (this.elements[0]<=>other.elements[0]) AND - * ... AND - * (this.elements[this.dimensions.capacity-1]<=>other.elements[this.dimensions.capacity-1])) - * @throws NullPointerException other = null - * @throws IllegalArgumentException !other.dimensions.equals(this.dimensions) || - * this.factory != other.factory - */ - public final BooleanValue eq(BooleanMatrix other, Environment< ? , ? > env) { - BooleanValue val = factory.and(this.subset(other, env), other.subset(this, env)); - return DefCond.ensureDef(factory, env, val, this.defCond(), other.defCond()); - } - - /** - * Returns a matrix representing the asymmetric difference between the entries - * in this and the given matrix. The same matrix can be obtained by calling - * this.and(other.not()), but this method performs the operation more - * efficiently (intermediate values are not explicity created). - * - * @return { m: BooleanMatrix | m.dimensions = this.dimensions && m.factory = - * this.factory && all i: [0..m.dimensions.capacity) | m.elements[i] = - * this.elements[i] AND !other.elements[i] } - * @throws NullPointerException other = null - * @throws IllegalArgumentException !other.dimensions.equals(this.dimensions) || - * this.factory != other.factory - */ - public final BooleanMatrix difference(BooleanMatrix other) { - checkFactory(this.factory, other.factory); - checkDimensions(this.dims, other.dims); - - final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells); - ret.mergeDefConds(this, other); - - for (IndexedEntry e0 : cells) { - ret.fastSet(e0.index(), factory.and(e0.value(), other.fastGet(e0.index()).negation())); - } - - return ret; - } - - /** - * Returns the transitive closure of this matrix. - * - * @return { m: BooleanMatrix | m = ^this } - * @throws UnsupportedOperationException #this.diensions != 2 || - * !this.dimensions.square() - */ - public final BooleanMatrix closure() { - if (dims.numDimensions() != 2 || !dims.isSquare()) { - throw new UnsupportedOperationException("#this.diensions != 2 || !this.dimensions.square()"); - } - if (cells.isEmpty()) - return clone(); - - // System.out.println("closure of " + this); - BooleanMatrix ret = this; - - // compute the number of rows in the matrix - int rowNum = 0; - final int rowFactor = dims.dimension(1); - for (IndexedEntry rowLead = cells.first(); rowLead != null; rowLead = cells.ceil(((rowLead.index() / rowFactor) + 1) * rowFactor)) { - rowNum++; - } - - // compute closure using iterative squaring - for (int i = 1; i < rowNum; i *= 2) { - ret = ret.or(ret.dot(ret)); - } - // System.out.println(ret); - return ret == this ? clone() : ret; - } - - /** - * Returns the transpose of this matrix. - * - * @return { m: BooleanMatrix | m = ~this } - * @throws UnsupportedOperationException #this.dimensions != 2 - */ - public final BooleanMatrix transpose() { - final BooleanMatrix ret = new BooleanMatrix(dims.transpose(), factory, cells, cells); - ret.mergeDefConds(this); - - final int rows = dims.dimension(0), cols = dims.dimension(1); - for (IndexedEntry e0 : cells) { - ret.cells.put((e0.index() % cols) * rows + (e0.index() / cols), e0.value()); - } - return ret; - } - - /** - * Returns a boolean matrix m such that m = this if the given condition - * evaluates to TRUE and m = other otherwise. - * - * @return { m: BooleanMatrix | m.dimensions = this.dimensions && all i: - * [0..m.dimensions.capacity) | m.elements[i] = condition => - * this.elements[i], other.elements[i] } - * @throws NullPointerException other = null || condition = null - * @throws IllegalArgumentException !other.dimensions.equals(this.dimensions) || - * this.factory != other.factory - */ - public final BooleanMatrix choice(BooleanValue condition, BooleanMatrix other) { - checkFactory(this.factory, other.factory); - checkDimensions(this.dims, other.dims); - if (condition == TRUE) - return this.clone(); - else if (condition == FALSE) - return other.clone(); - - final BooleanMatrix ret = new BooleanMatrix(dims, factory); - final SparseSequence otherCells = other.cells; - for (IndexedEntry e0 : cells) { - BooleanValue v1 = otherCells.get(e0.index()); - if (v1 == null) - ret.fastSet(e0.index(), factory.and(condition, e0.value())); - else - ret.fastSet(e0.index(), factory.ite(condition, e0.value(), v1)); - } - for (IndexedEntry e1 : other.cells) { - if (!cells.containsIndex(e1.index())) - ret.fastSet(e1.index(), factory.and(condition.negation(), e1.value())); - } - - BooleanValue of = factory.ite(condition, defCond().getOverflow(), other.defCond().getOverflow()); - BooleanValue accumOF = factory.ite(condition, defCond().getAccumOverflow(), other.defCond().getAccumOverflow()); - ret.defCond().setOverflows(of, accumOF); - return ret; - } - - /** - * Returns a matrix m such that the relational value of m is equal to the - * relational value of this projected on the specified columns. - * - * @requires column[int] in this.dimensions.dimensions[int] - * @requires this.dimensions.isSquare() - * @return { m: BooleanMatrix | [[m]] = project([[this]], columns) } - * @throws IllegalArgumentExceptions columns.length < 1 || - * !this.dimensions.isSquare() - * @throws NullPointerException columns = null - */ - public final BooleanMatrix project(Int[] columns) { - if (!dims.isSquare()) - throw new IllegalArgumentException("!this.dimensions.isSquare()"); - - final int rdnum = columns.length; - - if (rdnum < 1) - throw new IllegalArgumentException("columns.length < 1"); - - final Dimensions rdims = Dimensions.square(dims.dimension(0), rdnum); - final BooleanMatrix ret = new BooleanMatrix(rdims, factory, cells, cells); - ret.mergeDefConds(this); - - final int tdnum = dims.numDimensions(); - final int[] tvector = new int[tdnum]; - final int[] ivector = new int[rdnum]; - final int[] rvector = new int[rdnum]; - - int nVarCols = 1; - - // detect constant columns to avoid unnecessary looping; - for (int i = 0; i < rdnum; i++) { - if (columns[i].isConstant()) { - int value = columns[i].value(); - if (value < 0 || value >= tdnum) { - return ret; - } else { // distinguish constants by making them negative - ivector[i] = -value; - } - } else { - nVarCols *= tdnum; - } - } - - PROJECT: for (int i = 0; i < nVarCols; i++) { - BooleanValue colVal = TRUE; - for (int j = 0; j < rdnum; j++) { - // if the jth column is non-constant, check that it can take on - // the value ivector[j] - if (ivector[j] >= 0) { - colVal = factory.and(colVal, columns[j].eq(factory.integer(ivector[j]))); - if (colVal == FALSE) - continue PROJECT; - } - } - for (IndexedEntry e : cells) { - dims.convert(e.index(), tvector); - for (int j = 0; j < rdnum; j++) { - rvector[j] = tvector[StrictMath.abs(ivector[j])]; - } - int rindex = rdims.convert(rvector); - ret.fastSet(rindex, factory.or(factory.and(e.value(), colVal), ret.fastGet(rindex))); - } - for (int j = rdnum - 1; j >= 0; j--) { // update ivector - // update ivector[j] only if the jth column is not constant - if (ivector[j] >= 0) { - if (ivector[j] + 1 == tdnum) { - ivector[j] = 0; - } else { - ivector[j] += 1; - break; - } - } - } - } - - return ret; - } - - /** - * Returns a conjunction of the negated values between start, inclusive, and - * end, exclusive. - * - * @requires 0 <= start < end <= this.dimensions.capacity() - * @return !this.elements[start] && !this.elements[start+1] && ... && - * !this.elements[end-1] - */ - private final BooleanValue nand(int start, int end) { - final BooleanAccumulator g = BooleanAccumulator.treeGate(AND); - for (Iterator> iter = cells.iterator(start, end - 1); iter.hasNext();) { - if (g.add(iter.next().value().negation()) == FALSE) - return FALSE; - } - return factory.accumulate(g); - } - - /** - * Overrides the values in this matrix with those in other. - * Specifically, for each index i of the returned matrix m, m.elements[i] is - * true iff other.elements[i] is true or this.elements[i] is true and all - * elements of other that are in the same row as i are false. - * - * @return {m: BooleanMatrix | m.dimensions = this.dimensions && all i: - * [0..m.capacity()) | m.elements[i] = other.elements[i] || - * this.elements[i] && !OR(other.elements[row(i)]) } where - * other.elements[row(i)] selects all elements of other - * that are in the same row as i. - * @throws NullPointerException other = null - * @throws IllegalArgumentException other.dimensions != this.dimensions - */ - public final BooleanMatrix override(BooleanMatrix other) { - checkFactory(this.factory, other.factory); - checkDimensions(this.dims, other.dims); - if (other.cells.isEmpty()) - return this.clone(); - - final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells, other.cells); - ret.mergeDefConds(this, other); - - ret.cells.putAll(other.cells); - final int rowLength = dims.capacity() / dims.dimension(0); - int row = -1; - BooleanValue rowVal = BooleanConstant.TRUE; - for (IndexedEntry e0 : cells) { - int e0row = e0.index() / rowLength; - if (row != e0row) { - row = e0row; - rowVal = other.nand(row * rowLength, (row + 1) * rowLength); - } - ret.fastSet(e0.index(), factory.or(ret.fastGet(e0.index()), factory.and(e0.value(), rowVal))); - } - return ret; - } - - /** - * Overrides the values in this matrix with those in other. - * - * @return others.length = 0 => { m: BooleanMatrix | m.dimensions = - * this.dimensions && m.elements = this.elements) else others.length = 1 - * => {m: BooleanMatrix | m.dimensions = this.dimensions && all i: - * [0..m.capacity()) | m.elements[i] = other.elements[i] || - * this.elements[i] && !OR(other.elements[rowOf(i)]) } else - * this.override(others[0).override(others[1..others.length)) - * @throws NullPointerException others = null - * @throws IllegalArgumentException others[int].factory != this.factory or - * others[int].dimensions != this.dimensions - */ - public final BooleanMatrix override(BooleanMatrix... others) { - if (others.length == 0) - return clone(); - final BooleanMatrix[] matrices = Containers.copy(others, 0, new BooleanMatrix[others.length + 1], 1, others.length); - matrices[0] = this; - for (int part = matrices.length; part > 1; part -= part / 2) { - final int max = part - 1; - for (int i = 0; i < max; i += 2) { - matrices[i / 2] = matrices[i].override(matrices[i + 1]); - } - if (max % 2 == 0) { // even max => odd number of entries - matrices[max / 2] = matrices[max]; - } - } - return matrices[0]; - } - - /** - * Returns an Int that represents the cardinality (number of non-FALSE entries) - * of this matrix using this.factory.intEncoding. - * - * @return {i: Int | [[i]] = sum({v: elements[int] | if [[v]] then 1 else 0}) } - */ - public final Int cardinality() { - final Int ret = factory.sum(cells.values()); - BooleanValue accum = DefCond.merge(factory, ret.defCond(), this.defCond()); - ret.defCond().setOverflows(ret.defCond().getOverflow(), accum); - return ret; - } - - /** - * Returns a BooleanValue that constrains at least one value in this.elements to - * be true. The effect of this method is the same as calling this.orFold(). - * - * @return { f: BooleanValue | f <=> this.elements[0] || ... || - * this.elements[this.dimensions.capacity-1] } - */ - public final BooleanValue some(Environment< ? , ? > env) { - final BooleanAccumulator g = BooleanAccumulator.treeGate(OR); - for (IndexedEntry e : cells) { - if (g.add(e.value()) == TRUE) - return TRUE; - } - final BooleanValue val = factory.accumulate(g); - return DefCond.ensureDef(factory, env, val, this.defCond()); - } - - /** - * Returns a BooleanValue that constrains at most one value in this.elements to - * be true. The effect of this method is the same as calling - * this.factory.or(this.one(), this.none()). - * - * @return { f: BooleanValue | f <=> this.one() || this.none() } - */ - public final BooleanValue lone(Environment< ? , ? > env) { - if (cells.isEmpty()) - return TRUE; - else { - final BooleanAccumulator g = BooleanAccumulator.treeGate(AND); - - BooleanValue partial = FALSE; - for (IndexedEntry e : cells) { - if (g.add(factory.or(e.value().negation(), partial.negation())) == FALSE) - return FALSE; - partial = factory.or(partial, e.value()); - } - - final BooleanValue val = factory.accumulate(g); - return DefCond.ensureDef(factory, env, val, this.defCond()); - } - } - - /** - * Returns a BooleanValue that constraints exactly one value in this.elements to - * be true. - * - * @return { f: BooleanValue | f <=> #this.elements[int] = 1 } - */ - public final BooleanValue one(Environment< ? , ? > env) { - if (cells.isEmpty()) - return FALSE; - else { - final BooleanAccumulator g = BooleanAccumulator.treeGate(AND); - - BooleanValue partial = FALSE; - for (IndexedEntry e : cells) { - if (g.add(factory.or(e.value().negation(), partial.negation())) == FALSE) - return FALSE; - partial = factory.or(partial, e.value()); - } - g.add(partial); - - final BooleanValue val = factory.accumulate(g); - return DefCond.ensureDef(factory, env, val, this.defCond()); - } - } - - /** - * Returns a BooleanValue that constraints all values in this.elements to be - * false. The effect of this method is the same as calling - * this.factory.not(this.some()). - * - * @return { f: BooleanValue | f <=> !(this.elements[0] || ... || - * !this.elements[this.dimensions.capacity-1]) } - */ - public final BooleanValue none(Environment< ? , ? > env) { - env.negate(); - BooleanValue val = some(env).negation(); - env.negate(); - return val; - } - - /** - * Sets the specified index to the given value. - * - * @requires value in this.factory.components - * @ensures this.elements'[index] = value - * @throws NullPointerException value = null - * @throws IllegalArgumentException the given is a formula, and this matrix - * accepts only constants - * @throws IndexOutOfBoundsException the given index does not belong to the set - * of indices at which this matrix can store non-FALSE values. - */ - public final void set(final int index, final BooleanValue value) { - if (!dims.validate(index)) - throw new IndexOutOfBoundsException("index < 0 || index >= this.dimensions.capacity"); - if (value == null) - throw new NullPointerException("formula=null"); - if (value == FALSE) - cells.remove(index); - else - cells.put(index, value); - } - - /** - * Returns a copy of this boolean matrix. - * - * @return {m: BooleanMatrix - this | m.dimensions = this.dimensions && - * m.elements = copy of this.elements } - */ - @Override - public BooleanMatrix clone() { - try { - final BooleanMatrix ret = new BooleanMatrix(dims, factory, cells.clone()); - ret.mergeDefConds(this); - return ret; - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code. - } - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder buff = new StringBuilder("dimensions: "); - buff.append(dims); - buff.append(", elements: "); - buff.append(cells); - return buff.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanValue.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanValue.java deleted file mode 100644 index 3ed525492..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanValue.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -/** - * Represents a boolean value, which may be a - * {@link kodkod.engine.bool.BooleanFormula formula} or a - * {@link kodkod.engine.bool.BooleanConstant constant}. Boolean formulas are - * produced by {@link kodkod.engine.bool.BooleanFactory circuit factories}. Each - * value is associated with an integer label; the labels are unique within a - * given factory. A boolean value with a negative label -|l| represents the - * negation of the value with the positive label |l|. Non-constant values are - * not shared among factories. - * - * @specfield op: Operator - * @specfield label: [-Integer.MAX_VALUE, Integer.MAX_VALUE] - * @invariant no c: BooleanValue - this | some components.c & components.this && - * c.label = this.label - * @author Emina Torlak - */ -public abstract class BooleanValue implements Comparable { - - BooleanValue() {} - - /** - * Returns the negation of this boolean value - * - * @return { f: BooleanFormula | [[f]] = ![[this]] } - */ - abstract BooleanValue negation(); - - /** - * Returns the label for this value. - * - * @return this.label - */ - public abstract int label(); - - /** - * Returns the operator representing the function computed by this gate. - * - * @return this.op - */ - public abstract Operator op(); - - /** - * Boolean components are ordered according to their labels. Note that the - * ordering is well defined on components produced by the same factory. - * Specifically, this comparison function is consistent with equals for the - * components produced by the same factory, but may not be for the components - * produced by different factories. - * - * @return 0 if the label of this and other are the same, a negative integer if - * the label of this is smaller than the label of other; and a positive - * integer otherwise. - */ - @Override - public final int compareTo(BooleanValue other) { - return label() - other.label(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanVariable.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanVariable.java deleted file mode 100644 index 124232334..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanVariable.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; - -import kodkod.util.collections.Containers; -import kodkod.util.ints.Ints; - -/** - * Represents a boolean variable. - * - * @invariant op = Operator.VAR - * @invariant no inputs && label in [1, ..., Integer.MAX_VALUE) - * @author Emina Torlak - */ -public final class BooleanVariable extends BooleanFormula { - - final int label; - private final int hashcode; - - /** - * Constructs a new BooleanVariable with the given label. - * - * @requires label != 0 - * @ensures this.label' = label - */ - BooleanVariable(int label) { - super(null); - assert label != 0; - this.label = label; - this.hashcode = Ints.superFastHash(label); - } - - /** - * Returns a hash of this variable's label. - * - * @return Ints.superFastHash(this.label) - */ - @Override - int hash(Operator op) { - return hashcode; - } - - /** - * Returns the label for this value. - * - * @return this.label - */ - @Override - public int label() { - return label; - } - - /** - * Returns a string representation of this variable. - * - * @return a string representation of this variable. - */ - @Override - public String toString() { - return Integer.toString(label); - } - - /** - * Passes this value and the given argument value to the visitor, and returns - * the resulting value. - * - * @return the value produced by the visitor when visiting this node with the - * given argument. - */ - @Override - public T accept(BooleanVisitor visitor, A arg) { - return visitor.visit(this, arg); - } - - /** - * Returns the VAR operator. - * - * @return Operator.VAR - */ - @Override - public Operator op() { - return Operator.VAR; - } - - /** - * Returns an empty iterator. - * - * @return an empty iterator - */ - @Override - public Iterator iterator() { - return Containers.emptyIterator(); - } - - /** - * Returns 0. - * - * @return 0 - */ - @Override - public int size() { - return 0; - } - - /** - * Throws an IndexOutOfBoundsException. - * - * @throws IndexOutOfBoundsException - */ - @Override - public BooleanFormula input(int i) { - throw new IndexOutOfBoundsException(); - } - - /** - * Returns a hashcode for this variable. - * - * @return a hashcode for this variable. - */ - @Override - public int hashCode() { - return hashcode; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanVisitor.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanVisitor.java deleted file mode 100644 index 4c849004f..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/BooleanVisitor.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -/** - * Visits {@link kodkod.engine.bool.BooleanFormula boolean formulas}. In - * addition to passing themselves as the argument to the visitor, the boolean - * values also pass along satelite information of type A. - * - * @author Emina Torlak - */ -public interface BooleanVisitor { - - /** - * Visits the multigate and returns the result. - * - * @return the result of visiting the given multigate - */ - public T visit(MultiGate multigate, A arg); - - /** - * Visits the if-then-else gate and returns the result. - * - * @return the result of visiting the given ITEGate - */ - public T visit(ITEGate ite, A arg); - - /** - * Visits the inverter and returns the result. - * - * @return the result of visiting the given inverter - */ - public T visit(NotGate negation, A arg); - - /** - * Visits the variable and returns the result. - * - * @return the result of visiting the given variable - */ - public T visit(BooleanVariable variable, A arg); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/CBCFactory.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/CBCFactory.java deleted file mode 100644 index 316f1ec83..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/CBCFactory.java +++ /dev/null @@ -1,807 +0,0 @@ - -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package kodkod.engine.bool; - -import static kodkod.engine.bool.BooleanConstant.FALSE; -import static kodkod.engine.bool.BooleanConstant.TRUE; -import static kodkod.engine.bool.Operator.AND; -import static kodkod.engine.bool.Operator.CONST; -import static kodkod.engine.bool.Operator.ITE; -import static kodkod.engine.bool.Operator.NOT; -import static kodkod.engine.bool.Operator.OR; -import static kodkod.engine.bool.Operator.VAR; - -import java.util.Iterator; -import java.util.Set; - -import kodkod.ast.operator.ExprOperator; -import kodkod.engine.bool.Operator.Nary; -import kodkod.util.collections.CacheSet; -import kodkod.util.collections.IdentityHashSet; - -/** - * A factory for creating variables, multigates, and if-then-else gates. - * - * @specfield values: set (BooleanVariable + MultiGate + ITEGate) - * @specfield cmpMax: int // the maximum number of comparisons made when - * comparing circuits for equality - * @invariant no disj factory, factory' : CircuitFactory | some factory.values & - * factory'.values - * @author Emina Torlak - */ -final class CBCFactory { - - /** - * Sets used as `scrap paper' for gate comparisons. Its capacity is 2^(depth), - * where depth is the depth to which gates should be checked for equality. - */ - private final Set scrap0, scrap1; - /** - * Caches variables. This representation is optimized for infrequent addition of - * ranges of variables at a time (as opposed to frequent addition of one - * variable at a time). - * - * @invariant all i: [0..vars.length-1], j: [1..vars[i].length-1] | - * vars[i][j-1].label = vars[i][j] + 1 - * @invariant all i: [1..vars.length-1] | vars[i][0] > - * vars[i-1][vars[i-1].length-1] + 1 - * @invariant vars[0][0].label = 1 - */ - private BooleanVariable[][] vars; - /** - * Caches AND, OR, and ITE gates. - * - * @invariant all i: [0..2] | c[i].op.ordinal = i - */ - private final CacheSet[] cache; - private int label, cmpMax; - - /** - * Constructs a CircuitFactory using the given max comparison parameter, - * initialized to contain the given number of variables. - * - * @requires cmpMax > 0 && numVars >= 0 - * @ensures #this.values' = numVars && this.values in BooleanVariable - * @ensures this.cmpMax' = cmpMax - */ - @SuppressWarnings("unchecked" ) - CBCFactory(int numVars, int cmpMax) { - assert cmpMax > 0 && numVars >= 0; - this.cmpMax = cmpMax; - this.label = numVars + 1; - if (numVars == 0) { - vars = new BooleanVariable[0][]; - } else { - vars = new BooleanVariable[1][numVars]; - for (int i = 0; i < numVars; i++) { - vars[0][i] = new BooleanVariable(i + 1); - } - } - scrap0 = new IdentityHashSet(cmpMax); - scrap1 = new IdentityHashSet(cmpMax); - cache = new CacheSet[] { - new CacheSet(), new CacheSet(), new CacheSet() - }; - } - - /** - * Returns the cache for gates with the given operator. - * - * @requires op in AND + OR + ITE - * @return cache[op.ordinal] - */ - private CacheSet opCache(Operator op) { - return cache[op.ordinal]; - } - - /** - * Sets this.cmpMax to the given value. - * - * @requires cmpMax > 0 - * @ensures this.cmpMax' = cmpMax - */ - void setCmpMax(int cmpMax) { - assert cmpMax > 0; - this.cmpMax = cmpMax; - } - - /** - * Returns this.cmpMax. - * - * @return this.cmpMax - */ - int cmpMax() { - return cmpMax; - } - - /** - * Returns true if the given value is a valid argument to one of the - * assemble methods. Otherwise returns false. - * - * @return v in this.values + this.values.negation + BooleanConstant - */ - boolean canAssemble(BooleanValue v) { - if (v.op() == CONST) - return true; - if (v.label() < 0) - v = v.negation(); - if (v instanceof BooleanVariable) { - return v == variable(v.label()); - } else { - final BooleanFormula g = (BooleanFormula) v; - for (Iterator gates = opCache(g.op()).get(g.hashCode()); gates.hasNext();) { - if (g == gates.next()) - return true; - } - return false; - } - } - - /** - * Returns the maximum label of a {@link BooleanVariable variable} in - * {@code this.components}. - * - * @return max((this.values & BooleanVariable).label) - */ - int maxVariable() { - if (vars.length == 0) - return 0; - final BooleanVariable[] last = vars[vars.length - 1]; - return last[last.length - 1].label; - } - - /** - * Returns the maximum label of a {@link BooleanFormula formula} in - * {@code this.components}. Note that {@link #maxFormula()} >= - * {@link #maxVariable()} since variables themselves are formulas. - * - * @return max((this.values & BooleanFormula).label) - */ - int maxFormula() { - return label - 1; - } - - /** - * Returns the boolean variable from this.values with the given label. - * - * @requires label in (this.values & BooleanVariable).label - * @return (this.values & BooleanVariable).label - */ - BooleanVariable variable(int label) { - int high = vars.length - 1; - if (high == 0) - return vars[0][label - 1]; - int low = 0; - while (low <= high) { - final int mid = (low + high) >>> 1; - final BooleanVariable[] midVars = vars[mid]; - final int midKeyLow = midVars[0].label, midKeyHigh = midKeyLow + midVars.length - 1; - if (midKeyHigh < label) { - low = mid + 1; - } else if (midKeyLow > label) { - high = mid - 1; - } else { // variable range found - return midVars[label - midKeyLow]; - } - } - throw new IllegalArgumentException("Expected a variable label, given label = " + label); - } - - /** - * Adds the specified number of fresh variables to {@code this.values}. - * - * @requires numVars > 0 - * @ensures let diff = this.values' - this.values | diff in BooleanVariable && - * #diff = numVars && diff.label = { i: int | this.maxFormula() < i <= - * this.maxFormula() + numVars } - */ - void addVariables(int numVars) { - assert numVars > 0; - if (label > 1 && maxVariable() == maxFormula()) { - final BooleanVariable[] last = vars[vars.length - 1]; - final BooleanVariable[] newLast = new BooleanVariable[last.length + numVars]; - System.arraycopy(last, 0, newLast, 0, last.length); - for (int i = last.length, varLabel = this.label; i < newLast.length; i++, varLabel++) - newLast[i] = new BooleanVariable(varLabel); - vars[vars.length - 1] = newLast; - } else { - final BooleanVariable[][] newVars = new BooleanVariable[vars.length + 1][]; - System.arraycopy(vars, 0, newVars, 0, vars.length); - final BooleanVariable[] newLast = new BooleanVariable[numVars]; - for (int i = 0, varLabel = this.label; i < numVars; i++, varLabel++) - newLast[i] = new BooleanVariable(varLabel); - newVars[vars.length] = newLast; - vars = newVars; - } - this.label += numVars; - } - - /** - * Returns a boolean value whose meaning is (if [[i]] then [[t]] else [[e]]). - * - * @requires i + t + e in (this.values + this.values.negation + BooleanConstant) - * @return v: BooleanValue | [[v]] = if [[i]] then [[t]] else [[e]] - * @ensures v in BooleanFormula - NotGate => this.values' = this.values + v, - * this.values' = this.values - * @throws NullPointerException any of the arguments are null - */ - BooleanValue assemble(BooleanValue i, BooleanValue t, BooleanValue e) { - if (i == TRUE || t == e) - return t; - else if (i == FALSE) - return e; - else if (t == TRUE || i == t) - return assemble(OR, i, e); - else if (t == FALSE || i.label() == -t.label()) - return assemble(AND, i.negation(), e); - else if (e == TRUE || i.label() == -e.label()) - return assemble(OR, i.negation(), t); - else if (e == FALSE || i == e) - return assemble(AND, i, t); - else { - final BooleanFormula f0 = (BooleanFormula) i, f1 = (BooleanFormula) t, f2 = (BooleanFormula) e; - final int hash = ITE.hash(f0, f1, f2); - - for (Iterator gates = opCache(ITE).get(hash); gates.hasNext();) { - BooleanFormula gate = gates.next(); - if (gate.input(0) == i && gate.input(1) == t && gate.input(2) == e) - return gate; - } - final BooleanFormula ret = new ITEGate(label++, hash, f0, f1, f2); - opCache(ITE).add(ret); - return ret; - } - } - - /** - * Returns a boolean value whose meaning is ([[v0]] op [[v1]]). - * - * @requires v0 + v1 in (this.values + this.values.negation + BooleanConstant) - * @return v: BooleanValue | [[v]] = [[v0]] op [[v1]] - * @ensures v in BooleanFormula - NotGate => this.values' = this.values + v, - * this.values' = this.values - * @throws NullPointerException any of the arguments are null - */ - BooleanValue assemble(Operator.Nary op, BooleanValue v0, BooleanValue v1) { - final BooleanValue l, h; - if (v0.op().ordinal < v1.op().ordinal) { - l = v0; - h = v1; - } else { - l = v1; - h = v0; - } - if (h.op() == CONST) - return h == op.identity() ? l : h; - else - return assembler(l.op(), h.op()).assemble(op, (BooleanFormula) l, (BooleanFormula) h); - } - - /** - * Returns a boolean value with the same meaning as the given accumulator. - * - * @requires acc.components in (this.values + this.values.negation + - * BooleanConstant) - * @return v: BooleanValue | [[v]] = [[acc]] - * @ensures v in BooleanFormula - NotGate => this.values' = this.values + v, - * this.values' = this.values - * @throws NullPointerException any of the arguments are null - */ - @SuppressWarnings("unchecked" ) - BooleanValue assemble(BooleanAccumulator acc) { - final int asize = acc.size(); - final Operator.Nary op = acc.op; - switch (asize) { - case 0 : - return op.identity(); - case 1 : - return acc.iterator().next(); - case 2 : - final Iterator inputs = acc.iterator(); - return assemble(op, inputs.next(), inputs.next()); - default : - @SuppressWarnings("rawtypes" ) - final int hash = op.hash((Iterator) acc.iterator()); - if (asize > cmpMax) { - for (Iterator gates = opCache(op).get(hash); gates.hasNext();) { - BooleanFormula g = gates.next(); - if (g.size() == asize && ((NaryGate) g).sameInputs(acc.iterator())) { - return g; - } - } - } else { - LOOKUP: for (Iterator gates = opCache(op).get(hash); gates.hasNext();) { - BooleanFormula g = gates.next(); - if (g.size() == asize && ((NaryGate) g).sameInputs(acc.iterator())) { - return g; - } else if (g.size() < asize) { - scrap0.clear(); - g.flatten(op, scrap0, cmpMax); - if (scrap0.size() == asize) { - for (BooleanValue v : acc) { - if (!scrap0.contains(v)) - continue LOOKUP; - } - return g; - } - } - } - } - final BooleanFormula ret = new NaryGate(acc, label++, hash); - opCache(acc.op).add(ret); - return ret; - } - } - - /** - * Given two operators, op0 and op1, returns an Assembler which contains the - * creator method for expressions of the form v0 op v1 where op in - * ExprOperator.Nary and v0.op = op0 and v1.op = op1. - * - * @requires op0 <= op1 && no (op0 + op1) & CONST - * @requires op0 != null && op1 != null - * @return a Assembler which contains the creator method for expressions of the - * form v0 op v1 where op in ExprOperator.Nary and v0.op = op0 and v1.op - * = op1. - */ - private Assembler assembler(Operator op0, Operator op1) { - return ASSEMBLERS[(op0.ordinal << 2) + op1.ordinal - ((op0.ordinal * (op0.ordinal - 1) >> 1))]; - } - - /** - * Returns a BooleanFormula f such that [[f]] = f0 op f1. The method requires - * that the formulas f0 and f1 be already reduced with respect to op. A new - * formula is created and cached iff the circuit with the meaning [[f0]] op - * [[f1]] has not already been created. - * - * @requires f0 and f1 have already been reduced with respect to op; i.e. f0 op - * f1 cannot be reduced to a constant or a simple circuit by applying - * absorption, idempotence, etc. laws to f0 and f1. - * @return f : BooleanFormula | [[f]] = [[f0]] op [[f1]] - * @ensures f !in this.values => this.values' = this.values + f, this.values' = - * this.values - */ - private BooleanFormula cache(Operator.Nary op, BooleanFormula f0, BooleanFormula f1) { - final BooleanFormula l, h; - if (f0.label() < f1.label()) { - l = f0; - h = f1; - } else { - l = f1; - h = f0; - } - final int hash = op.hash(l, h); - if (l.op() == op || h.op() == op) { - scrap0.clear(); - l.flatten(op, scrap0, cmpMax - 1); - h.flatten(op, scrap0, cmpMax - scrap0.size()); - for (Iterator gates = opCache(op).get(hash); gates.hasNext();) { - BooleanFormula gate = gates.next(); - if (gate.size() == 2 && gate.input(0) == l && gate.input(1) == h) - return gate; - else { - scrap1.clear(); - gate.flatten(op, scrap1, cmpMax); - if (scrap0.equals(scrap1)) - return gate; - } - } - } else { - for (Iterator gates = opCache(op).get(hash); gates.hasNext();) { - BooleanFormula gate = gates.next(); - if (gate.size() == 2 && gate.input(0) == l && gate.input(1) == h) - return gate; - } - } - final BooleanFormula ret = new BinaryGate(op, label++, hash, l, h); - opCache(op).add(ret); - return ret; - } - - /** - * Wrapper for a method that generates boolean values out of existing gates, - * using AND and OR operators. - * - * @author Emina Torlak - */ - private static abstract class Assembler { - - /** - * Returns a BooleanValue whose meaning is [[f0]] op [[f1]]. A new circuit is - * created and cached iff [[f0]] op [[f1]] cannot be reduced to a simpler value - * and a circuit with equivalent meaning has not already been created. - * - * @requires f0.op <= f1.op && f0 + f1 in CircuitFactory.this.values + - * CircuitFactory.this.values.negation - * @return { v: BooleanValue | [[v]] = [[f0]] op [[f1]] } - * @ensures (no v: CircuitFactory.this.values | [[v]] = [[f0]] op [[f1]]) => - * CircuitFactory.this.values' = CircuitFactory.this.values + {v: - * BooleanValue | [[v]] = [[f0]] op [[f1]]} => - * CircuitFactory.this.values' = CircuitFactory.this.values - */ - abstract BooleanValue assemble(Operator.Nary op, BooleanFormula f0, BooleanFormula f1); - } - - /** - * Performs common simplifications on circuits of the form AND op X or OR op X, - * where X can be any operator other than CONST (J stands for 'junction'). - */ - private final Assembler JoX = new Assembler() { - - /** - * Performs the following reductions, if possible. Note that these reductions - * will be possible only if f0 was created after f1 (i.e. |f0.label| > - * |f1.label|). (a & b) & a = a & b (a & b) & !a = F (a & b) | a = a (a | b) | a - * = a | b (a | b) | !a = T (a | b) & a = a - * - * @requires f0.op in (AND + OR) - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op().ordinal < 2; - final int label = f1.label(); - if (f0.contains(f0.op(), label, cmpMax) > 0) - return op == f0.op() ? f0 : f1; - else if (op == f0.op() && f0.contains(op, -label, cmpMax) > 0) - return op.shortCircuit(); - else - return cache(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form AND op OR. - */ - private final Assembler AoO = new Assembler() { - - /** - * Performs the following reductions, if possible, along with JoX reductions. - * (aj & ... & ak) & (a1 | ... | an) = (aj & ... & ak) where 1 <= j <= k <= n - * (a1 & ... & an) | (aj | ... | ak) = (aj | ... | ak) where 1 <= j <= k <= n - * - * @requires f0.op = AND && f1.op = OR - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == AND && f1.op() == OR; - scrap0.clear(); - scrap1.clear(); - f0.flatten(f0.op(), scrap0, cmpMax); - f1.flatten(f1.op(), scrap1, cmpMax); - for (BooleanFormula formula : scrap1) { - if (scrap0.contains(formula)) - return op == AND ? f0 : f1; - } - return (f0.label() < f1.label()) ? JoX.assemble(op, f1, f0) : JoX.assemble(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form AND op AND or OR op - * OR. - */ - private final Assembler JoJ = new Assembler() { - - /** - * Performs the following reductions, if possible, along with the JoX - * reductions. (a1 & ... & an) & (aj & ... & ak) = (a1 & ... & an) where 1 <= j - * <= k <= n (a1 & ... & an) | (aj & ... & ak) = (aj & ... & ak) where 1 <= j <= - * k <= n (a1 | ... | an) | (aj | ... | ak) = (a1 | ... | an) where 1 <= j <= k - * <= n (a1 | ... | an) & (aj | ... | ak) = (aj | ... | ak) where 1 <= j <= k <= - * n - * - * @requires f0.op = f1.op && (f0+f1).op in (AND + OR) - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == f1.op(); - if (f0 == f1) - return f0; - final Operator fop = f0.op(); - scrap0.clear(); - scrap1.clear(); - f0.flatten(fop, scrap0, cmpMax); - f1.flatten(fop, scrap1, cmpMax); - if (scrap0.size() < scrap1.size() && scrap1.containsAll(scrap0)) - return op == fop ? f1 : f0; - else if (scrap0.size() >= scrap1.size() && scrap0.containsAll(scrap1)) - return op == fop ? f0 : f1; - else if (f0.label() < f1.label()) - return JoX.assemble(op, f1, f0); - else - return JoX.assemble(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form AND op ITE or OR op - * ITE. - */ - private final Assembler JoI = new Assembler() { - - /** - * Combines JoX and IoX reductions. - * - * @requires f0.op in (AND + OR) && f1.op = ITE - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op().ordinal < 2 && f1.op() == ITE; - if (f0.label() < f1.label()) // f0 - // created - // before - // f1 - return cache(op, f1, f0); - else - return JoX.assemble(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form AND op NOT or OR op - * NOT. - */ - private final Assembler JoN = new Assembler() { - - /** - * Performs the following reductions, if possible, along with the JoX/NoX - * reductions. a & !a = F a | !a = T - * - * @requires f0.op in (AND + OR) && f1.op = NOT - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op().ordinal < 2 && f1.op() == NOT; - if (f0.label() == -f1.label()) - return op.shortCircuit(); - else if (f0.label() < StrictMath.abs(f1.label())) // f0 - // created - // before - // f1 - return NoX.assemble(op, f1, f0); - else - return JoX.assemble(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form ITE op VAR. - */ - private final Assembler IoV = new Assembler() { - - /** - * Returns cache(op, f0, f1) - * - * @requires f0.op = ITE && f1.op = VAR - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == ITE && f1.op() == VAR; - return cache(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form ITE op NOT. - */ - private final Assembler IoN = new Assembler() { - - /** - * Performs the following reductions, if possible, along with IoX/NoX - * reductions. (a ? b : c) & !(a ? b : c) = F (a ? b : c) | !(a ? b : c) = T - * - * @requires f0.op = ITE && f1.op = NOT - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == ITE && f1.op() == NOT; - if (f0.label() == -f1.label()) - return op.shortCircuit(); - else if (f0.label() < StrictMath.abs(f1.label())) // f0 - // created - // before - // f1 - return NoX.assemble(op, f1, f0); - else - return cache(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form NOT op X, where X can - * be any operator other than CONST. - */ - private final Assembler NoX = new Assembler() { - - /** - * Performs the following reductions, if possible. Note that these reductions - * will be possible only if f0 was created after f1 (i.e. |f0.label| > - * |f1.label|). !(a | b) & a = F !(a | b) & !a = !(a | b) !(a & b) | a = T !(a & - * b) | !a = !(a & b) - * - * @requires f0.op = NOT - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == NOT; - final int label = f1.label(); - if (f0.input(0).contains(op.complement(), label, cmpMax) > 0) - return op.shortCircuit(); - else if (f0.input(0).contains(op.complement(), -label, cmpMax) > 0) - return f0; - else - return cache(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form NOT op NOT. - */ - private final Assembler NoN = new Assembler() { - - /** - * Performs the following reductions, if possible, along with NoX reductions. !a - * & !a = !a !a | !a = !a - * - * @requires f1.op + f0.op = NOT - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == NOT && f1.op() == NOT; - if (f0 == f1) - return f0; - else if (f0.label() < f1.label()) // f0 - // created - // after - // f1 - return NoX.assemble(op, f0, f1); - else - return NoX.assemble(op, f1, f0); - } - }; - - /** - * Performs common simplifications on circuits of the form NOT op VAR. - */ - private final Assembler NoV = new Assembler() { - - /** - * Performs the following reductions, if possible, along with NoX reductions. !a - * & a = F !a | a = T - * - * @requires f1.op = NOT && f1.op = VAR - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == NOT && f1.op() == VAR; - if (f0.label() == -f1.label()) - return op.shortCircuit(); - else - return NoX.assemble(op, f0, f1); - } - }; - - /** - * Performs common simplifications on circuits of the form X op X. - */ - private final Assembler XoX = new Assembler() { - - /** - * Performs the following reductions, if possible. a & a = a a | a = a - * - * @requires f0.op = f1.op - */ - @Override - BooleanValue assemble(Nary op, BooleanFormula f0, BooleanFormula f1) { - assert f0.op() == f1.op(); - return (f0 == f1) ? f0 : cache(op, f0, f1); - } - }; - - /** - * 15 Assembler entires representing all possible composition combinations of - * non-constant vertices using the operators AND and OR. Note that there are 15 - * of them rather than 25 because of the v0.op <= v1.op requirement of the - * {@link Assembler#assemble(ExprOperator.Nary, BooleanFormula, BooleanFormula)} - * method. - */ - private final Assembler[] ASSEMBLERS = { - JoJ, /* - * AND - * op - * AND - */ - AoO, /* - * AND - * op - * OR - */ - JoI, /* - * AND - * op - * ITE - */ - JoN, /* - * AND - * op - * NOT - */ - JoX, /* - * AND - * op - * VAR - */ - JoJ, /* - * OR - * op - * OR - */ - JoI, /* - * OR - * op - * ITE - */ - JoN, /* - * OR - * op - * NOT - */ - JoX, /* - * OR - * op - * VAR - */ - XoX, /* - * ITE - * op - * ITE - */ - IoN, /* - * ITE - * op - * NOT - */ - IoV, /* - * ITE - * op - * VAR - */ - NoN, /* - * NOT - * op - * NOT - */ - NoV, /* - * NOT - * op - * VAR - */ - XoX /* - * VAR - * op - * VAR - */ - }; - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/DefCond.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/DefCond.java deleted file mode 100644 index 5af9b8e51..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/DefCond.java +++ /dev/null @@ -1,137 +0,0 @@ -package kodkod.engine.bool; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Variable; -import kodkod.ast.operator.Quantifier; -import kodkod.engine.config.Options.OverflowPolicy; -import kodkod.engine.fol2sat.Environment; - -public class DefCond implements IDefCond { - - /* - * --------------------------------------------------------- ---------------- - * ----------- - */ - /* used during translation */ - /* - * --------------------------------------------------------- ---------------- - * ----------- - */ - - private BooleanValue overflow = BooleanConstant.FALSE; - private BooleanValue accumOverflow = BooleanConstant.FALSE; - private Set vars = new HashSet(); - - @Override - public BooleanValue getOverflow() { - return overflow; - } - - @Override - public BooleanValue getAccumOverflow() { - return accumOverflow; - } - - @Override - public void setOverflows(BooleanValue of, BooleanValue accumOF) { - this.overflow = of; - this.accumOverflow = accumOF; - } - - @Override - public void addVar(Variable v) { - vars.add(v); - } - - @Override - public void addVars(Collection vars) { - this.vars.addAll(vars); - } - - @Override - public Set vars() { - return vars; - } - - /** - * ORs overflow circuits of this object ( - * this.mergedOverflow), a given other object ( - * other.mergedOverflow), and a given overflow circuit ( - * of) - */ - public static BooleanValue merge(BooleanFactory factory, BooleanValue accum, IDefCond... conds) { - BooleanValue ret = accum; - for (IDefCond dc : conds) { - ret = factory.or(ret, dc.getAccumOverflow()); - } - return ret; - } - - public static BooleanValue merge(BooleanFactory factory, IDefCond... conds) { - return merge(factory, BooleanConstant.FALSE, conds); - } - - /** - * If overflow checking is disabled returns value. Otherwise, - * returns a conjunction of value, lhs.accumOverflow, - * and rhs.accumOverflow. ~~~ NOTE ~~~: Every time a BooleanValue - * is returned as a result of an operation over Ints, one of the - * ensureNoOverflow methods should be called. - */ - public static BooleanValue ensureDef(BooleanFactory factory, Environment< ? , ? > env, BooleanValue value, IDefCond... dcs) { - if (factory.noOverflow == OverflowPolicy.NONE) - return value; - List univQuantInts = new ArrayList(dcs.length); - List extQuantInts = new ArrayList(dcs.length); - for (IDefCond e : dcs) { - if (isUnivQuant(env, e)) - univQuantInts.add(e); - else - extQuantInts.add(e); - } - BooleanValue ret = value; - if ((!env.isNegated()) == (factory.noOverflow == OverflowPolicy.PREVENT)) { - for (IDefCond e : univQuantInts) - ret = factory.or(ret, e.getAccumOverflow()); - for (IDefCond e : extQuantInts) - ret = factory.and(ret, factory.not(e.getAccumOverflow())); - } else { - for (IDefCond e : extQuantInts) - ret = factory.or(ret, e.getAccumOverflow()); - for (IDefCond e : univQuantInts) - ret = factory.and(ret, factory.not(e.getAccumOverflow())); - } - return ret; - } - - private static boolean isUnivQuant(Environment< ? , ? > env, IDefCond e) { - if (env.isEmpty()) - return false; - if (!isInt(env.type())) - return isUnivQuant(env.parent(), e); - if (e.vars().contains(env.variable())) { - return env.envType() == Quantifier.ALL; - } else { - return isUnivQuant(env.parent(), e); - } - } - - /** - * Returns if this expression represents the Int type. - */ - private static boolean isInt(Object expression) { - if (expression == null) - return false; - if (!(expression instanceof Expression)) - return false; - // TODO: this is probably not complete - return "ints".equals(expression.toString()); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Dimensions.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Dimensions.java deleted file mode 100644 index 7b3a7848a..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Dimensions.java +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import kodkod.engine.CapacityExceededException; -import kodkod.util.ints.Ints; - -/** - * Stores information about the size of a matrix. Specifically, for an - * n-dimensional matrix n, a Dimensions object is abstractly a vector consisting - * of n integers; the ith integer in the vector represents the size of the ith - * dimension of a matrix. - * - * @specfield n: int - * @specfield dimensions: [0..n) -> one int - * @specfield capacity: dimensions[0] x ... x dimensions[n-1] - * @invariant n > 0 - * @author Emina Torlak - */ -public abstract class Dimensions { - - private final int capacity; - - /** - * Constructs a Dimensions with the given capacity. - */ - private Dimensions(int capacity) { - this.capacity = capacity; - } - - /** - * Returns a new Dimensions object with n dimensions, each of which has the - * specified size. - * - * @return {d: Dimensions | d.n = n && d.dimensions[int] = size } - * @throws IllegalArgumentException n < 1 || size < 1 - */ - public static Dimensions square(int size, int n) { - if (n < 1 || size < 1) - throw new IllegalArgumentException("n < 1 || size < 1"); - return new Square(n, size); - } - - /** - * Constructs a new Dimensions object with the given dimensions. - * - * @return {d: Dimensions | d.n = dimensions.length && d.dimensions = dimensions - * } - * @throws NullPointerException dimensions = null - * @throws IllegalArgumentException dimensions.length = 0 || some i: - * [0..dimensions.n) | dimensions[i] < 1 - */ - public static Dimensions rectangular(int[] dimensions) { - if (dimensions.length == 0) - throw new IllegalArgumentException("n=0."); - long capacity = 1; - int size = dimensions[0]; - for (int i = 0; i < dimensions.length; i++) { - if (dimensions[i] < 1) - throw new IllegalArgumentException("Invalid dimension: " + dimensions[i]); - capacity *= dimensions[i]; - if (size != dimensions[i]) - size = 0; - } - if (size > 0) { - return new Square(dimensions.length, size); - } else { - final int[] dims = new int[dimensions.length]; - System.arraycopy(dimensions, 0, dims, 0, dimensions.length); - return new Rectangle(dims, capacity); - } - } - - /** - * Returns the capacity of this. - * - * @return this.capacity - */ - public final int capacity() { - return capacity; - } - - /** - * Returns the size of the ith dimensions - * - * @return this.dimensions[i] - * @throws ArrayIndexOutOfBoundsException i < 0 || i >= this.capacity - */ - public abstract int dimension(int i); - - /** - * Returns the number of dimensions in this Dimensions object. - * - * @return this.n - */ - public abstract int numDimensions(); - - /** - * Returns true if this represents the dimensions of a square matrix; otherwise - * returns false. - * - * @return all i, j: [0..capacity) | this.dimensions[i] = this.dimensions[j] - */ - public abstract boolean isSquare(); - - /** - * Returns true if the dimensions data in this object is homogeneous from start, - * inclusive, to end, exclusive. - * - * @return some x: int | this.dimensions[start..end) = x - */ - abstract boolean isSquare(int start, int end); - - /** - * Fills the destination array, beginning at destPos, with the dimension data - * from this Dimensions object, beginning at srcPos. The number of components - * copied is equal to the length argument. The dimensions at positions srcPos - * through srcPos+length-1 are copied into positions destPos through - * destPos+length-1, respectively, of the destination array. - * - * @ensures dest[destPos..destPos+length) = - * this.dimensions[srcPos..srcPos+length) - */ - abstract void copy(int srcPos, int[] dest, int destPos, int length); - - /** - * Returns the dimensions of a matrix that would result from multiplying a - * matrix of dimensions given by this by a matrix whose dimensions are specified - * by dim. - * - * @return { d: Dimensions | d.n = this.n + dim.n - 2 && (all i: [0..this.n-1) | - * d.dimensions[i] = this.dimensions[i]) && (all i: [this.n-1..d.n) | - * d.dimensions[i] = dim.dimensions[i-this.n+1])} - * @throws IllegalArgumentException this.n + dim.n < 3 || this.dimensions[n-1] - * != dim.dimensions[0] - */ - public final Dimensions dot(Dimensions dim) { - final int n0 = numDimensions(), n1 = dim.numDimensions(); - final int n = n0 + n1 - 2, drop = dim.dimension(0); - if (n == 0 || dimension(n0 - 1) != drop) { - throw new IllegalArgumentException(); - } - - if (isSquare(0, n0 - 1) && dim.isSquare(1, n1) && (n0 == 1 || n1 == 1 || dimension(0) == dim.dimension(1))) { - return new Square(n, dimension(0)); - } else { - final int[] dims = new int[n]; - copy(0, dims, 0, n0 - 1); - dim.copy(1, dims, n0 - 1, n1 - 1); - return new Rectangle(dims, (capacity * dim.capacity) / (drop * drop)); - } - } - - /** - * Returns the dimensions of a matrix that would result from taking the cross - * product of a matrix of dimensions given by this and a matrix whose dimensions - * are specified by dim. - * - * @return { d: Dimensions | d.n = this.n + dim.n && (all i: [0..this.n) | - * d.dimensions[i] = this.dimensions[i]) && (all i: [this.n..d.n) | - * d.dimensions[i] = dim.dimensions[i-this.n])} - */ - public final Dimensions cross(Dimensions dim) { - final int n0 = numDimensions(), n1 = dim.numDimensions(); - if (isSquare() && dim.isSquare() && dimension(0) == dim.dimension(0)) - return new Square(n0 + n1, dimension(0)); - else { - final int[] dims = new int[n0 + n1]; - copy(0, dims, 0, n0); - dim.copy(0, dims, n0, n1); - return new Rectangle(dims, (long) capacity * (long) dim.capacity); - } - } - - /** - * Returns the transpose of these dimensions. - * - * @return { d: Dimensions | d.n = 2 && d.dimensions[0] = this.dimensions[1] && - * d.dimensions[1] = this.dimensions[0] } - * @throws UnsupportedOperationException this.n != 2 - */ - public abstract Dimensions transpose(); - - /** - * @return true if index is positive and less than bound. - */ - private static boolean positiveBounded(int index, int bound) { - return 0 <= index && index < bound; - } - - /** - * Returns true if index is a valid flat index for a matrix with these - * dimensions; otherwise returns false. - * - * @return 0 <= i < this.capacity - */ - public final boolean validate(int index) { - return positiveBounded(index, capacity); - } - - /** - * Returns true if index is a valid vector index for a matrix with these - * dimensions; otherwise returns false. - * - * @return index.length = n && (all i: [0..this.capacity) | 0 <= index[i] < - * this.dimensions[i]) - * @throws NullPointerException index = null - */ - public final boolean validate(int[] index) { - final int length = numDimensions(); - if (index.length != length) - return false; - for (int i = 0; i < length; i++) { - if (!positiveBounded(index[i], dimension(i))) - return false; - } - return true; - } - - /** - * Converts an integer index into a matrix with these dimensions into a vector - * index. The effect of this method is the same as calling this.convert(index, - * new int[this.numDimensions()]). - * - * @return an array of ints that represents a vector index corresponding to the - * specified integer index into a - * this.dimensions[0]x...xthis.dimensions[n-1] matrix - * @throws IndexOutOfBoundsException !validate(index) - */ - public final int[] convert(int index) { - final int[] vector = new int[numDimensions()]; - convert(index, vector); - return vector; - } - - /** - * Converts an integer index into a matrix with these dimensions into a vector - * index, and stores the result in the provided array. This method requires that - * the array argument have at least this.n cells, which are used to store the - * vector representation of the given index. The contents of the cells of - * vectorIndex beyond the first this.n cells are left unchanged. - * - * @requires vectorIndex.length <= this.n - * @ensures the first this.numDimensions entries of vectorIndex - * contain the vector index representation of the specified integer - * index into a this.dimensions[0]x...xthis.dimensions[n-1] matrix - * @throws NullPointerException vectorIndex = null - * @throws IllegalArgumentException vectorIndex.length < this.numDimensions - * @throws IndexOutOfBoundsException !validate(index) - */ - public final void convert(int index, int[] vectorIndex) { - final int length = numDimensions(); - if (vectorIndex.length < length) - throw new IllegalArgumentException("arrayIndex.length= this.dimensions[i] - */ - public final int convert(int[] vectorIndex) { - final int length = numDimensions(); - if (vectorIndex.length < length) { - throw new IllegalArgumentException("index.length < this.n"); - } - int intIndex = 0; - int conversionFactor = capacity; - for (int i = 0; i < length; i++) { - int dim = dimension(i); - if (!positiveBounded(vectorIndex[i], dim)) - throw new IndexOutOfBoundsException("index[" + i + "]"); - conversionFactor = conversionFactor / dim; - intIndex += conversionFactor * vectorIndex[i]; - } - return intIndex; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder buffer = new StringBuilder("[ "); - for (int i = 0; i < numDimensions(); i++) { - buffer.append(dimension(i)); - buffer.append(" "); - } - buffer.append("]"); - return buffer.toString(); - } - - /** - * Represents a Dimensions object whose dimensions are all of the same size. - */ - private static final class Square extends Dimensions { - - private final int n, size; - - /** - * Constructs a new Dimensions object with n dimensions, each of which has the - * specified size. - * - * @ensures this.n' = n && this.dimensions[int] = size - * @requires size > 0 && n > 0 - * @throws IllegalArgumentException n < 1 || size < 1 - */ - Square(int n, int size) { - super(capacity(n, size)); - this.size = size; - this.n = n; - } - - static int capacity(int n, int size) { - final long cap = Math.round(Math.pow(size, n)); - if (cap > Integer.MAX_VALUE || cap <= 0) - throw new CapacityExceededException("Matrix too large: requested capacity of " + cap, Ints.nCopies(n, size)); - return (int) cap; - } - - @Override - void copy(int srcPos, int[] dest, int destPos, int length) { - if (srcPos < 0 || length < 0 || srcPos + length > n) - throw new ArrayIndexOutOfBoundsException(); - while (srcPos++ < length) { - dest[destPos++] = size; - } - } - - @Override - boolean isSquare(int start, int end) { - if (start <= end && start >= 0 && end <= n) { - return true; - } - throw new ArrayIndexOutOfBoundsException(); - } - - @Override - public int numDimensions() { - return n; - } - - @Override - public int dimension(int i) { - if (!positiveBounded(i, n)) - throw new ArrayIndexOutOfBoundsException(); - return size; - } - - @Override - public boolean isSquare() { - return true; - } - - @Override - public Dimensions transpose() { - if (numDimensions() != 2) - throw new UnsupportedOperationException("n!=2"); - return this; - } - - /** - * Returns true if the given object is logically equivalent to this; otherwise - * returns false. - * - * @return this.dimensions = o.dimensions - */ - @Override - public boolean equals(Object o) { - if (o instanceof Square) { - final Square s = (Square) o; - return n == s.n && size == s.size; - } - return false; - } - - @Override - public int hashCode() { - return n ^ size; - } - - } - - /** - * Represents a Dimensions object with at least two dimensions of different - * size. - */ - private static final class Rectangle extends Dimensions { - - private final int[] dimensions; - - /** - * Constructs a new Dimensions object with the given dimensions. - * - * @ensures this.n' = dimensions.length && this.dimensions' = dimensions - * @requires - dimensions.length > 0 && (all i: [0..dimensions.n) | - * dimensions[i] > 0) && (some i, j: [0..dimensions.n) | dimensions[i] - * != dimensions[j]) && capacity = - * dimensions[0]*dimensions[1]*...*dimensions[dimensions.length-1] - */ - Rectangle(int[] dims, long capacity) { - super((int) capacity); - if (capacity > Integer.MAX_VALUE || capacity <= 0) - throw new CapacityExceededException("Matrix too large: requested capacity of " + capacity, Ints.asIntVector(dims)); - this.dimensions = dims; - } - - @Override - void copy(int srcPos, int[] dest, int destPos, int length) { - System.arraycopy(dimensions, srcPos, dest, destPos, length); - } - - @Override - boolean isSquare(int start, int end) { - for (int i = start + 1; i < end; i++) { - if (dimensions[i - 1] != dimensions[i]) - return false; - } - return true; - } - - @Override - public boolean isSquare() { - return false; - } - - @Override - public int dimension(int i) { - return dimensions[i]; - } - - @Override - public int numDimensions() { - return dimensions.length; - } - - @Override - public Dimensions transpose() { - if (numDimensions() != 2) - throw new UnsupportedOperationException("n!=2"); - int[] dims = { - dimensions[1], dimensions[0] - }; - return new Rectangle(dims, capacity()); - } - - /** - * Returns true if the given object is logically equivalent to this; otherwise - * returns false. - * - * @return this.dimensions = dim.dimensions - */ - @Override - public boolean equals(Object o) { - if (o instanceof Rectangle) { - final Rectangle r = (Rectangle) o; - if (dimensions.length != r.dimensions.length || capacity() != r.capacity()) - return false; - for (int i = 0; i < dimensions.length; i++) { - if (dimensions[i] != r.dimensions[i]) - return false; - } - return true; - } - return false; - - } - - @Override - public int hashCode() { - return dimensions.length ^ capacity(); - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/FakeDefCond.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/FakeDefCond.java deleted file mode 100644 index 8eec6b4cb..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/FakeDefCond.java +++ /dev/null @@ -1,56 +0,0 @@ -package kodkod.engine.bool; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import kodkod.ast.Variable; -import kodkod.engine.fol2sat.Environment; - -public class FakeDefCond implements IDefCond { - - private final Set vars = Collections.unmodifiableSet(new HashSet()); - - @Override - public BooleanValue getOverflow() { - return BooleanConstant.FALSE; - } - - @Override - public BooleanValue getAccumOverflow() { - return BooleanConstant.FALSE; - } - - @Override - public void setOverflows(BooleanValue of, BooleanValue accumOF) {} - - @Override - public void addVar(Variable v) {} - - @Override - public void addVars(Collection vars) {} - - @Override - public Set vars() { - return vars; - } - - public void setOverflowFlag(boolean overflow) {} - - public boolean isOverflowFlag() { - return false; - } - - public static BooleanValue merge(BooleanFactory factory, BooleanValue accum, IDefCond... conds) { - return BooleanConstant.FALSE; - } - - public static BooleanValue merge(BooleanFactory factory, IDefCond... conds) { - return BooleanConstant.FALSE; - } - - public static BooleanValue ensureDef(BooleanFactory factory, Environment< ? , ? > env, BooleanValue value, IDefCond... dcs) { - return value; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/IDefCond.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/IDefCond.java deleted file mode 100644 index 698d7f43d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/IDefCond.java +++ /dev/null @@ -1,21 +0,0 @@ -package kodkod.engine.bool; - -import java.util.Collection; -import java.util.Set; - -import kodkod.ast.Variable; - -public interface IDefCond { - - public BooleanValue getOverflow(); - - public BooleanValue getAccumOverflow(); - - public void setOverflows(BooleanValue of, BooleanValue accumOF); - - public void addVar(Variable v); - - public void addVars(Collection vars); - - public Set vars(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/ITEGate.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/ITEGate.java deleted file mode 100644 index b3313ff83..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/ITEGate.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; -import java.util.Set; - -import kodkod.util.collections.Containers; -import kodkod.util.ints.Ints; - -/** - * An if-then-else gate. - * - * @specfield ifFormula: BooleanFormula - * @specfield thenFormula: BooleanFormula - * @specfield elseFormula: BooleanFormula - * @invariant inputs = 0->ifFormula + 1->thenFormula + 2->elseFormula - * @invariant this.label > 0 - * @invariant this.op = Operator.ITE - * @specfield all input: inputs | this.label > |input.label| - * @author Emina Torlak - */ -public final class ITEGate extends BooleanFormula { - - private final BooleanFormula[] inputs; - private final int label, hashcode, labelhash; - - /** - * Constructs a new ITEGate from the given formulas and label. - * - * @requires label >= 0 && null !in ifFormula + thenFormula + elseFormula - * @requires hashcode = ITE.hash(ifFormula, thenFormula, elseFormula) - * @ensures this.label' = label && this.ifFormula' = ifFormula && - * this.thenFormula' = thenFormula && this.elseFormula' = elseFormula - * @throws NullPointerException owner = null - */ - ITEGate(int label, int hashcode, BooleanFormula ifFormula, BooleanFormula thenFormula, BooleanFormula elseFormula) { - super(null); - assert label >= 0; - this.label = label; - this.labelhash = Ints.superFastHash(label); - this.hashcode = hashcode; - this.inputs = new BooleanFormula[3]; - inputs[0] = ifFormula; - inputs[1] = thenFormula; - inputs[2] = elseFormula; - } - - /** - * Returns a hash of this.label - * - * @return a hash of this.label - */ - @Override - int hash(Operator op) { - return labelhash; - } - - /** - * Returns an iterator over this.inputs - * - * @return returns an iterator over this.inputs - * @see kodkod.engine.bool.BooleanFormula#iterator() - */ - @Override - public Iterator iterator() { - return Containers.iterate(inputs); - } - - /** - * Returns 3. - * - * @return 2 - * @see kodkod.engine.bool.BooleanFormula#size() - */ - @Override - public int size() { - return 3; - } - - /** - * Returns this.label - * - * @return this.label - * @see kodkod.engine.bool.BooleanValue#label() - */ - @Override - public int label() { - return label; - } - - /** - * Passes this value and the given argument value to the visitor, and returns - * the resulting value. - * - * @return the value produced by the visitor when visiting this node with the - * given argument. - * @see kodkod.engine.bool.BooleanFormula#accept(kodkod.engine.bool.BooleanVisitor, - * Object) - */ - @Override - public T accept(BooleanVisitor visitor, A arg) { - return visitor.visit(this, arg); - } - - /** - * Returns a string representation of this ITE gate. - * - * @return a string representation of this ITE gate. - */ - @Override - public String toString() { - return "(" + inputs[0] + "?" + inputs[1] + ":" + inputs[2] + ")"; - } - - /** - * Returns the hashcode for this if-then-else gate. - * - * @return the hashcode for this gate. - */ - @Override - public int hashCode() { - return hashcode; - } - - /** - * Returns Operator.ITE. - * - * @return Operator.ITE - */ - @Override - public kodkod.engine.bool.Operator op() { - return kodkod.engine.bool.Operator.ITE; - } - - /** - * Returns this.inputs[i]. - * - * @return this.inputs[i] - * @throws IndexOutOfBoundsException 0 < i || i > 2 - */ - @Override - public BooleanFormula input(int i) { - if (i < 0 || i > 2) - throw new IndexOutOfBoundsException(); - return inputs[i]; - } - - /** - * Returns an integer k' such that 0 < |k'| < k and |k'| is the number of - * flattening steps that need to be taken to determine that this circuit has (or - * does not have) an input with the given label. A positive k' indicates that f - * is found to be an input to this circuit in k' steps. A negative k' indicates - * that f is not an input to this circuit, when it is flattened using at most k - * steps. - * - * @requires k > 0 - * @return this=f => 1 else op=ITE && k>2 && f in this.inputs[int].label => 3 - * else -3 - */ - @Override - int contains(Operator op, int f, int k) { - assert k > 0; - if (f == label) - return 1; - else if (op != Operator.ITE || k < 3 || f > label || -f > label) - return -1; - else - return (inputs[0].label() == f || inputs[1].label() == f || inputs[2].label() == f) ? 3 : -3; - } - - /** - * Flattens this circuit with respect to the given operator into the provided - * set. - * - * @requires k > 0 - * @ensures op = Operator.ITE && k> 2 => flat.elts' = flat.elts + - * this.inputs[ints], flat.elts' = flat.elts + this - */ - @Override - void flatten(Operator op, Set flat, int k) { - assert k > 0; - if (op == Operator.ITE && k > 2) { - flat.add(inputs[0]); - flat.add(inputs[1]); - flat.add(inputs[2]); - } else { - flat.add(this); - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Int.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Int.java deleted file mode 100644 index 7d16bcb73..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Int.java +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Collection; -import java.util.List; - -import kodkod.ast.Variable; -import kodkod.engine.fol2sat.Environment; - -/** - * An integer represented using {@link kodkod.engine.bool.BooleanValue boolean - * values} and a given {@link kodkod.engine.config.Options.IntEncoding integer - * encoding}. - * - * @specfield factory: BooleanFactory - * @specfield bits: [0..factory.bitwidth) -> one factory.components - * @specfield encoding: factory.intEncoding - * @author Emina Torlak - */ -@SuppressWarnings("rawtypes" ) -public abstract class Int { - - final BooleanFactory factory; - final IDefCond defCond; - final boolean overflows; - - /** - * Creates an Int with the given factory - * - * @ensures this.factory' = factory - */ - Int(BooleanFactory factory, Collection vars, boolean overflows) { - this.factory = factory; - this.overflows = overflows; - this.defCond = overflows ? new DefCond() : new FakeDefCond(); - defCond.addVars(vars); - } - - /** - * Throws IllegalArgumentException if other.factory != this.factory. - * - * @throws IllegalArgumentException other.factory != this.factory. - */ - final void validate(Int other) { - if (other.factory != factory) - throw new IllegalArgumentException("other.factory != this.factory"); - } - - /** - * Returns the BooleanValue at the specified index. - * - * @requires 0 <= i < this.factory.bitwidth - * @return this.bits[i] - */ - abstract BooleanValue bit(int i); - - /** - * Returns the most significant bit - * - * @return this.bits[this.width()-1] - */ - abstract BooleanValue msb(); - - /** - * Returns the little endian two's complement representation of this integer - * that is this.factory.bitwidth bits wide. Specifically, the returned list L - * has this.factory.bitwidth boolean values such that the meaning of this - * integer is 1*[[L.get(0)]] + ... + (1< twosComplementBits(); - - /** - * Returns this.factory - * - * @return this.factory - */ - public final BooleanFactory factory() { - return factory; - } - - /** - * Returns this.defCond - * - * @return this.defCond - */ - public final IDefCond defCond() { - return defCond; - } - - /** - * Returns the number of bits in the representation of this Int, including sign - * bits (if any). - * - * @return this.width - */ - public abstract int width(); - - /** - * Returns true if all the bits representing this Int are BooleanConstants. - * - * @return this.bits[int] in BooleanConstant - */ - public abstract boolean isConstant(); - - /** - * If this Int is constant, returns its value. Otherwise throws an - * IllegalStateException. - * - * @return this.isConstant() => [[this.bits]] - * @throws IllegalStateException !this.isConstant() - */ - public abstract int value(); - - /** - * Returns a BooleanValue encoding the comparator circuit that checks whether - * the integer represented by this Int is equal to the integer represented by - * the specified Int. - * - * @requires this.factory = other.factory - * @return BooleanValue encoding the comparator circuit that checks whether the - * integer represented by this Int is equal to the integer represented - * by the specified Int - * @throws IllegalArgumentException this.factory != other.factory - */ - public final BooleanValue eq(Int other) { - return this.eq(other, Environment.empty()); - } - - public abstract BooleanValue eq(Int other, Environment env); - - public final BooleanValue neq(Int other) { - return this.neq(other, Environment.empty()); - } - - public abstract BooleanValue neq(Int other, Environment env); - - /** - * Returns a BooleanValue encoding the comparator circuit that checks whether - * the integer represented by this Int is less than or equal to the integer - * represented by the specified Int - * - * @requires this.factory = other.factory - * @return BooleanValue encoding the comparator circuit that checks whether the - * integer represented by this Int is less than or equal to the integer - * represented by the specified Int - * @throws IllegalArgumentException this.factory != other.factory - */ - public BooleanValue lte(Int other) { - return this.lte(other, Environment.empty()); - } - - public abstract BooleanValue lte(Int other, Environment env); - - /** - * Returns a BooleanValue encoding the comparator circuit that checks whether - * the integer represented by this Int is less than the integer represented by - * the specified Int. - * - * @requires this.factory = other.factory - * @return BooleanValue encoding the comparator circuit that checks whether the - * integer represented by this Int is less than the integer represented - * by the specified Int - * @throws IllegalArgumentException this.factory != other.factory - */ - public final BooleanValue lt(Int other) { - return this.gte(other, Environment.empty()); - } - - public abstract BooleanValue lt(Int other, Environment env); - - /** - * Returns a BooleanValue encoding the comparator circuit that checks whether - * the integer represented by this Int is greater than or equal to the integer - * represented by the specified Int. - * - * @requires this.factory = other.factory - * @return BooleanValue encoding the comparator circuit that checks whether the - * integer represented by this Int is greater than or equal to the - * integer represented by the specified Int - * @throws IllegalArgumentException this.factory != other.factory - */ - public BooleanValue gte(Int other) { - return this.gte(other, Environment.empty()); - } - - public BooleanValue gte(Int other, Environment env) { - return other.lte(this, env); - } - - /** - * Returns a BooleanValue encoding the comparator circuit that checks whether - * the integer represented by this Int is greater than the integer represented - * by the specified Int. - * - * @requires this.factory = other.factory - * @return BooleanValue encoding the comparator circuit that checks whether the - * integer represented by this Int is greater than the integer - * represented by the specified Int - * @throws IllegalArgumentException this.factory != other.factory - */ - public BooleanValue gt(Int other) { - return this.gt(other, Environment.empty()); - } - - public BooleanValue gt(Int other, Environment env) { - return other.lt(this, env); - } - - /** - * Returns an Int that represents the sum of this and the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the sum of this and the given Int - * @throws IllegalArgumentException this.factory != other.factory - */ - public abstract Int plus(Int other); - - /** - * Returns an Int that represents the sum of this and the given Ints. - * - * @requires this.factory = others[int].factory - * @return an Int that represents the sum of this and the given Ints - * @throws IllegalArgumentException this.factory != others[int].factory - */ - public abstract Int plus(Int... others); - - /** - * Returns an Int that represents the product between this and the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the product between this and the given Int - * @throws UnsupportedOperationException this.encoding does not support - * multiplication - */ - public abstract Int multiply(Int other); - - /** - * Returns an Int that represents the product between this and the given Ints. - * - * @requires this.factory = others[int].factory - * @return an Int that represents the product between this and the given Ints - * @throws UnsupportedOperationException this.encoding does not support - * multiplication - */ - public abstract Int multiply(Int... others); - - /** - * Returns an Int that represents the difference between this and the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the difference between this and the given Int - * @throws UnsupportedOperationException this.encoding does not support - * subtraction - */ - public abstract Int minus(Int other); - - /** - * Returns an Int that represents the quotient of the division between this and - * the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the quotient of the division between this and - * the given Int - * @throws UnsupportedOperationException this.encoding does not support division - */ - public abstract Int divide(Int other); - - /** - * Returns an Int that represents the remainder of the division between this and - * the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the remainder of the division between this and - * the given Int - * @throws UnsupportedOperationException this.encoding does not support division - */ - public abstract Int modulo(Int other); - - /** - * Returns an Int that evaluates to this if the condition is true, otherwise it - * evaluates to the given Int. - * - * @requires other + condition in this.factory.components - * @return an Int that evaluates to this if the condition is true, and to the - * given Int if the condition is false. - */ - public abstract Int choice(BooleanValue condition, Int other); - - /** - * Returns an Int that represents the bitwise conjunction of this and the given - * Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the bitwise conjunction of this and the given - * Int. - */ - public abstract Int and(Int other); - - /** - * Returns an Int that represents the bitwise conjunction of this and the given - * Ints. - * - * @requires this.factory = others[int].factory - * @return an Int that represents the bitwise conjunction of this and the given - * Ints. - */ - public abstract Int and(Int... others); - - /** - * Returns an Int that represents the bitwise disjunction of this and the given - * Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the bitwise disjunction of this and the given - * Int. - */ - public abstract Int or(Int other); - - /** - * Returns an Int that represents the bitwise disjunction of this and the given - * Ints. - * - * @requires this.factory = others[int].factory - * @return an Int that represents the bitwise disjunction of this and the given - * Ints. - */ - public abstract Int or(Int... others); - - /** - * Returns an Int that represents the bitwise XOR of this and the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents the bitwise XOR of this and the given Int. - * @throws UnsupportedOperationException this.encoding does not support XOR - */ - public abstract Int xor(Int other); - - /** - * Returns an Int that represents this shifted to the left by the given Int. - * - * @requires this.factory = other.factory - * @return an Int that represents this shifted to the left by the given Int. - * @throws UnsupportedOperationException this.encoding does not support SHL - */ - public abstract Int shl(Int other); - - /** - * Returns an Int that represents this shifted to the right by the given Int, - * with zero extension. - * - * @requires this.factory = other.factory - * @return an Int that represents this shifted to the right by the given Int, - * with zero extension. - * @throws UnsupportedOperationException this.encoding does not support SHR - */ - public abstract Int shr(Int other); - - /** - * Returns an Int that represents this shifted to the right by the given Int, - * with sign extension. - * - * @requires this.factory = other.factory - * @return an Int that represents this shifted to the right by the given Int, - * with sign extension. - * @throws UnsupportedOperationException this.encoding does not support SHA - */ - public abstract Int sha(Int other); - - /** - * Returns an Int that represents the negation of this integer. - * - * @return -[[this]] - * @throws UnsupportedOperationException this.encoding does not support negation - */ - public abstract Int negate(); - - /** - * Returns an Int that represents bitwise negation of this integer. - * - * @return ~[[this]] - * @throws UnsupportedOperationException this.encoding does not support bitwise - * negation - */ - public abstract Int not(); - - /** - * Returns an Int that represents the absolute value of this integer. - * - * @return abs([[this]]) - */ - public abstract Int abs(); - - /** - * Returns an Int that represents the signum of this integer. - * - * @return sgn([[this]]) - */ - public abstract Int sgn(); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/MultiGate.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/MultiGate.java deleted file mode 100644 index fdbcefd72..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/MultiGate.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; - -import kodkod.util.ints.Ints; - -/** - * A logic gate with two or more inputs; an AND or an OR gate. - * - * @specfield op: Operator.Binary - * @invariant #inputs > 1 - * @invariant some components.this => label in [1..Integer.MAX_VALUE), label in - * [0..Integer.MAX_VALUE) - * @invariant no c1, c2: inputs | c1.label = -c2.label - * @invariant this.label > 0 => all c: inputs | |c.label| < this.label - * @author Emina Torlak - */ -public abstract class MultiGate extends BooleanFormula { - - final Operator.Nary op; - - private final int label, labelhash, hashcode; - - /** - * Constructs a new MultiGate gate with the given operator and label. - * - * @requires op != null && label >= 0 - * @ensures this.op' = op && this.label' = label - */ - MultiGate(Operator.Nary op, int label, int hashcode) { - super(null); - assert op != null; - assert label >= 0; - this.op = op; - this.label = label; - this.labelhash = Ints.superFastHash(label); - this.hashcode = hashcode; - } - - /** - * Returns the label for this value. - * - * @return this.label - */ - @Override - public final int label() { - return label; - } - - /** - * Returns the operator used to combine the input variables of this connective - * gate. - * - * @return this.op - */ - @Override - public final Operator.Nary op() { - return op; - } - - /** - * Passes this value and the given argument value to the visitor, and returns - * the resulting value. - * - * @return the value produced by the visitor when visiting this node with the - * given argument. - */ - @Override - public T accept(BooleanVisitor visitor, A arg) { - return visitor.visit(this, arg); - } - - /** - * Returns a string representation of this multigate. - * - * @return a string representation of this multigate. - */ - @Override - public String toString() { - final StringBuilder builder = new StringBuilder("("); - final Iterator children = iterator(); - builder.append(children.next()); - while (children.hasNext()) { - builder.append(op); - builder.append(children.next()); - } - builder.append(")"); - return builder.toString(); - } - - /** - * Returns a hashcode for this gate. The hashcode obeys the Object contract. - * - * @return a hashcode for this gate. - */ - @Override - public final int hashCode() { - return hashcode; - } - - /** - * Returns the digest of this formula that would be used to compute the digest - * of the composition of this and some other formula using the given operator. - * Specifically, if op = this.op, then the sum of this circuit's irreducible - * inputs' hashes (with respect to op) is returned. Otherwise, the superFastHash - * of this.label is returned. - * - * @return this.op = op => this.op.hash(this.inputs), - * Ints.superFastHash(this.label) - */ - @Override - final int hash(Operator op) { - return op == this.op ? hashcode : labelhash; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/NaryGate.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/NaryGate.java deleted file mode 100644 index 0f10e4da8..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/NaryGate.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; -import java.util.Set; - -import kodkod.util.collections.Containers; - -/** - * Represents a multi gate with more than two inputs. - * - * @invariant #this.inputs > 2 - * @invariant digest = sum(inputs.digest(this.op)) - */ -final class NaryGate extends MultiGate { - - private final BooleanFormula[] inputs; - - /** - * Constructs a new n-ary gate with the given label, from the given mutable - * multi gate. - * - * @requires g != null && #g.inputs > 2 - * @ensures this.op' = g.op && this.inputs' = g.inputs && this.label' = label - */ - NaryGate(BooleanAccumulator g, int label, int hashcode) { - super(g.op, label, hashcode); - this.inputs = new BooleanFormula[g.size()]; - int index = 0; - for (Iterator i = g.iterator(); i.hasNext();) { - inputs[index] = (BooleanFormula) i.next(); - index++; - } - } - - /** - * Returns the number of inputs to this gate. - * - * @return #this.inputs - */ - @Override - public int size() { - return inputs.length; - } - - /** - * Returns an iterator over the inputs to this gate, in the ascending label - * order. - * - * @return an iterator over this.inputs - */ - @Override - public Iterator iterator() { - return Containers.iterate(inputs); - } - - /** - * Returns an integer k' such that 0 < |k'| < k and |k'| is the number of - * flattening steps that need to be taken to determine that this circuit has (or - * does not have) an input with the given label. A positive k' indicates that f - * is found to be an input to this circuit in k' steps. A negative k' indicates - * that f is not an input to this circuit, when it is flattened using at most k - * steps. - * - * @requires k > 0 - * @return the number of flattening steps that need to be taken to determine - * that f is (not) an input to this circuit - */ - @Override - int contains(Operator op, int f, int k) { - assert k > 0; - if (f == label()) - return 1; - else if (this.op != op || f > label() || -f > label()) - return -1; - else { - int low = 0, high = inputs.length - 1, step = 1; - while (low <= high && step <= k) { - int mid = (low + high) >>> 1; - int midVal = inputs[mid].label(); - - if (midVal < f) - low = mid + 1; - else if (midVal > f) - high = mid - 1; - else - return step; // key found in the given number of steps - step++; - } - return 1 - step; // key not found. - } - } - - /** - * Flattens this circuit with respect to the given operator into the provided - * set. Specifically, the method modifies the set so that it contains the - * elements f_0, ..., f_k' where k' <= k elements and [[this]] = op(f_0, ..., - * f_k'). The default implementation simply adds this to the set. - * - * @requires k > 0 - * @ensures 1 <= k' <= k && some f_0,..., f_k' : flat.elts' | [[this]] = - * op([[f_0]], ..., [[f_k']]) - */ - @Override - void flatten(Operator op, Set flat, int k) { - assert k > 0; - if (this.op == op && k >= inputs.length) { - int diff = k - inputs.length; - for (BooleanFormula f : inputs) { - int oldsize = flat.size(); - f.flatten(op, flat, StrictMath.max(1, diff)); - diff -= (flat.size() - oldsize); - } - } else { - flat.add(this); - } - } - - /** - * Returns true if the given iterator and this.iterator return the same - * elements, in the same order. - * - * @return true if values and this.iterator return the same elements, in the - * same order. - */ - boolean sameInputs(Iterator< ? extends BooleanValue> values) { - for (BooleanFormula f : inputs) { - if (!(values.hasNext() && f == values.next())) - return false; - } - return !values.hasNext(); - } - - /** - * Returns the ith input to this gate. - * - * @return this.inputs[i] - * @requires 0 <= i < size - * @throws IndexOutOfBoundsException i < 0 || i >= #this.inputs - */ - @Override - public BooleanFormula input(int i) { - if (i < 0 || i > inputs.length) - throw new IndexOutOfBoundsException(); - return inputs[i]; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/NotGate.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/NotGate.java deleted file mode 100644 index 2802de768..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/NotGate.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import kodkod.util.ints.Ints; - -/** - * A logic NOT gate. - * - * @invariant this.op = Operator.NOT - * @invariant #inputs = 1 - * @invariant this.label = -inputs.label - * @invariant label in (-Integer.MAX_VALUE..-1] - * @author Emina Torlak - */ -public final class NotGate extends BooleanFormula { - - private final int hashcode; - - /** - * Constructs a new NotGate with the given formula as its input. - * - * @requires input != null && input !in NotGate - * @ensures this.inputs' = 0->input && this.output'.label = -input.label - */ - NotGate(BooleanFormula input) { - super(input); - this.hashcode = Ints.superFastHash(-input.label()); - } - - /** - * Returns a hash of this inverter's label. - * - * @return Ints.superFastHash(this.label) - */ - @Override - int hash(Operator op) { - return hashcode; - } - - /** - * Returns an iterator that returns this gate's single input. - * - * @return an iterator over this.inputs. - */ - @Override - public Iterator iterator() { - return new Iterator() { - - boolean hasNext = true; - - @Override - public boolean hasNext() { - return hasNext; - } - - @Override - public BooleanFormula next() { - if (!hasNext) - throw new NoSuchElementException(); - hasNext = false; - return negation(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - }; - } - - /** - * Returns the label for this value. - * - * @return this.label - */ - @Override - public final int label() { - return -negation().label(); - } - - /** - * Returns 1. - * - * @return 1. - */ - @Override - public int size() { - return 1; - } - - /** - * Passes this value and the given argument value to the visitor, and returns - * the resulting value. - * - * @return the value produced by the visitor when visiting this node with the - * given argument. - */ - @Override - public T accept(BooleanVisitor visitor, A arg) { - return visitor.visit(this, arg); - } - - /** - * Returns a string representation of this inverter. - * - * @return a string representation of this inverter. - */ - @Override - public String toString() { - return "!" + negation().toString(); - } - - /** - * Returns Operator.NOT. - * - * @return Operator.NOT - */ - @Override - public kodkod.engine.bool.Operator op() { - return kodkod.engine.bool.Operator.NOT; - } - - /** - * Returns this.input[i]. - * - * @return this.input[i] - * @throws IndexOutOfBoundsException i != 0 - */ - @Override - public BooleanFormula input(int i) { - if (i != 0) - throw new IndexOutOfBoundsException(); - return negation(); - } - - /** - * Returns a hashcode for this inverter. - * - * @return a hashcode for this inverter. - */ - @Override - public int hashCode() { - return hashcode; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Operator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Operator.java deleted file mode 100644 index 85270cd2a..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/Operator.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import java.util.Iterator; - -/** - * ExprOperator associated with a {@link kodkod.engine.bool.BooleanValue boolean - * value}. - * - * @specfield ordinal: [0..5] - * @invariant AND.ordinal = 0 && OR.ordinal = 1 && ITE.ordinal = 2 && - * NOT.ordinal = 2 && VAR.ordinal = 4 && CONST.ordinal = 5 - * @author Emina Torlak - */ -public abstract class Operator implements Comparable { - - final int ordinal; - - private Operator(int ordinal) { - this.ordinal = ordinal; - } - - /** - * Returns the ordinal of this operator constant. - * - * @return the ordinal of this operator constant. - */ - public final int ordinal() { - return ordinal; - } - - /** - * Returns an integer i such that i < 0 if this.ordinal < op.ordinal, i = 0 when - * this.ordinal = op.ordinal, and i > 0 when this.ordinal > op.ordinal. - * - * @return i: int | this.ordinal < op.ordinal => i < 0, this.ordinal = - * op.ordinal => i = 0, i > 0 - * @throws NullPointerException op = null - */ - @Override - public int compareTo(Operator op) { - return ordinal() - op.ordinal(); - } - - /** - * N-ary {@link MultiGate AND} operator. - */ - public static final Nary AND = new Nary(0) { - - @Override - public String toString() { - return "&"; - } - - /** @return true */ - @Override - public BooleanConstant identity() { - return BooleanConstant.TRUE; - } - - /** @return false */ - @Override - public BooleanConstant shortCircuit() { - return BooleanConstant.FALSE; - } - - /** @return OR */ - @Override - public Nary complement() { - return OR; - } - }; - - /** - * N-ary {@link MultiGate OR} operator. - */ - public static final Nary OR = new Nary(1) { - - @Override - public String toString() { - return "|"; - } - - /** @return false */ - @Override - public BooleanConstant identity() { - return BooleanConstant.FALSE; - } - - /** @return true */ - @Override - public BooleanConstant shortCircuit() { - return BooleanConstant.TRUE; - } - - /** @return AND */ - @Override - public Nary complement() { - return AND; - } - }; - - /** - * Ternary {@link ITEGate if-then-else} operator. - */ - public static final Ternary ITE = new Ternary(2) { - - @Override - public String toString() { - return "?"; - } - }; - - /** - * Unary {@link NotGate negation} operator. - */ - public static final Operator NOT = new Operator(3) { - - @Override - public String toString() { - return "!"; - } - }; - - /** - * Zero-arity {@link BooleanVariable variable} operator. - */ - public static final Operator VAR = new Operator(4) { - - @Override - public String toString() { - return "var"; - } - }; - - /** - * Zero-arity {@link BooleanConstant constant} operator. - */ - public static final Operator CONST = new Operator(5) { - - @Override - public String toString() { - return "const"; - } - }; - - /** - * An n-ary operator, where n>=2 - */ - public static abstract class Nary extends Operator { - - private Nary(int ordinal) { - super(ordinal); - } - - /** - * Returns the hashcode for a gate v such that v.op = this && v.inputs[int] = f0 - * + f1 - * - * @return f0.hash(this) + f1.hash(this) - */ - int hash(BooleanFormula f0, BooleanFormula f1) { - return f0.hash(this) + f1.hash(this); - } - - /** - * Returns the hashcode for a gate v such that v.op = this && v.iterator() = - * formulas. - * - * @return sum(formulas.hash(this)) - */ - int hash(Iterator formulas) { - int sum = 0; - while (formulas.hasNext()) - sum += formulas.next().hash(this); - return sum; - } - - /** - * Returns the boolean constant c such that for all logical values - * x, c composed with x using this operator will result in - * x. - * - * @return the identity value of this binary operator - */ - public abstract BooleanConstant identity(); - - /** - * Returns the boolean constant c such that for all logical values - * x, c composed with x using this operator will result in - * c. - * - * @return the short circuiting value of this binary operator - */ - public abstract BooleanConstant shortCircuit(); - - /** - * Returns the binary operator whose identity and short circuit values are the - * negation of this operator's identity and short circuit. - * - * @return the complement of this binary operator - */ - public abstract Operator.Nary complement(); - } - - static abstract class Ternary extends Operator { - - private Ternary(int ordinal) { - super(ordinal); - } - - /** - * Returns the hashcode for a gate v such that v = (i ? t : e) - * - * @return 3*i.hash(this) + 5*t.hash(this) + 7*e.hash(this) - */ - int hash(BooleanFormula i, BooleanFormula t, BooleanFormula e) { - return 3 * i.hash(this) + 5 * t.hash(this) + 7 * e.hash(this); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/RBCFactory.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/RBCFactory.java deleted file mode 100644 index 4a5519a42..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/RBCFactory.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import static kodkod.engine.bool.BooleanConstant.FALSE; -import static kodkod.engine.bool.BooleanConstant.TRUE; -import static kodkod.engine.bool.Operator.AND; -import static kodkod.engine.bool.Operator.CONST; -import static kodkod.engine.bool.Operator.ITE; -import static kodkod.engine.bool.Operator.OR; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; - -import kodkod.util.collections.CacheSet; - -/** - * A factory for creating variables, binary gates, and if-then-else gates, in - * RBC form. - * - * @specfield values: set (BooleanVariable + MultiGate + ITEGate) - * @specfield cmpMax: int // the maximum number of comparisons made when - * comparing circuits for equality - * @invariant no disj factory, factory' : CircuitFactory | some factory.values & - * factory'.values - * @author Emina Torlak - */ -final class RBCFactory { - - /** - * Stores input variables. - * - * @invariant all i: [1..iLits.size()] | vars[i-1].positive.label = i - */ - private final BooleanVariable[] vars; - /** - * Caches the AND, OR, and ITE gates. - * - * @invariant all i: [0..2] | c[i].op.ordinal = i - */ - private final CacheSet[] cache; - private int label, cmpMax; - - /** - * Constructs a CircuitFactory using the given max comparison parameter, - * initialized to contain the given number of variables. - * - * @requires cmpMax > 0 && numVars >= 0 - * @ensures #this.values' = numVars && this.values in BooleanVariable - * @ensures this.cmpMax' = cmpMax - */ - @SuppressWarnings("unchecked" ) - RBCFactory(int numVars, int cmpMax) { - assert cmpMax > 0 && numVars >= 0; - this.cmpMax = cmpMax; - this.label = numVars + 1; - vars = new BooleanVariable[numVars]; - for (int i = 0; i < numVars; i++) { - vars[i] = new BooleanVariable(i + 1); - } - - cache = new CacheSet[] { - new CacheSet(), new CacheSet(), new CacheSet() - }; - } - - /** - * Returns the cache for gates with the given operator. - * - * @requires op in AND + OR + ITE - * @return cache[op.ordinal] - */ - private CacheSet opCache(Operator op) { - return cache[op.ordinal]; - } - - /** - * Sets this.cmpMax to the given value. - * - * @requires cmpMax > 0 - * @ensures this.cmpMax' = cmpMax - */ - void setCmpMax(int cmpMax) { - assert cmpMax > 0; - this.cmpMax = cmpMax; - } - - /** - * Returns this.cmpMax. - * - * @return this.cmpMax - */ - int cmpMax() { - return cmpMax; - } - - /** - * Removes all MultiGates and ITEGates from this.factory. - * - * @ensures this.values' = this.values & BooleanVariable - */ - void clear() { - label = vars.length + 1; - cache[0].clear(); - cache[1].clear(); - cache[2].clear(); - } - - /** - * Returns true if the given value is a valid argument to one of the - * assemble methods. Otherwise returns false. - * - * @return v in this.values + this.values.negation + BooleanConstant - */ - boolean canAssemble(BooleanValue v) { - if (v.op() == CONST) - return true; - if (v.label() < 0) - v = v.negation(); - final int absLit = v.label(); - if (absLit <= vars.length) { - return v == vars[absLit - 1]; - } else { - final BooleanFormula g = (BooleanFormula) v; - for (Iterator gates = opCache(g.op()).get(g.hashCode()); gates.hasNext();) { - if (gates.next() == g) - return true; - } - return false; - } - } - - /** - * Returns the number of variables in this factory. - * - * @return #(this.values & BooleanVariable) - */ - int numVars() { - return vars.length; - } - - /** - * Returns the boolean variable from this.values with the given label. - * - * @requires 0 < label <= #(this.values & BooleanVariable) - * @return (this.values & BooleanVariable).label - */ - BooleanVariable variable(int label) { - return vars[label - 1]; - } - - /** - * Returns a boolean value whose meaning is (if [[i]] then [[t]] else [[e]]). - * - * @requires i + t + e in (this.values + this.values.negation + BooleanConstant) - * @return v: BooleanValue | [[v]] = if [[i]] then [[t]] else [[e]] - * @ensures v in BooleanFormula - NotGate => this.values' = this.values + v, - * this.values' = this.values - * @throws NullPointerException any of the arguments are null - */ - BooleanValue assemble(BooleanValue i, BooleanValue t, BooleanValue e) { - if (i == TRUE || t == e) - return t; - else if (i == FALSE) - return e; - else if (t == TRUE || i == t) - return assemble(OR, i, e); - else if (t == FALSE || i.negation() == t) - return assemble(AND, i.negation(), e); - else if (e == TRUE || i.negation() == e) - return assemble(OR, i.negation(), t); - else if (e == FALSE || i == e) - return assemble(AND, i, t); - else { - final int ilabel = i.label(), tlabel = t.label(), elabel = e.label(); - boolean neg = false; - BooleanFormula f0 = (BooleanFormula) i, f1 = (BooleanFormula) t, f2 = (BooleanFormula) e; - if (Math.abs(tlabel) == Math.abs(elabel)) { - if (ilabel > 0 && tlabel < 0 && elabel > 0) { // (a <=> !b) - // becomes !(a - // <=> b) - neg = true; - f1 = f1.negation(); - f2 = f2.negation(); - } else if (ilabel < 0 && tlabel > 0 && elabel < 0) { // (!a <=> - // b) - // becomes - // !(a - // <=> - // b) - neg = true; - f0 = f0.negation(); - } else if (ilabel < 0 && tlabel < 0 && elabel > 0) {// (!a <=> - // !b) - // becomes - // (a <=> b) - f0 = f0.negation(); - f1 = f1.negation(); - f2 = f2.negation(); - } - } - - final int hash = ITE.hash(f0, f1, f2); - - for (Iterator gates = opCache(ITE).get(hash); gates.hasNext();) { - BooleanFormula gate = gates.next(); - if (gate.input(0) == i && gate.input(1) == t && gate.input(2) == e) - return gate; - } - final BooleanFormula ret = new ITEGate(label++, hash, f0, f1, f2); - opCache(ITE).add(ret); - return neg ? ret.negation() : ret; - } - } - - /** - * Returns a boolean value whose meaning is ([[v0]] op [[v1]]). - * - * @requires v0 + v1 in (this.values + this.values.negation + BooleanConstant) - * @return v: BooleanValue | [[v]] = [[v0]] op [[v1]] - * @ensures v in BooleanFormula - NotGate => this.values' = this.values + v, - * this.values' = this.values - * @throws NullPointerException any of the arguments are null - */ - BooleanValue assemble(Operator.Nary op, BooleanValue v0, BooleanValue v1) { - if (op == OR) { - return assemble(AND, v0.negation(), v1.negation()).negation(); - } - - if (v0 == v1) - return v0; - if (v0.label() == -v1.label()) - return FALSE; - if (v0 == TRUE) - return v1; - if (v1 == TRUE) - return v0; - if (v0 == FALSE) - return FALSE; - if (v1 == FALSE) - return FALSE; - - return cache(op, (BooleanFormula) v0, (BooleanFormula) v1); - } - - /** - * Returns a boolean value with the same meaning as the given accumulator. - * - * @requires acc.components in (this.values + this.values.negation + - * BooleanConstant) - * @return v: BooleanValue | [[v]] = [[acc]] - * @ensures v in BooleanFormula - NotGate => this.values' = this.values + v, - * this.values' = this.values - * @throws NullPointerException any of the arguments are null - */ - BooleanValue assemble(BooleanAccumulator acc) { - final int asize = acc.size(); - final Operator.Nary op = acc.op; - switch (asize) { - case 0 : - return op.identity(); - case 1 : - return acc.iterator().next(); - case 2 : - final Iterator inputs = acc.iterator(); - return assemble(op, inputs.next(), inputs.next()); - default : - final List vals = new LinkedList(); - for (BooleanValue v : acc) { - vals.add(v); - } - while (vals.size() > 1) { - final ListIterator itr = vals.listIterator(); - for (int i = 0, max = vals.size() - 1; i < max; i += 2) { - final BooleanValue v0 = itr.next(); - itr.remove(); - final BooleanValue v1 = itr.next(); - final BooleanValue v0opv1 = assemble(op, v0, v1); - if (v0opv1 == op.shortCircuit()) - return op.shortCircuit(); - else if (v0opv1 == op.identity()) - itr.remove(); - else - itr.set(v0opv1); - } - } - return vals.get(0); - } - } - - /** - * Returns a BooleanFormula f such that [[f]] = f0 op f1. The method requires - * that the formulas f0 and f1 be already reduced with respect to op. A new - * formula is created and cached iff the circuit with the meaning [[f0]] op - * [[f1]] has not already been created. - * - * @requires f0 and f1 have already been reduced with respect to op; i.e. f0 op - * f1 cannot be reduced to a constant or a simple circuit by applying - * absorption, idempotence, etc. laws to f0 and f1. - * @return f : BooleanFormula | [[f]] = [[f0]] op [[f1]] - * @ensures f !in this.values => this.values' = this.values + f, this.values' = - * this.values - */ - private BooleanFormula cache(Operator.Nary op, BooleanFormula f0, BooleanFormula f1) { - final BooleanFormula l, h; - if (f0.label() < f1.label()) { - l = f0; - h = f1; - } else { - l = f1; - h = f0; - } - final int hash = op.hash(l, h); - for (Iterator gates = opCache(op).get(hash); gates.hasNext();) { - BooleanFormula gate = gates.next(); - if (gate.size() == 2 && gate.input(0) == l && gate.input(1) == h) - return gate; - } - final BooleanFormula ret = new BinaryGate(op, label++, hash, l, h); - opCache(op).add(ret); - return ret; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/TwosComplementInt.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/TwosComplementInt.java deleted file mode 100644 index d01ec64f2..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/TwosComplementInt.java +++ /dev/null @@ -1,949 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.bool; - -import static kodkod.engine.bool.BooleanConstant.FALSE; -import static kodkod.engine.bool.BooleanConstant.TRUE; -import static kodkod.engine.bool.Operator.AND; -import static kodkod.engine.bool.Operator.OR; - -import java.util.AbstractList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import kodkod.ast.Variable; -import kodkod.engine.config.Options.OverflowPolicy; -import kodkod.engine.fol2sat.Environment; -import kodkod.util.collections.Containers; - -/** - * Two's complement integer representation. Supports comparisons, addition and - * subtraction. Integers are represented in little-endian (least significant bit - * first) order. - * - * @author Emina Torlak - */ -@SuppressWarnings("rawtypes" ) -final class TwosComplementInt extends Int { - - private final BooleanValue[] bits; - - /** - * Constructs a TwosComplementInt out of the given factory and bits. - * - * @requires bits is well formed - * @ensures this.factory' = factory && this.bits' = bits - */ - private TwosComplementInt(BooleanFactory factory, BooleanValue[] bits, BooleanValue overflow, BooleanValue accumOverflow) { - this(factory, bits, Collections. emptySet(), overflow, accumOverflow); - } - - private TwosComplementInt(BooleanFactory factory, BooleanValue[] bits, Collection vars, BooleanValue overflow, BooleanValue accumOverflow) { - super(factory, vars, true); - this.bits = bits; - defCond().setOverflows(overflow, accumOverflow); - } - - /** - * Constructs a TwosComplementInt that represents either 0 or the given number, - * depending on the value of the given bit. - * - * @requires factory.encoding = TWOSCOMPLEMENT && bit in factory.components - * @ensures this.factory' = factory - * @ensures bits is a two's-complement representation of the given number that - * uses the provided bit in place of 1's - */ - TwosComplementInt(BooleanFactory factory, int number, BooleanValue bit) { - super(factory, Collections. emptySet(), true); - final int width = bitwidth(number); - this.bits = new BooleanValue[width]; - for (int i = 0; i < width; i++) { - bits[i] = (number & (1 << i)) == 0 ? FALSE : bit; - } - if (factory.noOverflow != OverflowPolicy.NONE && !checkBounds(number)) { - defCond().setOverflows(TRUE, TRUE); - } - } - - /** - * Checks whether a given integer literal is representable using only - * this.factory.bitwidth bits. - */ - private boolean checkBounds(int num) { - return num >= minInt() && num <= maxInt(); - } - - /** - * Returns the min int representable using only - * this.factory.bitwidth bits. - */ - private int minInt() { - return -(1 << (factory.bitwidth - 1)); - } - - /** - * Returns the max int representable using only - * this.factory.bitwidth bits. - */ - private int maxInt() { - return (1 << (factory.bitwidth - 1)) - 1; - } - - /** - * ORs overflow circuits of this object ( - * this.mergedOverflow), a given other object ( - * other.mergedOverflow), and a given overflow circuit ( - * of) - */ - private BooleanValue mergeOverflows(Int other, BooleanValue of) { - if (factory.noOverflow == OverflowPolicy.NONE) - return FALSE; - return DefCond.merge(factory, of, defCond(), other.defCond()); - } - - /** - * Returns the number of bits needed/allowed to represent the given number. - * - * @return the number of bits needed/allowed to represent the given number. - */ - private int bitwidth(int number) { - if (number > 0) - return StrictMath.min(33 - Integer.numberOfLeadingZeros(number), factory.bitwidth); - else if (number < 0) - return StrictMath.min(33 - Integer.numberOfLeadingZeros(~number), factory.bitwidth); - else // number = 0 - return 1; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#isConstant() - */ - @Override - public final boolean isConstant() { - for (int i = width() - 1; i >= 0; i--) { - BooleanValue b = bit(i); - if (b != TRUE && b != FALSE) - return false; - } - return true; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#twosComplementBits() - */ - @Override - public final List twosComplementBits() { - return new AbstractList() { - - @Override - public BooleanValue get(int i) { - if (i < 0 || i >= factory.bitwidth) - throw new IndexOutOfBoundsException(); - return bit(i); - } - - @Override - public int size() { - return factory.bitwidth; - } - }; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#width() - */ - @Override - public int width() { - return bits.length; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#value() - */ - @Override - public final int value() { - int ret = 0; - final int max = bits.length - 1; - for (int i = 0; i < max; i++) { - if (bits[i] == TRUE) - ret += 1 << i; - else if (bits[i] != FALSE) - throw new IllegalStateException(this + " is not constant."); - } - if (bits[max] == TRUE) - ret -= 1 << max; - else if (bits[max] != FALSE) - throw new IllegalStateException(this + " is not constant."); - return ret; - } - - /** - * Returns the BooleanValue at the specified index. - * - * @requires 0 <= i < this.factory.bitwidth - * @return this.bits[i] - */ - @Override - public final BooleanValue bit(int i) { - return bits[StrictMath.min(i, bits.length - 1)]; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#msb(kodkod.engine.bool.Int) - */ - @Override - public final BooleanValue msb() { - return bits[bits.length - 1]; - } - - /** - * If overflow checking is disabled returns value. Otherwise, - * returns a conjunction of value, lhs.accumOverflow, - * and rhs.accumOverflow. ~~~ NOTE ~~~: Every time a BooleanValue - * is returned as a result of an operation over Ints, one of the - * ensureNoOverflow methods should be called. - */ - private BooleanValue ensureNoOverflow(Environment env, BooleanValue value, Int... ints) { - IDefCond[] dcs = new IDefCond[ints.length]; - for (int i = 0; i < ints.length; i++) - dcs[i] = ints[i].defCond(); - return DefCond.ensureDef(factory, env, value, dcs); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#eq(kodkod.engine.bool.Int) - */ - @Override - public final BooleanValue eq(Int other, Environment env) { - BooleanValue ret = eqWithoutOverflow(other); - return ensureNoOverflow(env, ret, this, other); - } - - @Override - public final BooleanValue neq(Int other, Environment env) { - BooleanValue ret = factory.not(eqWithoutOverflow(other)); - return ensureNoOverflow(env, ret, this, other); - } - - private BooleanValue eqWithoutOverflow(Int other) { - validate(other); - final BooleanAccumulator cmp = BooleanAccumulator.treeGate(AND); - for (int i = 0, width = StrictMath.max(width(), other.width()); i < width; i++) { - if (cmp.add(factory.iff(bit(i), other.bit(i))) == FALSE) - return FALSE; - } - BooleanValue ret = factory.accumulate(cmp); - return ret; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#lt(kodkod.engine.bool.Int) - */ - @Override - public final BooleanValue lt(Int other, Environment env) { - final BooleanValue leq = lte(other); - final BooleanAccumulator acc = BooleanAccumulator.treeGate(OR); - for (int i = 0, width = StrictMath.max(width(), other.width()); i < width; i++) { - acc.add(factory.xor(bit(i), other.bit(i))); - } - BooleanValue ret = factory.and(leq, factory.accumulate(acc)); - return ensureNoOverflow(env, ret, this, other); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#lte(kodkod.engine.bool.Int) - */ - @Override - public BooleanValue lte(Int other, Environment env) { - validate(other); - final BooleanAccumulator cmp = BooleanAccumulator.treeGate(Operator.AND); - final int last = StrictMath.max(width(), other.width()) - 1; - cmp.add(factory.implies(other.bit(last), bit(last))); - BooleanValue prevEquals = factory.iff(bit(last), other.bit(last)); - for (int i = last - 1; i >= 0; i--) { - BooleanValue v0 = bit(i), v1 = other.bit(i); - cmp.add(factory.implies(prevEquals, factory.implies(v0, v1))); - prevEquals = factory.and(prevEquals, factory.iff(v0, v1)); - } - BooleanValue ret = factory.accumulate(cmp); - return ensureNoOverflow(env, ret, this, other); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#plus(kodkod.engine.bool.Int) - */ - @Override - public Int plus(Int other) { - validate(other); - final int width = StrictMath.min(StrictMath.max(width(), other.width()) + 1, factory.bitwidth); - final BooleanValue[] plus = new BooleanValue[width]; - BooleanValue carry = FALSE; - BooleanValue c1 = FALSE; - BooleanValue c2 = FALSE; - for (int i = 0; i < width; i++) { - BooleanValue v0 = bit(i), v1 = other.bit(i); - plus[i] = factory.sum(v0, v1, carry); - carry = factory.carry(v0, v1, carry); - if (i == width - 2) - c2 = carry; - else if (i == width - 1) - c1 = carry; - } - BooleanValue overflow = FALSE; - BooleanValue accumOF = FALSE; - if (width == factory.bitwidth && factory.noOverflow != OverflowPolicy.NONE) { - overflow = factory.xor(c1, c2); - accumOF = mergeOverflows(other, overflow); - } - return new TwosComplementInt(factory, plus, unionVars(this, other), overflow, accumOF); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#minus(kodkod.engine.bool.Int) - */ - @Override - public Int minus(Int other) { - validate(other); - final int width = StrictMath.min(StrictMath.max(width(), other.width()) + 1, factory.bitwidth); - final BooleanValue[] minus = new BooleanValue[width]; - BooleanValue carry = TRUE; - BooleanValue c1 = FALSE; - BooleanValue c2 = FALSE; - for (int i = 0; i < width; i++) { - BooleanValue v0 = bit(i), v1 = other.bit(i).negation(); - minus[i] = factory.sum(v0, v1, carry); - carry = factory.carry(v0, v1, carry); - if (i == width - 2) - c2 = carry; - else if (i == width - 1) - c1 = carry; - } - BooleanValue overflow = FALSE; - BooleanValue accumOF = FALSE; - if (width == factory.bitwidth && factory.noOverflow != OverflowPolicy.NONE) { - overflow = factory.xor(c1, c2); - accumOF = mergeOverflows(other, overflow); - } - return new TwosComplementInt(factory, minus, unionVars(this, other), overflow, accumOF); - } - - /** - * Adds the newBit and the given carry to this.bits[index] and returns the new - * carry. - * - * @requires 0 <= index < this.width - * @ensures this.bits'[index] = this.factory.sum(this.bits[index], newBit, cin) - * @return this.factory.carry(this.bits[index], newBit, cin) - */ - private BooleanValue addAndCarry(int index, BooleanValue newBit, BooleanValue cin) { - BooleanValue oldBit = bits[index]; - bits[index] = factory.sum(oldBit, newBit, cin); - return factory.carry(oldBit, newBit, cin); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#multiply(kodkod.engine.bool.Int) - */ - // [AM] TODO: not optimal, uses double precision (too many bits)! - @Override - public Int multiply(Int other) { - validate(other); - final int retWidth = width() + other.width(); - final BooleanValue[] mult = new BooleanValue[retWidth]; - final Set unionVars = unionVars(this, other); - final TwosComplementInt ret = new TwosComplementInt(factory, mult, unionVars, FALSE, FALSE); - - /* first partial sum */ - BooleanValue iBit = bit(0); - for (int j = 0; j < retWidth; j++) { - mult[j] = factory.and(iBit, other.bit(j)); - } - - /* intermediate partial sums */ - int last = retWidth - 1; - for (int i = 1; i < last; i++) { - iBit = this.bit(i); - BooleanValue carry = FALSE; - for (int j = 0; j < retWidth - i; j++) { - BooleanValue bit = factory.and(iBit, other.bit(j)); - carry = ret.addAndCarry(i + j, bit, carry); - } - } - - /* - * last partial sum is subtracted (see - * http://en.wikipedia.org/wiki/Multiplication_ALU) - */ - iBit = this.bit(last); - BooleanValue carry = TRUE; - for (int j = 0; j < retWidth - last; j++) { - BooleanValue bit = factory.and(iBit, other.bit(j)).negation(); - carry = ret.addAndCarry(last + j, bit, carry); - } - - final int width = StrictMath.min(mult.length, factory.bitwidth); - final BooleanValue[] multTrunc = new BooleanValue[width]; - for (int i = 0; i < multTrunc.length; i++) - multTrunc[i] = mult[i]; - - BooleanValue overflow = FALSE; - BooleanValue accumOF = FALSE; - if (factory.noOverflow != OverflowPolicy.NONE) { - BooleanAccumulator acc = BooleanAccumulator.treeGate(Operator.OR); - for (int i = multTrunc.length; i < mult.length; i++) { - acc.add(factory.xor(mult[i - 1], mult[i])); - } - overflow = factory.accumulate(acc); - accumOF = mergeOverflows(other, overflow); - } - return new TwosComplementInt(factory, multTrunc, unionVars, overflow, accumOF); - } - - // @Override - public Int multiply_no_overflow_detection(Int other) { - validate(other); - final int width = StrictMath.min(width() + other.width(), factory.bitwidth); - final BooleanValue[] mult = new BooleanValue[width]; - final TwosComplementInt ret = new TwosComplementInt(factory, mult, unionVars(this, other), FALSE, FALSE); - - /* first partial sum */ - BooleanValue iBit = bit(0), carry; - for (int j = 0; j < width; j++) { - mult[j] = factory.and(iBit, other.bit(j)); - } - - final int last = width - 1; - /* intermediate partial sums */ - for (int i = 1; i < last; i++) { - carry = FALSE; - iBit = bit(i); - for (int j = 0, jmax = width - i; j < jmax; j++) { - carry = ret.addAndCarry(j + i, factory.and(iBit, other.bit(j)), carry); - } - } - - /* - * last partial sum is subtracted (see - * http://en.wikipedia.org/wiki/Multiplication_ALU) - */ - ret.addAndCarry(last, factory.and(this.bit(last), other.bit(0)).negation(), TRUE); - return ret; - } - - /** - * Returns an array of BooleanValues that represents the same integer as this, - * but using extwidth bits. - * - * @requires extwidth >= this.width() - * @return an array of BooleanValues that represents the same integer as this, - * but using extwidth bits. - */ - private BooleanValue[] extend(int extwidth) { - final BooleanValue[] ext = new BooleanValue[extwidth]; - final int width = width(); - for (int i = 0; i < width; i++) { - ext[i] = bits[i]; - } - final BooleanValue sign = bits[width - 1]; - for (int i = width; i < extwidth; i++) { - ext[i] = sign; - } - return ext; - } - - /** - * Performs non-restoring signed division of this and the given integer. Returns - * the this.factory.bitwidth low-order bits of the quotient if the quotient flag - * is true; otherwise returns the this.factory.bitwidth low-order bits of the - * remainder. Both the quotionent and the remainder are given in little endian - * format. - * - * @see Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Designs, - * Oxford University Press, 2000, pp. 218-221. - * @requires this.factory = d.factory && d instanceof BinaryInt - * @return an array of boolean values, as described above - */ - private BooleanValue[] nonRestoringDivision(Int d, boolean quotient) { - final int width = factory.bitwidth, extended = width * 2 + 1; - - // extend the dividend to bitwidth*2 + 1 and store it in s; the quotient - // will have width digits - final BooleanValue[] s = this.extend(extended), q = new BooleanValue[width]; - - // detects if one of the intermediate remainders is zero - final BooleanValue[] svalues = new BooleanValue[width]; - - BooleanValue carry, sbit, qbit, dbit; - - // the sign bit of the divisor - final BooleanValue dMSB = d.bit(width); - - int sleft = 0; // the index which contains the LSB of s - for (int i = 0; i < width; i++) { - svalues[i] = factory.accumulate(BooleanAccumulator.treeGate(Operator.OR, s)); - int sright = (sleft + extended - 1) % extended; // the index which - // contains the MSB - // of s - - // q[width-i-1] is 1 if sign(s_(i)) = sign(d), otherwise it is 0 - qbit = factory.iff(s[sright], dMSB); - q[width - i - 1] = qbit; - - // shift s to the left by 1 -- simulated by setting sright to FALSE - // and sleft to sright - s[sright] = FALSE; - sleft = sright; - - // if sign(s_(i)) = sign(d), form s_(i+1) by subtracting (2^width)d - // from s_(i); - // otherwise, form s_(i+1) by adding (2^width)d to s_(i). - carry = qbit; - for (int di = 0, si = (sleft + width) % extended; di <= width; di++, si = (si + 1) % extended) { - dbit = factory.xor(qbit, d.bit(di)); - sbit = s[si]; - s[si] = factory.sum(sbit, dbit, carry); - carry = factory.carry(sbit, dbit, carry); - } - } - - // s[0..width] holds the width+1 high order bits of s - assert (sleft + width) % extended == 0; - - // correction needed if one of the intermediate remainders is zero - // or s is non-zero and its sign differs from the sign of the dividend - final BooleanValue incorrect = factory.or(factory.not(factory.accumulate(BooleanAccumulator.treeGate(Operator.AND, svalues))), factory.and(factory.xor(s[width], this.bit(width)), factory.accumulate(BooleanAccumulator.treeGate(Operator.OR, s)))); - final BooleanValue corrector = factory.iff(s[width], d.bit(width)); - - if (quotient) { // convert q to 2's complement, correct it if s is - // nonzero, and return - - // convert q to 2's complement: shift to the left by 1 and set LSB - // to TRUE - System.arraycopy(q, 0, q, 1, width - 1); - q[0] = TRUE; - - // correct if incorrect evaluates to true as follows: if corrector - // evaluates to true, - // increment q; otherwise decrement q. - final BooleanValue sign = factory.and(incorrect, factory.not(corrector)); - carry = factory.and(incorrect, corrector); - - for (int i = 0; i < width; i++) { - qbit = q[i]; - q[i] = factory.sum(qbit, sign, carry); - carry = factory.carry(qbit, sign, carry); - } - - return q; - } else { // correct s if non-zero and return - - // correct if incorrect evaluates to true as follows: if corrector - // evaluates to true, - // subtract (2^width)d from s; otherwise add (2^width)d to s - carry = factory.and(incorrect, corrector); - - for (int i = 0; i <= width; i++) { - dbit = factory.and(incorrect, factory.xor(corrector, d.bit(i))); - sbit = s[i]; - s[i] = factory.sum(sbit, dbit, carry); - carry = factory.carry(sbit, dbit, carry); - } - - final BooleanValue[] r = new BooleanValue[width]; - System.arraycopy(s, 0, r, 0, width); - return r; - } - - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#divide(kodkod.engine.bool.Int) - */ - @Override - public Int divide(Int other) { - validate(other); - TwosComplementInt ret = new TwosComplementInt(factory, nonRestoringDivision(other, true), unionVars(this, other), FALSE, FALSE); - BooleanValue divByZero = other.eq(factory.integer(0)); - BooleanValue singleOverflowCase = factory.and(this.eq(factory.integer(-(1 << (factory.bitwidth - 1)))), other.eq(factory.integer(-1))); - BooleanValue overflow = factory.or(divByZero, singleOverflowCase); - BooleanValue accumOF = mergeOverflows(other, overflow); - ret.defCond().setOverflows(overflow, accumOF); - return ret; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#modulo(kodkod.engine.bool.Int) - */ - @Override - public Int modulo(Int other) { - validate(other); - TwosComplementInt ret = new TwosComplementInt(factory, nonRestoringDivision(other, false), unionVars(this, other), FALSE, FALSE); - BooleanValue divByZero = other.eq(factory.integer(0)); - BooleanValue accumOF = mergeOverflows(other, divByZero); - ret.defCond().setOverflows(FALSE, accumOF); - return ret; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#choice(kodkod.engine.bool.BooleanValue, - * kodkod.engine.bool.Int) - */ - @Override - public Int choice(BooleanValue condition, Int other) { - validate(other); - final int width = StrictMath.max(width(), other.width()); - final BooleanValue[] choice = new BooleanValue[width]; - for (int i = 0; i < width; i++) { - choice[i] = factory.ite(condition, bit(i), other.bit(i)); - } - BooleanValue of = factory.ite(condition, defCond().getOverflow(), other.defCond().getOverflow()); - BooleanValue accumOF = factory.ite(condition, defCond().getAccumOverflow(), other.defCond().getAccumOverflow()); - return new TwosComplementInt(factory, choice, unionVars(this, other), of, accumOF); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#and(kodkod.engine.bool.Int) - */ - @Override - public Int and(Int other) { - validate(other); - final int width = StrictMath.max(width(), other.width()); - final BooleanValue[] and = new BooleanValue[width]; - for (int i = 0; i < width; i++) { - and[i] = factory.and(bit(i), other.bit(i)); - } - Set unionVars = unionVars(this, other); - return new TwosComplementInt(factory, and, unionVars, FALSE, mergeOverflows(other, FALSE)); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#or(kodkod.engine.bool.Int) - */ - @Override - public Int or(Int other) { - validate(other); - final int width = StrictMath.max(width(), other.width()); - final BooleanValue[] or = new BooleanValue[width]; - for (int i = 0; i < width; i++) { - or[i] = factory.or(bit(i), other.bit(i)); - } - return new TwosComplementInt(factory, or, unionVars(this, other), FALSE, mergeOverflows(other, FALSE)); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#xor(kodkod.engine.bool.Int) - */ - @Override - public Int xor(Int other) { - validate(other); - final int width = StrictMath.max(width(), other.width()); - final BooleanValue[] xor = new BooleanValue[width]; - for (int i = 0; i < width; i++) { - xor[i] = factory.xor(bit(i), other.bit(i)); - } - return new TwosComplementInt(factory, xor, unionVars(this, other), FALSE, mergeOverflows(other, FALSE)); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#shl(kodkod.engine.bool.Int) - */ - @Override - public Int shl(Int other) { - validate(other); - final int width = factory.bitwidth; - final TwosComplementInt shifted = new TwosComplementInt(factory, extend(width), unionVars(this, other), FALSE, FALSE); - final int max = 32 - Integer.numberOfLeadingZeros(width - 1); - BooleanAccumulator acc = BooleanAccumulator.treeGate(Operator.OR); - for (int i = 0; i < width; i++) { - int shift = 1 << i; - BooleanValue bit = other.bit(i); - // overflow: check if the bits being pushed out is different from - // the one immediately to the right of it - for (int x = 0; x < shift; x++) { - BooleanValue b1 = width - x - 1 < 0 ? FALSE : shifted.bit(width - x - 1); - BooleanValue b2 = width - x - 2 < 0 ? FALSE : shifted.bit(width - x - 2); - if (factory.noOverflow != OverflowPolicy.NONE) - acc.add(factory.ite(bit, factory.xor(b1, b2), FALSE)); - } - if (i < max) { - for (int j = width - 1; j >= 0; j--) { - shifted.bits[j] = factory.ite(bit, j < shift ? FALSE : shifted.bit(j - shift), shifted.bits[j]); - } - } - } - if (factory.noOverflow != OverflowPolicy.NONE) { - BooleanValue overflow = factory.accumulate(acc); - BooleanValue accumOF = mergeOverflows(other, overflow); - shifted.defCond().setOverflows(overflow, accumOF); - } - return shifted; - } - - /** - * Performs a right shift with the given extension. - */ - private Int shr(Int other, BooleanValue sign) { - validate(other); - final int width = factory.bitwidth; - final TwosComplementInt shifted = new TwosComplementInt(factory, extend(width), unionVars(this, other), FALSE, FALSE); - final int max = 32 - Integer.numberOfLeadingZeros(width - 1); - for (int i = 0; i < max; i++) { - int shift = 1 << i; - int fill = width - shift; - BooleanValue bit = other.bit(i); - for (int j = 0; j < width; j++) { - shifted.bits[j] = factory.ite(bit, j < fill ? shifted.bit(j + shift) : sign, shifted.bits[j]); - } - } - shifted.defCond().setOverflows(FALSE, mergeOverflows(other, FALSE)); - return shifted; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#shr(kodkod.engine.bool.Int) - */ - @Override - public Int shr(Int other) { - return shr(other, FALSE); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#sha(kodkod.engine.bool.Int) - */ - @Override - public Int sha(Int other) { - return shr(other, bits[bits.length - 1]); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#negate() - */ - @Override - public Int negate() { - return (new TwosComplementInt(factory, new BooleanValue[] { - FALSE - }, FALSE, FALSE)).minus(this); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#not() - */ - @Override - public Int not() { - final int width = width(); - final BooleanValue[] inverse = new BooleanValue[width]; - for (int i = 0; i < width; i++) { - inverse[i] = factory.not(bits[i]); - } - return new TwosComplementInt(factory, inverse, defCond().vars(), FALSE, defCond().getAccumOverflow()); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#abs() - */ - @Override - public Int abs() { - Int negated = negate(); - return choice(factory.not(bits[bits.length - 1]), negated); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#sgn() - */ - @Override - public Int sgn() { - final BooleanValue[] sgn = new BooleanValue[2]; - sgn[0] = factory.accumulate(BooleanAccumulator.treeGate(Operator.OR, bits)); - sgn[1] = bits[bits.length - 1]; - return new TwosComplementInt(factory, sgn, defCond().vars(), FALSE, defCond().getAccumOverflow()); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "b" + Arrays.toString(bits); - } - - /** - * If the plus flag is true, returns a sum of this and other ints, with a - * cascade of adders or logarithmic depth. If the plus flag is false, returns a - * product of this and other ints, with a cascade of multipliers of logarithmic - * depth. - * - * @return plus => PLUS(this, others) else MULTIPLY(this, others) - */ - private Int apply(boolean plus, Int... others) { - final Int[] ints = Containers.copy(others, 0, new Int[others.length + 1], 1, others.length); - ints[0] = this; - for (int part = ints.length; part > 1; part -= part / 2) { - final int max = part - 1; - for (int i = 0; i < max; i += 2) { - ints[i / 2] = plus ? ints[i].plus(ints[i + 1]) : ints[i].multiply(ints[i + 1]); - } - if (max % 2 == 0) { // even max => odd number of entries - ints[max / 2] = ints[max]; - } - } - return ints[0]; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#plus(kodkod.engine.bool.Int[]) - */ - @Override - public Int plus(Int... others) { - return apply(true, others); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#multiply(kodkod.engine.bool.Int[]) - */ - @Override - public Int multiply(Int... others) { - return apply(false, others); - } - - /** - * Applies the given nary operator to this and the given ints. - * - * @return op(this, others) - */ - private Int apply(Operator.Nary op, Int... others) { - int width = width(); - for (Int other : others) { - validate(other); - width = Math.max(width, other.width()); - } - final BooleanValue[] bits = new BooleanValue[width]; - final BooleanValue shortCircuit = op.shortCircuit(); - for (int i = 0; i < width; i++) { - final BooleanAccumulator acc = BooleanAccumulator.treeGate(op, bit(i)); - for (Int other : others) { - if (acc.add(other.bit(i)) == shortCircuit) - break; - } - bits[i] = factory.accumulate(acc); - } - - final BooleanValue[] allOverflows = new BooleanValue[others.length + 1]; - final Set allVars = new HashSet(); - allOverflows[0] = defCond().getAccumOverflow(); - allVars.addAll(defCond().vars()); - for (int i = 1; i < allOverflows.length; i++) { - allOverflows[i] = others[i - 1].defCond().getAccumOverflow(); - allVars.addAll(others[i - 1].defCond().vars()); - } - BooleanAccumulator overflowAcc = BooleanAccumulator.treeGate(op, allOverflows); - return new TwosComplementInt(factory, bits, allVars, FALSE, factory.accumulate(overflowAcc)); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#and(kodkod.engine.bool.Int[]) - */ - @Override - public Int and(Int... others) { - return apply(AND, others); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.bool.Int#or(kodkod.engine.bool.Int[]) - */ - @Override - public Int or(Int... others) { - return apply(OR, others); - } - - private static Set emptyVars = Collections.unmodifiableSet(new HashSet()); - - private Set unionVars(Int int1, Int int2) { - if (factory.noOverflow == OverflowPolicy.NONE) - return emptyVars; - Set union = new HashSet(); - union.addAll(int1.defCond().vars()); - union.addAll(int2.defCond().vars()); - return union; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/package.html deleted file mode 100644 index 2bac8bb06..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/package.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -Provides classes for constructing and composing boolean matrices, boolean circuits, and -boolean representations of integers. - -

Package Specification

- -

Contains classes that represent {@linkplain kodkod.engine.bool.BooleanMatrix boolean matrices}, -{@linkplain kodkod.engine.bool.BooleanValue boolean circuits}, and {@linkplain kodkod.engine.bool.Int boolean -representation of integers}. Matrices, circuits, and integers are constructed via factory methods of the - {@linkplain kodkod.engine.bool.BooleanFactory} class.

- -

Related Documentation

- -@see kodkod.engine.bool.BooleanFactory -@see kodkod.engine.bool.BooleanValue -@see kodkod.engine.bool.BooleanMatrix -@see kodkod.engine.bool.Int - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/bool/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/AbstractReporter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/AbstractReporter.java deleted file mode 100644 index ea9346276..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/AbstractReporter.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.config; - -import java.util.List; -import java.util.Set; - -import kodkod.ast.Decl; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.bool.BooleanFormula; -import kodkod.engine.hol.HOLTranslation; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.util.ints.IntSet; - -/** - * A skeleton implementation of the {@link Reporter} interface. The default - * implementation for each method has an empty body.s - * - * @author Emina Torlak - */ -public abstract class AbstractReporter implements Reporter { - - /** - * Constructs a new abstract reporter. - */ - protected AbstractReporter() {} - - /** - * {@inheritDoc} - * - * @see kodkod.engine.config.Reporter#detectingSymmetries(kodkod.instance.Bounds) - */ - @Override - public void detectingSymmetries(Bounds bounds) {} - - /** - * {@inheritDoc} - * - * @see kodkod.engine.config.Reporter#detectedSymmetries(java.util.Set) - */ - @Override - public void detectedSymmetries(Set parts) {} - - /** - * @see kodkod.engine.config.Reporter#generatingSBP() - */ - @Override - public void generatingSBP() {} - - /** - * {@inheritDoc} - * - * @see kodkod.engine.config.Reporter#skolemizing(kodkod.ast.Decl, - * kodkod.ast.Relation, java.util.List) - */ - @Override - public void skolemizing(Decl decl, Relation skolem, List context) {} - - /** - * @see kodkod.engine.config.Reporter#solvingCNF(int, int, int) - */ - @Override - public void solvingCNF(int primaryVars, int vars, int clauses) {} - - /** - * @see kodkod.engine.config.Reporter#optimizingBoundsAndFormula() - */ - @Override - public void optimizingBoundsAndFormula() {} - - /** - * @see kodkod.engine.config.Reporter#translatingToBoolean(kodkod.ast.Formula, - * kodkod.instance.Bounds) - */ - @Override - public void translatingToBoolean(Formula formula, Bounds bounds) {} - - /** - * @see kodkod.engine.config.Reporter#translatingToCNF(kodkod.engine.bool.BooleanFormula) - */ - @Override - public void translatingToCNF(BooleanFormula circuit) {} - - @Override - public void convertingToNNF() {} - - @Override - public void holLoopStart(HOLTranslation tr, Formula formula, Bounds bounds) {} - - @Override - public void holCandidateFound(HOLTranslation tr, Instance candidate) {} - - @Override - public void holVerifyingCandidate(HOLTranslation tr, Instance candidate, Formula checkFormula, Bounds bounds) {} - - @Override - public void holCandidateVerified(HOLTranslation tr, Instance candidate) {} - - @Override - public void holCandidateNotVerified(HOLTranslation tr, Instance candidate, Instance cex) {} - - @Override - public void holFindingNextCandidate(HOLTranslation tr, Formula inc) {} - - @Override - public void holSplitStart(HOLTranslation tr, Formula formula) {} - - @Override - public void holSplitChoice(HOLTranslation tr, Formula formula, Bounds bounds) {} - - @Override - public void holSplitChoiceSAT(HOLTranslation tr, Instance inst) {} - - @Override - public void holSplitChoiceUNSAT(HOLTranslation tr) {} - - @Override - public void holFixpointStart(HOLTranslation tr, Formula formula, Bounds bounds) {} - - @Override - public void holFixpointNoSolution(HOLTranslation tr) {} - - @Override - public void holFixpointFirstSolution(HOLTranslation tr, Instance candidate) {} - - @Override - public void holFixpointIncrementing(HOLTranslation tr, Formula inc) {} - - @Override - public void holFixpointIncrementingOutcome(HOLTranslation tr, Instance next) {} - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/ConsoleReporter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/ConsoleReporter.java deleted file mode 100644 index 87145f87e..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/ConsoleReporter.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.config; - -import java.util.List; -import java.util.Set; - -import kodkod.ast.Decl; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.bool.BooleanFormula; -import kodkod.engine.hol.HOLTranslation; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.util.ints.IntSet; - -/** - * An implementation of the reporter interface that prints messages to the - * standard output stream. - * - * @author Emina Torlak - */ -public final class ConsoleReporter implements Reporter { - - /** - * Constructs a new instance of the ConsoleReporter. - */ - public ConsoleReporter() {} - - /** - * @see kodkod.engine.config.Reporter#generatingSBP() - */ - @Override - public void generatingSBP() { - System.out.println("generating lex-leader symmetry breaking predicate ..."); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.config.Reporter#skolemizing(kodkod.ast.Decl, - * kodkod.ast.Relation, java.util.List) - */ - @Override - public void skolemizing(Decl decl, Relation skolem, List context) { - System.out.println("skolemizing " + decl + ": skolem relation=" + skolem + ", arity=" + skolem.arity()); - } - - /** - * @see kodkod.engine.config.Reporter#solvingCNF(int, int, int) - */ - @Override - public void solvingCNF(int primaryVars, int vars, int clauses) { - System.out.println("solving p cnf " + vars + " " + clauses); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.config.Reporter#detectingSymmetries(kodkod.instance.Bounds) - */ - @Override - public void detectingSymmetries(Bounds bounds) { - System.out.println("detecting symmetries ..."); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.config.Reporter#detectedSymmetries(java.util.Set) - */ - @Override - public void detectedSymmetries(Set parts) { - System.out.println("detected " + parts.size() + " equivalence classes of atoms ..."); - } - - /** - * @see kodkod.engine.config.Reporter#optimizingBoundsAndFormula() - */ - @Override - public void optimizingBoundsAndFormula() { - System.out.println("optimizing bounds and formula (breaking predicate symmetries, inlining, skolemizing) ..."); - } - - /** - * @see kodkod.engine.config.Reporter#translatingToBoolean(kodkod.ast.Formula, - * kodkod.instance.Bounds) - */ - @Override - public void translatingToBoolean(Formula formula, Bounds bounds) { - System.out.println("translating to boolean ..."); - } - - /** - * @see kodkod.engine.config.Reporter#translatingToCNF(kodkod.engine.bool.BooleanFormula) - */ - @Override - public void translatingToCNF(BooleanFormula circuit) { - System.out.println("translating to cnf ..."); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ConsoleReporter"; - } - - @Override - public void convertingToNNF() { - System.out.println("converting to nnf ..."); - - } - - @Override - public void holLoopStart(HOLTranslation tr, Formula formula, Bounds bounds) { - System.out.println(String.format("starting higher-order (%s) search ...", tr)); - } - - @Override - public void holCandidateFound(HOLTranslation tr, Instance candidate) { - System.out.println(String.format(" [%s] candidate found", tr)); - } - - @Override - public void holVerifyingCandidate(HOLTranslation tr, Instance candidate, Formula checkFormula, Bounds bounds) { - System.out.println(String.format(" [%s] verifying candidate", tr)); - } - - @Override - public void holCandidateVerified(HOLTranslation tr, Instance candidate) { - System.out.println(String.format(" [%s] candidate verified", tr)); - } - - @Override - public void holCandidateNotVerified(HOLTranslation tr, Instance candidate, Instance cex) { - System.out.println(String.format(" [%s] counterexample found", tr)); - } - - @Override - public void holFindingNextCandidate(HOLTranslation tr, Formula inc) { - System.out.println(String.format(" [%s] continuing cegis loop", tr.getClass())); - } - - @Override - public void holSplitStart(HOLTranslation tr, Formula formula) { - System.out.println(String.format("starting split (%s) ...", tr)); - } - - @Override - public void holSplitChoice(HOLTranslation tr, Formula formula, Bounds bounds) { - System.out.println(String.format(" [%s] trying choice", tr)); - } - - @Override - public void holSplitChoiceSAT(HOLTranslation tr, Instance interpret) { - System.out.println(String.format(" [%s] choice SAT", tr)); - } - - @Override - public void holSplitChoiceUNSAT(HOLTranslation tr) { - System.out.println(String.format(" [%s] choice UNSAT", tr)); - } - - @Override - public void holFixpointStart(HOLTranslation tr, Formula formula, Bounds bounds) { - System.out.println(String.format(" [%s] fixpoint search started", tr)); - } - - @Override - public void holFixpointNoSolution(HOLTranslation tr) { - System.out.println(String.format(" [%s] no solution", tr)); - } - - @Override - public void holFixpointFirstSolution(HOLTranslation tr, Instance candidate) { - System.out.println(String.format(" [%s] first solution found", tr)); - } - - @Override - public void holFixpointIncrementing(HOLTranslation tr, Formula inc) { - System.out.println(String.format(" [%s] hill climbing", tr)); - } - - @Override - public void holFixpointIncrementingOutcome(HOLTranslation tr, Instance next) { - if (next != null) - System.out.println(String.format(" [%s] climbed one step", tr)); - else - System.out.println(String.format(" [%s] fixpoint reached", tr)); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/Options.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/Options.java deleted file mode 100644 index cbf1c3c68..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/Options.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.config; - -import kodkod.engine.satlab.SATFactory; -import kodkod.util.ints.IntRange; -import kodkod.util.ints.Ints; - -/** - * Stores information about various user-level translation and analysis options. - * It can be used to choose the SAT solver, control symmetry breaking, etc. - * - * @specfield solver: SATFactory // SAT solver factory to use - * @specfield reporter: Reporter // reporter to use - * @specfield symmetryBreaking: int // the amount of symmetry breaking to - * perform - * @specfield sharing: int // the depth to which circuits should be checked for - * equivalence during translation - * @specfield intEncoding: IntEncoding // encoding to use for translating int - * expressions - * @specfield bitwidth: int // the bitwidth to use for integer representation / - * arithmetic - * @specfield skolemDepth: int // skolemization depth - * @specfield ofPolicy: OverflowPolicy // whether to detect and prevent or - * promote overflows. - * @specfield logTranslation: [0..2] // log translation events, default is 0 (no - * logging) - * @specfield coreGranularity: [0..3] // unsat core granularity, default is 0 - * (only top-level conjuncts are considered) - * @specfield allowHOL: boolean // allow higher-order quantification - * @specfield holSome4AllMaxIter: boolean // allow higher-order quantification - * @author Emina Torlak - */ -public final class Options implements Cloneable { - - public static enum OverflowPolicy { - NONE, - PREVENT, - PROMOTE; - - public OverflowPolicy dual; - - static { - NONE.dual = NONE; - PREVENT.dual = PROMOTE; - PROMOTE.dual = PREVENT; - } - } - - private Reporter reporter = new AbstractReporter() {}; - private SATFactory solver = SATFactory.DefaultSAT4J; - private int symmetryBreaking = 20; - private IntEncoding intEncoding = IntEncoding.TWOSCOMPLEMENT; - private int bitwidth = 4; - private int sharing = 3; - private OverflowPolicy ofPolicy = OverflowPolicy.NONE; - private boolean allowHOL = false; - private boolean holFullIncrements = true; - private int holSome4AllMaxIter = -1; - private int holFixpointMaxIter = -1; - private int skolemDepth = 0; - private int logTranslation = 0; - private int coreGranularity = 0; - - // [AM] - public static boolean isDebug() { - return false; // TODO: read from the environment or something - } - - /** - * Constructs an Options object initialized with default values. - * - * @ensures this.solver' = SATFactory.DefaultSAT4J this.reporter' is silent (no - * messages reported) this.symmetryBreaking' = 20 this.sharing' = 3 - * this.intEncoding' = BINARY this.bitwidth' = 4 this.skolemDepth' = 0 - * this.logTranslation' = 0 this.coreGranularity' = 0 this.allowHOL = - * false this.holSome4AllMaxIter = -1 - */ - public Options() {} - - /** - * Returns the value of the solver options. The default is - * SATSolver.DefaultSAT4J. - * - * @return this.solver - */ - public SATFactory solver() { - return solver; - } - - /** - * Sets the solver option to the given value. - * - * @ensures this.solver' = solver - * @throws NullPointerException solver = null - */ - public void setSolver(SATFactory solver) { - if (solver == null) - throw new NullPointerException(); - this.solver = solver; - } - - /** - * Returns this.reporter. - * - * @return this.reporter - */ - public Reporter reporter() { - return reporter; - } - - /** - * Sets this.reporter to the given reporter. - * - * @requires reporter != null - * @ensures this.reporter' = reporter - * @throws NullPointerException reporter = null - */ - public void setReporter(Reporter reporter) { - if (reporter == null) - throw new NullPointerException(); - this.reporter = reporter; - } - - /** Returns the noOverflow flag */ - public boolean noOverflow() { - return ofPolicy != OverflowPolicy.NONE; - } - - /** Sets the noOverflow flag */ - public void setNoOverflow(boolean noOverflow) { - this.ofPolicy = noOverflow ? OverflowPolicy.PREVENT : OverflowPolicy.NONE; - } - - public OverflowPolicy overflowPolicy() { - return ofPolicy; - } - - public void setOverflowPolicy(OverflowPolicy ofPolicy) { - this.ofPolicy = ofPolicy; - } - - // [HOL]======= - public boolean isAllowHOL() { - return allowHOL; - } - - public void setAllowHOL(boolean allowHOL) { - this.allowHOL = allowHOL; - } - - public boolean isHolFullIncrements() { - return holFullIncrements; - } - - public void setHolFullIncrements(boolean val) { - this.holFullIncrements = val; - } - - public int getHolSome4AllMaxIter() { - return holSome4AllMaxIter; - } - - public void setHolSome4AllMaxIter(int val) { - this.holSome4AllMaxIter = val; - } - - public int getHolFixpointMaxIter() { - return holFixpointMaxIter; - } - - public void setHolFixpointMaxIter(int val) { - this.holFixpointMaxIter = val; - } - // ============ - - /** - * @throws IllegalArgumentException arg !in [min..max] - */ - private void checkRange(int arg, int min, int max) { - if (arg < min || arg > max) - throw new IllegalArgumentException(arg + " !in [" + min + ".." + max + "]"); - } - - /** - * Returns the integer encoding that will be used for translating - * {@link kodkod.ast.IntExpression int nodes}. The default is BINARY - * representation, which allows negative numbers. UNARY representation is best - * suited to problems with small scopes, in which cardinalities are only - * compared (and possibly added to each other or non-negative numbers). - * - * @return this.intEncoding - */ - public IntEncoding intEncoding() { - return intEncoding; - } - - /** - * Sets the intEncoding option to the given value. - * - * @ensures this.intEncoding' = encoding - * @throws NullPointerException encoding = null - * @throws IllegalArgumentException this.bitwidth is not a valid bitwidth for - * the specified encoding - */ - public void setIntEncoding(IntEncoding encoding) { - if (encoding.maxAllowedBitwidth() < bitwidth) - throw new IllegalArgumentException(); - this.intEncoding = encoding; - } - - /** - * Returns the size of the integer representation. For example, if - * this.intEncoding is BINARY and this.bitwidth = 5 (the default), then all - * operations will yield one of the five-bit numbers in the range [-16..15]. If - * this.intEncoding is UNARY and this.bitwidth = 5, then all operations will - * yield one of the numbers in the range [0..5]. - * - * @return this.bitwidth - */ - public int bitwidth() { - return bitwidth; - } - - /** - * Sets this.bitwidth to the given value. - * - * @ensures this.bitwidth' = bitwidth - * @throws IllegalArgumentException bitwidth < 1 - * @throws IllegalArgumentException this.intEncoding==BINARY && bitwidth > 32 - */ - public void setBitwidth(int bitwidth) { - checkRange(bitwidth, 1, intEncoding.maxAllowedBitwidth()); - this.bitwidth = bitwidth; - } - - /** - * Returns the range of integers that can be encoded using this.intEncoding and - * this.bitwidth. - * - * @return range of integers that can be encoded using this.intEncoding and - * this.bitwidth. - */ - public IntRange integers() { - return intEncoding.range(bitwidth); - } - - /** - * Returns the 'amount' of symmetry breaking to perform. If a non-symmetric - * solver is chosen for this.solver, this value controls the maximum length of - * the generated lex-leader symmetry breaking predicate. In general, the higher - * this value, the more symmetries will be broken. But setting the value too - * high may have the opposite effect and slow down the solving. The default - * value for this property is 20. - * - * @return this.symmetryBreaking - */ - public int symmetryBreaking() { - return symmetryBreaking; - } - - /** - * Sets the symmetryBreaking option to the given value. - * - * @ensures this.symmetryBreaking' = symmetryBreaking - * @throws IllegalArgumentException symmetryBreaking !in [0..Integer.MAX_VALUE] - */ - public void setSymmetryBreaking(int symmetryBreaking) { - checkRange(symmetryBreaking, 0, Integer.MAX_VALUE); - this.symmetryBreaking = symmetryBreaking; - } - - /** - * Returns the depth to which circuits are checked for equivalence during - * translation. The default depth is 3, and the minimum allowed depth is 1. - * Increasing the sharing may result in a smaller CNF, but at the cost of slower - * translation times. - * - * @return this.sharing - */ - public int sharing() { - return sharing; - } - - /** - * Sets the sharing option to the given value. - * - * @ensures this.sharing' = sharing - * @throws IllegalArgumentException sharing !in [1..Integer.MAX_VALUE] - */ - public void setSharing(int sharing) { - checkRange(sharing, 1, Integer.MAX_VALUE); - this.sharing = sharing; - } - - /** - * Returns the depth to which existential quantifiers are skolemized. A negative - * depth means that no skolemization is performed. The default depth of 0 means - * that only existentials that are not nested within a universal quantifiers are - * skolemized. A depth of 1 means that existentials nested within a single - * universal are also skolemized, etc. - * - * @return this.skolemDepth - */ - public int skolemDepth() { - return skolemDepth; - } - - /** - * Sets the skolemDepth to the given value. - * - * @ensures this.skolemDepth' = skolemDepth - */ - public void setSkolemDepth(int skolemDepth) { - this.skolemDepth = skolemDepth; - } - - /** - * Returns the translation logging level (0, 1, or 2), where 0 means logging is - * not performed, 1 means only the translations of top level formulas are - * logged, and 2 means all formula translations are logged. This is necessary - * for determining which formulas occur in the unsat core of an unsatisfiable - * formula. Logging is off by default, since it incurs a non-trivial time - * overhead. - * - * @return this.logTranslation - */ - public int logTranslation() { - return logTranslation; - } - - /** - * Sets the translation logging level. - * - * @requires logTranslation in [0..2] - * @ensures this.logTranslation' = logTranslation - * @throws IllegalArgumentException logTranslation !in [0..2] - */ - public void setLogTranslation(int logTranslation) { - checkRange(logTranslation, 0, 2); - this.logTranslation = logTranslation; - } - - /** - * Returns the core granularity level. The default is 0, which means that - * top-level conjuncts of the input formula are used as "roots" for the purposes - * of core minimization and extraction. Granularity of 1 means that the - * top-level conjuncts of the input formula's negation normal form (NNF) are - * used as roots; granularity of 2 means that the top-level conjuncts of the - * formula's skolemized NNF (SNNF) are used as roots; and, finally, a - * granularity of 3 means that the universal quantifiers of the formula's SNNF - * are broken up and that the resulting top-level conjuncts are then used as - * roots for core minimization and extraction. - *

- * Note that the finer granularity (that is, a larger value of - * this.coreGranularity) will provide better information at the cost of slower - * core extraction and, in particular, minimization. - *

- * - * @return this.coreGranularity - */ - public int coreGranularity() { - return coreGranularity; - } - - /** - * Sets the core granularity level. - * - * @requires coreGranularity in [0..3] - * @ensures this.coreGranularity' = coreGranularity - * @throws IllegalArgumentException coreGranularity !in [0..3] - */ - public void setCoreGranularity(int coreGranularity) { - checkRange(coreGranularity, 0, 3); - this.coreGranularity = coreGranularity; - } - - /** - * Returns a shallow copy of this Options object. In particular, the returned - * options shares the same {@linkplain #reporter()} and {@linkplain #solver()} - * factory objects as this Options. - * - * @return a shallow copy of this Options object. - */ - @Override - public Options clone() { - final Options c = new Options(); - c.setSolver(solver); - c.setReporter(reporter); - c.setBitwidth(bitwidth); - c.setIntEncoding(intEncoding); - c.setSharing(sharing); - c.setSymmetryBreaking(symmetryBreaking); - c.setSkolemDepth(skolemDepth); - c.setLogTranslation(logTranslation); - c.setCoreGranularity(coreGranularity); - c.setOverflowPolicy(ofPolicy); - c.setAllowHOL(allowHOL); - c.setHolFullIncrements(holFullIncrements); - c.setHolSome4AllMaxIter(holSome4AllMaxIter); - c.setHolFixpointMaxIter(holFixpointMaxIter); - return c; - } - - /** - * Returns a string representation of this Options object. - * - * @return a string representation of this Options object. - */ - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - b.append("Options:"); - b.append("\n solver: "); - b.append(solver); - b.append("\n reporter: "); - b.append(reporter); - b.append("\n intEncoding: "); - b.append(intEncoding); - b.append("\n bitwidth: "); - b.append(bitwidth); - b.append("\n sharing: "); - b.append(sharing); - b.append("\n symmetryBreaking: "); - b.append(symmetryBreaking); - b.append("\n skolemDepth: "); - b.append(skolemDepth); - b.append("\n logTranslation: "); - b.append(logTranslation); - b.append("\n coreGranularity: "); - b.append(coreGranularity); - b.append("\n noOverflow: "); - b.append(ofPolicy); - b.append("\n allowHOL: "); - b.append(allowHOL); - b.append("\n holFullIncrements: "); - b.append(holFullIncrements); - b.append("\n holSome4AllMaxIter: "); - b.append(holSome4AllMaxIter); - b.append("\n holFixpointMaxIter: "); - b.append(holFixpointMaxIter); - return b.toString(); - } - - /** - * Integer encoding options for the translation of - * {@link kodkod.ast.IntExpression int expressions}. - */ - public static enum IntEncoding { - /** - * Two's-complement encoding of integers supports comparisons, addition, - * subtraction, multiplication, division, and all low-level bit operations - * (shifting, and, or, not, etc.). Maximum allowed bitwidth for this encoding is - * 32 bits. - */ - TWOSCOMPLEMENT { - - @Override - int maxAllowedBitwidth() { - return 32; - } - - @Override - IntRange range(int bitwidth) { - final int shift = bitwidth - 1; - return Ints.range(-1 << shift, (1 << shift) - 1); - } - }; - - /** - * Returns the maximum bitwidth allowed by this encoding. - * - * @return maximum bitwidth allowed by this encoding. - */ - abstract int maxAllowedBitwidth(); - - /** - * Returns the range of integers representable with this encoding using the - * given number of bits. - * - * @requires bitwidth > 0 - * @return range of integers representable with this encoding using the given - * number of bits. - */ - abstract IntRange range(int bitwidth); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/Reporter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/Reporter.java deleted file mode 100644 index 31090f1bb..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/Reporter.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.config; - -import java.util.List; -import java.util.Set; - -import kodkod.ast.Decl; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.bool.BooleanFormula; -import kodkod.engine.hol.HOLTranslation; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.util.ints.IntSet; - -/** - * Enables passing of messages between the kodkod engine and the client about - * the following stages of the analysis: - *
    - *
  1. symmetry detection - *
  2. bounds and formula optimization (breaking of predicate symmetries, - * predicate inlining and skolemization)
  3. - *
  4. translation to a boolean circuit
  5. - *
  6. symmetry breaking predicate (SBP) generation
  7. - *
  8. translation to cnf
  9. - *
  10. running a sat solver on the generated cnf
  11. - *
- * Some of these stages may not be executed, depending on the {@link Options - * options} used for analysis. - * - * @author Emina Torlak - */ -public interface Reporter { - - /** - * Reports that symmetry detection started on the given bounds. The given bounds - * must not be mutated. - */ - public void detectingSymmetries(Bounds bounds); - - /** - * Reports the symmetry partitions that were detected. The given partitions must - * not be mutated. - */ - public void detectedSymmetries(Set parts); - - /** - * Reports that bounds optimization is in progress (stage 2). - */ - public void optimizingBoundsAndFormula(); - - /** - * Reports that the given declaration is being skolemized using the given skolem - * relation. The context list contains non-skolemizable quantified declarations - * on which the given decl depends, in the order of declaration (most recent - * decl is last in the list). - */ - public void skolemizing(Decl decl, Relation skolem, List context); - - /** - * Reports that the analysis of the given (optimized) formula and bounds is in - * stage 3. The given bounds must not be mutated. - * - * @ensures bounds' = bounds - */ - public void translatingToBoolean(Formula formula, Bounds bounds); - - /** - * Reports that the analysis is in stage 4. - */ - public void generatingSBP(); - - /** - * Reports that the given (optimized) circuit is being translated to CNF (stage - * 5 of the analysis). - */ - public void translatingToCNF(BooleanFormula circuit); - - /** - * Reports that the cnf generated in stage 6, consisting of the given number of - * variables and clauses, is being analyzed by a sat solver (stage 7 of the - * analysis). - */ - public void solvingCNF(int primaryVars, int vars, int clauses); - - public void convertingToNNF(); - - public void holLoopStart(HOLTranslation tr, Formula formula, Bounds bounds); - - public void holCandidateFound(HOLTranslation tr, Instance candidate); - - public void holVerifyingCandidate(HOLTranslation tr, Instance candidate, Formula checkFormula, Bounds bounds); - - public void holCandidateVerified(HOLTranslation tr, Instance candidate); - - public void holCandidateNotVerified(HOLTranslation tr, Instance candidate, Instance cex); - - public void holFindingNextCandidate(HOLTranslation tr, Formula inc); - - public void holFixpointStart(HOLTranslation tr, Formula formula, Bounds bounds); - - public void holFixpointNoSolution(HOLTranslation tr); - - public void holFixpointFirstSolution(HOLTranslation tr, Instance candidate); - - public void holFixpointIncrementing(HOLTranslation tr, Formula inc); - - public void holFixpointIncrementingOutcome(HOLTranslation tr, Instance next); - - public void holSplitStart(HOLTranslation tr, Formula formula); - - public void holSplitChoice(HOLTranslation tr, Formula formula, Bounds bounds); - - public void holSplitChoiceSAT(HOLTranslation tr, Instance inst); - - public void holSplitChoiceUNSAT(HOLTranslation tr); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/package.html deleted file mode 100644 index 50a3a06b0..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/package.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - -Provides a mechanism for configuring the kodkod engine and for passing messages -between the engine and the client. - -

Package Specification

- -

Provides a mechanism for configuring the kodkod engine and for passing messages -between the engine and the client. The class {@linkplain kodkod.engine.config.Options} -stores information about various user-level translation and analysis options. It can be -used to choose the SAT solver, control symmetry breaking, etc. The interface -{@linkplain kodkod.engine.config.Reporter} enables passing of messages between the kodkod engine -and the client via callback methods.

- -

Related Documentation

- -@see kodkod.engine.config.Options -@see kodkod.engine.config.Reporter - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/config/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Bool2CNFTranslator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Bool2CNFTranslator.java deleted file mode 100644 index b2cc677b4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Bool2CNFTranslator.java +++ /dev/null @@ -1,494 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import static kodkod.engine.bool.Operator.AND; - -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanFactory; -import kodkod.engine.bool.BooleanFormula; -import kodkod.engine.bool.BooleanVariable; -import kodkod.engine.bool.BooleanVisitor; -import kodkod.engine.bool.ITEGate; -import kodkod.engine.bool.MultiGate; -import kodkod.engine.bool.NotGate; -import kodkod.engine.bool.Operator; -import kodkod.engine.satlab.SATFactory; -import kodkod.engine.satlab.SATSolver; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; - -/** - * Transforms a boolean circuit into a formula in conjunctive normal form. - * - * @specfield factory: {@link BooleanFactory} - * @specfield roots: some factory.components - * @specfield cnf: {@link SATSolver} - * @invariant max(abs(roots.label)) = max(cnf.variables) - * @invariant meaning(roots) = meaning(cnf.clauses) - * @author Emina Torlak - */ -abstract class Bool2CNFTranslator implements BooleanVisitor { - - /** - * Creates a new instance of SATSolver using the provided factory and uses it to - * translate the given circuit into conjunctive normal form using the - * definitional translation algorithm. The {@code maxPrimaryVar} - * parameter is required to contain the maximum label of any primary variable - * allocated during translation from FOL to boolean. This method assumes that - * all variables allocated during translation have contiguous labels. - * - * @requires let boolFactory = components.circuit | boolFactory.maxVariable() = - * maxPrimaryVar && no f: boolFactory.components - BooleanVariable | 1 - * <= f.label <= maxPrimaryVar - * @return some cnf: SATSolver | cnf in factory.instance() && max(cnf.variables) - * = max(abs(circuit.label), maxPrimaryVar) && meaning(circuit) = - * meaning(cnf.clauses) - */ - static SATSolver translate(final BooleanFormula circuit, final int maxPrimaryVar, final SATFactory factory) { - final int maxLiteral = StrictMath.abs(circuit.label()); - final Bool2CNFTranslator translator = new Bool2CNFTranslator(factory.instance()) { - - final PolarityDetector pdetector = (new PolarityDetector(maxPrimaryVar, maxLiteral)).apply(circuit); - - @Override - boolean positive(int label) { - return pdetector.positive(label); - } - - @Override - boolean negative(int label) { - return pdetector.negative(label); - } - }; - return translator.translate(circuit, maxPrimaryVar).solver; - } - - /** - * Creates a new instance of SATSolver using the provided factory and - * initializes it with the trivial translation of the given boolean value. If - * {@code value} is true, the translation is a solver with no variables and no - * clauses. Otherwise, the translation is a solver with no variables and a - * single empty (conflict) clause. - * - * @return some cnf : SATSolver | no cnf.variables && (value.booleanValue() => - * no cnf.clauses else (one cnf.clauses && no cnf.clauses.literals)) - */ - static SATSolver translate(BooleanConstant value, final SATFactory factory) { - final SATSolver cnf = factory.instance(); - if (!value.booleanValue()) { - cnf.addClause(new int[0]); // unsat - } // sat - return cnf; - } - - /** - * Returns a new Bool2CNFTranslator that is initialized with the translation of - * the given circuit. The {@code maxPrimaryVar} parameter is required to contain - * the maximum label of any primary variable allocated during translation from - * FOL to boolean. - * - * @requires let boolFactory = components.circuit | boolFactory.maxVariable() = - * maxPrimaryVar - * @requires factory.incremental - * @return some t: Bool2CNFTranslator | t.roots = circuit && t.factory = - * components.circuit && max(t.cnf.variables) = max(abs(circuit.label), - * maxPrimaryVar) && meaning(circuit) = meaning(t.cnf.clauses) - */ - static Bool2CNFTranslator translateIncremental(final BooleanFormula circuit, final int maxPrimaryVar, final SATFactory factory) { - assert factory.incremental(); - final Bool2CNFTranslator translator = new Bool2CNFTranslator(factory.instance()) {}; - return translator.translate(circuit, maxPrimaryVar); - } - - /** - * Returns a new Bool2CNFTranslator that is initialized with the trivial - * translation of the given boolean value. If {@code value} is true, the - * translation is a solver with no variables and no clauses. Otherwise, the - * translation is a solver with no variables and a single empty (conflict) - * clause. - * - * @requires factory.incremental - * @return some t: Bool2CNFTranslator | t.roots = value && no t.cnf.variables && - * (value.booleanValue() => no t.cnf.clauses else (one t.cnf.clauses && - * no t.cnf.clauses.literals)) - */ - static Bool2CNFTranslator translateIncremental(BooleanConstant value, final SATFactory factory) { - assert factory.incremental(); - return new Bool2CNFTranslator(translate(value, factory)) {}; - } - - /** - * Updates the given Bool2CNFTranslator with the translation of the given - * circuit. The behavior of this method is undefined if it is called after - * translator.solver has returned UNSAT. The {@code maxPrimaryVar} parameter is - * required to contain the maximum label of any primary variable allocated - * during translation from FOL to boolean. - * - * @requires circuit in translator.factory.components - * @requires maxPrimaryVar = translator.factory.maxVariable() - * @requires translator.solver.solve() - * @ensures translator.roots' = translator.roots + circuit && - * max(translator.cnf.variables) = max(abs(circuit.label), - * abs(translator.roots.label), maxPrimaryVar) && - * translator.cnf.clauses in translator.cnf.clauses' && - * translator.cnf.clauses' = CNF(circuit) + translator.cnf.clauses - * @return translator - */ - static Bool2CNFTranslator translateIncremental(final BooleanFormula circuit, final int maxPrimaryVar, final Bool2CNFTranslator translator) { - return translator.translate(circuit, maxPrimaryVar); - } - - private final SATSolver solver; - private final IntSet visited; - private final int[] unaryClause = new int[1]; - private final int[] binaryClause = new int[2]; - private final int[] ternaryClause = new int[3]; - - /** - * Constructs a translator for the given circuit. - * - * @requires no solver.variables && solver.clauses - * @ensures this.solver' = solver - */ - private Bool2CNFTranslator(SATSolver solver) { - this.solver = solver; - this.visited = new IntTreeSet(); - } - - /** - * Applies this translator to the given circuit, adding the translation of the - * circuit to this.solver, and returns the translator. - * - * @requires circuit in this.factory.components - * @requires maxPrimaryVar = this.factory.maxPrimaryVariable() - * @ensures this.solver.variables' = this.solver.variables + { i: int | - * solver.numberOfVariables() < i <= max(abs(circuit.label), - * maxPrimaryVar) } - * @effects this.solver.clauses' = this.solver.clauses + CNF(circuit) - * @return this - */ - private Bool2CNFTranslator translate(BooleanFormula circuit, int maxPrimaryVar) { - final int newVars = Math.max(Math.abs(circuit.label()), maxPrimaryVar) - solver.numberOfVariables(); - // System.out.println("circuit.label=" + Math.abs(circuit.label())); - // System.out.println("maxPrimaryVar=" + maxPrimaryVar); - // System.out.println("solver.vars=" + solver.numberOfVariables()); - if (newVars > 0) - solver.addVariables(newVars); - - if (circuit.op() == Operator.AND) { - for (BooleanFormula input : circuit) { - input.accept(this, null); - } - for (BooleanFormula input : circuit) { - unaryClause[0] = input.label(); - solver.addClause(unaryClause); - } - } else { - solver.addClause(circuit.accept(this, null)); - } - return this; - } - - /** - * Returns this.solver. - * - * @return this.solver - */ - public SATSolver solver() { - return solver; - } - - /** - * Returns true if the gate with the given label occurs (or may occur) - * positively in this.roots. - * - * @requires some f: (MultiGate + ITEGate) & components.(this.roots) | f.label = - * label - * @return true if the gate with the given label occurs (or may occur) - * positively in this.roots - */ - boolean positive(int label) { - return true; - } - - /** - * Returns true if the gate with the given label occurs (or may occur) - * negatively in this.roots. - * - * @requires some f: (MultiGate + ITEGate) & components.(this.roots) | f.label = - * label - * @return true if the gate with the given label occurs (or may occur) - * negatively in this.roots. - */ - boolean negative(int label) { - return true; - } - - /** @return 0->lit */ - private final int[] clause(int lit) { - unaryClause[0] = lit; - return unaryClause; - } - - /** @return 0->lit0 + 1->lit1 */ - private final int[] clause(int lit0, int lit1) { - binaryClause[0] = lit0; - binaryClause[1] = lit1; - return binaryClause; - } - - /** @return 0->lit0 + 1->lit1 + 2->lit2 */ - private final int[] clause(int lit0, int lit1, int lit2) { - ternaryClause[0] = lit0; - ternaryClause[1] = lit1; - ternaryClause[2] = lit2; - return ternaryClause; - } - - /** - * Adds translation clauses to the solver and returns an array containing the - * gate's literal. The CNF clauses are generated according to the standard SAT - * to CNF translation: o = AND(i1, i2, ... ik) ---> (i1 | !o) & (i2 | !o) & ... - * & (ik | !o) & (!i1 | !i2 | ... | !ik | o), o = OR(i1, i2, ... ik) ---> (!i1 | - * o) & (!i2 | o) & ... & (!ik | o) & (i1 | i2 | ... | ik | !o). - * - * @return o: int[] | o.length = 1 && o.[0] = multigate.literal - * @ensures if the multigate has not yet been visited, its children are visited - * and the clauses are added to the solver connecting the multigate's - * literal to its input literal, as described above. - */ - @Override - public final int[] visit(MultiGate multigate, Object arg) { - final int oLit = multigate.label(); - if (visited.add(oLit)) { - final int sgn; - final boolean p, n; - if (multigate.op() == AND) { - sgn = 1; - p = positive(oLit); - n = negative(oLit); - } else { // multigate.op()==OR - sgn = -1; - n = positive(oLit); - p = negative(oLit); - } - final int[] lastClause = n ? new int[multigate.size() + 1] : null; - final int output = oLit * -sgn; - int i = 0; - for (BooleanFormula input : multigate) { - int iLit = input.accept(this, arg)[0]; - if (p) { - solver.addClause(clause(iLit * sgn, output)); - } - if (n) { - lastClause[i++] = iLit * -sgn; - } - } - if (n) { - lastClause[i] = oLit * sgn; - solver.addClause(lastClause); - } - } - return clause(oLit); - } - - /** - * Adds translation clauses to the solver and returns an array containing the - * gate's literal. The CNF clauses are generated according to the standard SAT - * to CNF translation: o = ITE(i, t, e) ---> (!i | !t | o) & (!i | t | !o) & (i - * | !e | o) & (i | e | !o) - * - * @return o: int[] | o.length = 1 && o.[0] = itegate.literal - * @ensures if the itegate has not yet been visited, its children are visited - * and the clauses are added to the solver connecting the multigate's - * literal to its input literal, as described above. - */ - @Override - public final int[] visit(ITEGate itegate, Object arg) { - final int oLit = itegate.label(); - if (visited.add(oLit)) { - final int i = itegate.input(0).accept(this, arg)[0]; - final int t = itegate.input(1).accept(this, arg)[0]; - final int e = itegate.input(2).accept(this, arg)[0]; - final boolean p = positive(oLit), n = negative(oLit); - if (p) { - solver.addClause(clause(-i, t, -oLit)); - solver.addClause(clause(i, e, -oLit)); - // redundant clause that strengthens unit propagation - solver.addClause(clause(t, e, -oLit)); - } - if (n) { - solver.addClause(clause(-i, -t, oLit)); - solver.addClause(clause(i, -e, oLit)); - // redundant clause that strengthens unit propagation - solver.addClause(clause(-t, -e, oLit)); - } - } - return clause(oLit); - } - - /** - * Returns the negation of the result of visiting negation.input, wrapped in an - * array. - * - * @return o: int[] | o.length = 1 && o[0] = - translate(negation.inputs)[0] - */ - @Override - public final int[] visit(NotGate negation, Object arg) { - return clause(-negation.input(0).accept(this, arg)[0]); - } - - /** - * Returns the variable's literal wrapped in a an array. - * - * @return o: int[] | o.length = 1 && o[0] = variable.literal - */ - @Override - public final int[] visit(BooleanVariable variable, Object arg) { - return clause(variable.label()); - } - - /** - * Helper visitor that detects polarity of subformulas. - * - * @specfield root: BooleanFormula // the root of the DAG for whose components - * we are storing pdetector information - */ - private static final class PolarityDetector implements BooleanVisitor { - - final int offset; - /** - * @invariant all i : [0..polarity.length) | pdetector[i] = 0 <=> formula with - * label offset + i has not been visited, pdetector[i] = 1 <=> - * formula with label offset + i has been visited with positive - * pdetector only, pdetector[i] = 2 <=> formula with label offset + i - * has been visited with negative pdetector only, pdetector[i] = 3 - * <=> formula with label offset + i has been visited with both - * polarities - */ - private final int[] polarity; - private final Integer[] ints = { - Integer.valueOf(3), Integer.valueOf(1), Integer.valueOf(2) - }; - - /** - * Creates a new pdetector detector and applies it to the given circuit. This - * constructor assumes that all primary variables have contiguous labels, which - * may not be the case during incremental translation. - * - * @requires maxLiteral = |root.label()| - */ - PolarityDetector(int numPrimaryVars, int maxLiteral) { - this.offset = numPrimaryVars + 1; - this.polarity = new int[StrictMath.max(0, maxLiteral - numPrimaryVars)]; - } - - /** - * Applies this detector to the given formula, and returns this. - * - * @requires this.root = root - * @ensures this.visit(root) - * @return this - */ - PolarityDetector apply(BooleanFormula root) { - root.accept(this, ints[1]); - return this; - } - - /** - * Returns true if the formula with the given label occurs positively in - * this.root. - * - * @requires this visitor has been applied to this.root - * @requires label in (MultiGate + ITEGate).label - * @return true if the formula with the given label occurs positively in - * this.root. - */ - boolean positive(int label) { - return (polarity[label - offset] & 1) > 0; - } - - /** - * Returns true if the formula with the given label occurs negatively in - * this.root. - * - * @requires this visitor has been applied to this.root - * @requires label in (MultiGate + ITEGate).label - * @return true if the formula with the given label occurs negatively in - * this.root. - */ - boolean negative(int label) { - return (polarity[label - offset] & 2) > 0; - } - - /** - * Returns true if the given formula has been visited with the specified - * pdetector (1 = positive, 2 = negative, 3 = both). Otherwise records the visit - * and returns false. - * - * @requires formula in (MultiGate + ITEGate) - * @requires pdetector in this.ints - * @return true if the given formula has been visited with the specified - * pdetector. Otherwise records the visit and returns false. - */ - private boolean visited(BooleanFormula formula, Integer polarity) { - final int index = formula.label() - offset; - final int value = this.polarity[index]; - return (this.polarity[index] = value | polarity) == value; - } - - @Override - public Object visit(MultiGate multigate, Integer arg) { - if (!visited(multigate, arg)) { - for (BooleanFormula input : multigate) { - input.accept(this, arg); - } - } - return null; - } - - @Override - public Object visit(ITEGate ite, Integer arg) { - if (!visited(ite, arg)) { - // the condition occurs both positively and negative in an ITE - // gate - ite.input(0).accept(this, ints[0]); - ite.input(1).accept(this, arg); - ite.input(2).accept(this, arg); - } - return null; - } - - @Override - public Object visit(NotGate negation, Integer arg) { - return negation.input(0).accept(this, ints[3 - arg]); - } - - @Override - public Object visit(BooleanVariable variable, Integer arg) { - return null; // nothing to do - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Environment.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Environment.java deleted file mode 100644 index 5b7ddc76a..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Environment.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import kodkod.ast.Variable; -import kodkod.ast.operator.Quantifier; - -/** - * Represents a variable binding environment as a map from a - * {@link kodkod.ast.Variable variable} to a {@link java.lang.Object value}. An - * environment has a (possibly empty) parent environment to which unsuccessful - * lookups are delegated. - * - * @specfield variable: lone Variable - * @specfield value: lone T - * @specfield type: lone E - * @specfield parent: Environment - * @invariant this = parent => no variable - * @author Emina Torlak - */ -public final class Environment { - - private final Variable variable; - private final T value; - private final E type; - private final Environment parent; - private final Quantifier envType; // may be null, but will - // typically contain - // Quantifier.ALL or - // Quantifier.SOME - - private boolean negated; - - /** - * Constructs the empty environment. - */ - private Environment() { - this.variable = null; - this.value = null; - this.type = null; - this.parent = this; - this.envType = null; - this.negated = false; - } - - /** - * Constructs a new environment with the specified parent and mapping. - * - * @ensures this.parent' = parent && this.variable' = variable && this.value' = - * value - */ - private Environment(Environment parent, Variable variable, E type, T value, Quantifier quant, boolean negated) { - this.variable = variable; - this.value = value; - this.type = type; - this.parent = parent; - this.envType = quant; - this.negated = negated; - } - - /** - * Returns the empty environment. - * - * @return the empty environment. - */ - public static Environment empty() { - return new Environment(); - } - - /** - * Returns the parent environment of this, or null if this does not have a - * parent. - * - * @return this.parent - */ - public Environment parent() { - return parent; - } - - /** - * Returns a new environment that extends this environment with the specified - * mapping. - * - * @requires variable != null - * @return e : Environment | e.parent = this && e.variable = variable && e.value - * = value - */ - public Environment extend(Variable variable, E type, T value) { - return extend(variable, type, value, null); - } - - public Environment extend(Variable variable, E type, T value, Quantifier envType) { - if (envType == null) - return new Environment(this, variable, type, value, envType, false); - Quantifier q = negated ? envType.opposite : envType; - return new Environment(this, variable, type, value, q, negated); - } - - public void negate() { - negated = !negated; - } - - /** - * Returns this.variable. - * - * @return this.variable - */ - public Variable variable() { - return this.variable; - } - - /** - * Return this.type. - * - * @return this.type - */ - public E type() { - return this.type; - } - - /** - * Returns this.value. - * - * @return this.value - */ - public T value() { - return this.value; - } - - /** - * Returns this.quant. - * - * @return this.quant - */ - public Quantifier envType() { - return envType; - } - - public boolean isNegated() { - return negated; - } - - /** - * Returns true if this is the empty (root) environment; otherwise returns - * false. - * - * @return this.parent = this - */ - public boolean isEmpty() { - return this == this.parent; - } - - /** - * Looks up the given variable in this environment and its ancestors. If the - * variable is not bound in this environment or any of its ancestors, null is - * returned. If the variable is bound in multiple environments, the first found - * binding is returned. Note that null will also be returned if the variable is - * bound to null. - * - * @return variable = this.variable => this.value, this.parent.lookup(variable) - */ - public T lookup(Variable variable) { - Environment p = this; - // ok to use == for testing variable equality: - // see kodkod.ast.LeafExpression#equals - while (!p.isEmpty() && p.variable != variable) { - p = p.parent; - } - return p.value; - } - - public E lookupType(Variable variable) { - Environment p = this; - // ok to use == for testing variable equality: - // see kodkod.ast.LeafExpression#equals - while (!p.isEmpty() && p.variable != variable) { - p = p.parent; - } - return p.type; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return (parent.isEmpty() ? "[]" : parent.toString()) + "[" + variable + "=" + value + "]"; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FOL2BoolCache.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FOL2BoolCache.java deleted file mode 100644 index c3fa00607..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FOL2BoolCache.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.util.nodes.AnnotatedNode; - -/** - * Manages the caching policy for a translation from FOL to boolean. In - * particular it determines which translations to cache, when to throw them out - * of the cache, etc. - * - * @specfield node: Node // node being translated - * @specfield cached: node.*children // the nodes whose translations are cached - * @specfield cache: cached -> (Object ->lone Environment) - * @author Emina Torlak - */ -final class FOL2BoolCache { - - private final Map cache; - - /** - * Constructs a new translation cache for the given annotated node. - * - * @ensures this.node' = annotated.node - */ - FOL2BoolCache(AnnotatedNode< ? extends Node> annotated) { - final CacheCollector collector = new CacheCollector(annotated.sharedNodes()); - annotated.node().accept(collector); - - this.cache = new IdentityHashMap(collector.cache().size()); - for (Map.Entry> e : collector.cache().entrySet()) { - Set freeVars = e.getValue(); - if (freeVars.isEmpty()) - this.cache.put(e.getKey(), new NoVarRecord()); - else - this.cache.put(e.getKey(), new MultiVarRecord(freeVars)); - } - } - - /** - * If the translation of the given node, with its free variables bound as they - * are in the given environment, has been cached, the cached value is returned. - * Otherwise, null is returned. - * - * @return this.cache[node][Object] in env.map => this.cache[node].map, null - */ - @SuppressWarnings("unchecked" ) - T lookup(Node node, Environment env) { - final Record info = cache.get(node); - return info == null ? null : (T) info.get(env); - } - - /** - * Caches the given translation for the specified node, if the given node is in - * this.cached. Otherwise does nothing. The method returns the specified - * translation. - * - * @ensures node in this.cached => this.cache' = this.cache ++ - * node->translation->env, this.cache' = this.cache - * @return translation - */ - final T cache(Node node, T translation, Environment env) { - final Record info = cache.get(node); - if (info != null) { - info.set(translation, env); - } - return translation; - } - - /** - * Collects the free variables of the nodes in a given AST whose translations - * should be cached. - * - * @specfield root: Node - * @specfield cached: root.*children -> Set - * @invariant all c: root.*children | some cached[c] => cached[c] = - * freeVariables(c) - * @author Emina Torlak - */ - private static final class CacheCollector extends FreeVariableCollector { - - /** - * Constructs a new cache collector. - */ - protected CacheCollector(Set cached) { - super(cached); - } - - /** - * Returns this.cache. This method should be called *after* the visitor has been - * applied to this.root. - * - * @return this.cache - */ - final Map> cache() { - return cache; - } - - /** - * We record the set of free variables for the given node if the node is shared, - * or if it has free variables, none of which is the most recently declared - * variable. - * - * @ensures node in sharedNodes || ((node.^(~children) in (QuantifiedFormula + - * Comprehension)) && (some varsInScope.top() => - * !freeVars.contains(varsInScope.top()))) => this.cache' = this.cache - * ++ node->varsInScope, this.cache' = this.cache - * @return freeVars - */ - @Override - protected final Set cache(Node node, Set freeVars) { - if (cached.contains(node) || !varsInScope.empty() && !freeVars.contains(varsInScope.peek())) { - cache.put(node, reduce(freeVars)); - } - return freeVars; - } - - } - - /** - * A container class that stores the translation of a shared node (BooleanValue - * for formulas and BooleanMatrix for expressions) and bindings for the node's - * free variables which were used to generate the translation. Storing the - * bindings is necessary for proper handling of sharing within quantified - * formulas and comprehensions. This implementation assumes that each free - * variable is mapped to a BooleanMatrix of density one, whose sole entry is the - * BooleanConstant TRUE. - * - * @specfield varBinding: Variable -> lone int - * @specfield translation: lone Object - */ - private static abstract class Record { - - Object translation; - - /** - * Returns this.translation if the given environment has the same mappings for - * the free variables of the translated node as the ones used to generate - * this.translation. Otherwise returns null. - * - * @requires all v: varBinding.int | some e.lookup(v) - * @return all v: varBinding.int | e.lookup(v).get(varBinding[v])=TRUE => - * this.translation, null - * @throws NullPointerException e = null - */ - abstract Object get(Environment e); - - /** - * Sets this.translation to the given translation and sets the free variable - * bindings to those given by the specified environment. - * - * @requires all v: varBinding.int | some env.lookup(v) - * @ensures this.translation' = translation && this.varBinding' = {v: - * this.varBinding.int, tupleIndex: int | tupleIndex = - * env.lookup(v).iterator().next().index() } - */ - abstract void set(Object transl, Environment env); - } - - /** - * A TranslationInfo for a node with one or more free variables. - */ - private static final class MultiVarRecord extends Record { - - final Variable[] vars; - final int[] tuples; - - /** - * Constructs a translation unit for a node which has the given set of free - * variables. - * - * @ensures this.freeVariables' = vars && no this.translation' - */ - MultiVarRecord(Set freeVariables) { - this.vars = freeVariables.toArray(new Variable[freeVariables.size()]); - this.tuples = new int[freeVariables.size()]; - } - - /** - * @see kodkod.engine.fol2sat.FOL2BoolCache.Record#get(kodkod.engine.fol2sat.Environment) - */ - @Override - Object get(Environment e) { - if (translation == null) - return null; - for (int i = 0; i < vars.length; i++) { - if (e.lookup(vars[i]).get(tuples[i]) != BooleanConstant.TRUE) - return null; - } - return translation; - } - - /** - * @see kodkod.engine.fol2sat.FOL2BoolCache.Record#set(java.lang.Object, - * kodkod.engine.fol2sat.Environment) - */ - @Override - void set(Object transl, Environment env) { - translation = transl; - for (int i = 0; i < vars.length; i++) { - final BooleanMatrix varVal = env.lookup(vars[i]); - tuples[i] = varVal.iterator().next().index(); - if (transl == varVal) { - translation = varVal.clone(); - } - } - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder b = new StringBuilder("{"); - b.append(String.valueOf(translation)); - for (int i = 0; i < vars.length; i++) { - b.append(" ("); - b.append(vars[i]); - b.append(", "); - b.append(tuples[i]); - b.append(")"); - } - b.append("}"); - return b.toString(); - } - } - - /** - * A TranslationInfo for a node with no free variables. - */ - private static final class NoVarRecord extends Record { - - /** - * @see kodkod.engine.fol2sat.FOL2BoolCache.Record#get(kodkod.engine.fol2sat.Environment) - */ - @Override - Object get(Environment e) { - return translation; - } - - /** - * @see kodkod.engine.fol2sat.FOL2BoolCache.Record#set(java.lang.Object, - * kodkod.engine.fol2sat.Environment) - */ - @Override - void set(Object transl, Environment env) { - translation = transl; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "{" + translation + "}"; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FOL2BoolTranslator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FOL2BoolTranslator.java deleted file mode 100644 index b605b9611..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FOL2BoolTranslator.java +++ /dev/null @@ -1,1329 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.LeafExpression; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.ExprCompOperator; -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.engine.bool.BooleanAccumulator; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanFactory; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.BooleanValue; -import kodkod.engine.bool.Dimensions; -import kodkod.engine.bool.Int; -import kodkod.engine.bool.Operator; -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.nodes.AnnotatedNode; -import kodkod.util.nodes.Nodes; - -/** - * Translates an annotated node to boolean representation. - * - * @specfield node: AnnotatedNode // node to translate - * @specfield interpreter: LeafInterpreter // the interpreter used for - * translation - * @specfield env: Environment // current environment - * @author Emina Torlak - */ -abstract class FOL2BoolTranslator implements ReturnVisitor { - - /** - * Translates the given annotated formula or expression into a boolean formula - * or matrix, using the provided interpreter. - * - * @requires interpreter.relations = AnnotatedNode.relations(annotated) - * @return {transl: T | annotated.node in Formula => transl in BooleanValue, - * annotated.node in Expression => transl in BooleanMatrix, - * annotated.node in IntExpression => transl in Int} - * @throws HigherOrderDeclException annotated.node contains a higher order - * declaration - * @throws UnboundLeafException annotated.node refers to an undeclared variable - **/ - @SuppressWarnings("unchecked" ) - static final T translate(AnnotatedNode< ? extends Node> annotated, LeafInterpreter interpreter) { - final FOL2BoolCache cache = new FOL2BoolCache(annotated); - final FOL2BoolTranslator translator = new FOL2BoolTranslator(cache, interpreter) {}; - translator.addSkolems(annotated.skolemRelations()); - return (T) annotated.node().accept(translator); - } - - /** - * Translates the given annotated formula into a boolean accumulator with - * respect to the given interpreter and logs the translation events to the given - * logger. - * - * @requires interpreter.relations = AnnotatedNode.relations(annotated) - * @requires annotated.source[annotated.sourceSensitiveRoots()] = - * Nodes.roots(annotated.source[annotated.node]) - * @return BooleanAccumulator that is the meaning of the given annotated formula - * with respect to the given interpreter - * @ensures log.records' contains the translation events that occurred while - * generating the returned value - * @throws HigherOrderDeclException annotated.node contains a higher order - * declaration - * @throws UnboundLeafException annotated.node refers to an undeclared variable - **/ - static final BooleanAccumulator translate(final AnnotatedNode annotated, LeafInterpreter interpreter, final TranslationLogger logger) { - final FOL2BoolCache cache = new FOL2BoolCache(annotated); - final FOL2BoolTranslator translator = new FOL2BoolTranslator(cache, interpreter) { - - @Override - BooleanValue cache(Formula formula, BooleanValue translation) { - logger.log(formula, translation, super.env); - return super.cache(formula, translation); - } - }; - translator.addSkolems(annotated.skolemRelations()); - final BooleanAccumulator acc = BooleanAccumulator.treeGate(Operator.AND); - - for (Formula root : Nodes.conjuncts(annotated.node())) { - acc.add(root.accept(translator)); - } - logger.close(); - return acc; - } - - /** - * Translates the given annotated expression into a boolean matrix that is a - * least sound upper bound on the expression's value, given the leaf and - * variable bindings in the the provided interpreter and environment. - * - * @requires interpreter.relations = AnnotatedNode.relations(annotated) - * @return a boolean matrix that is a least sound upper bound on the - * expression's value - * @throws HigherOrderDeclException annotated.node contains a higher order - * declaration - * @throws UnboundLeafException annotated.node refers to a variable that neither - * declared nor bound in env - **/ - static final BooleanMatrix approximate(AnnotatedNode annotated, LeafInterpreter interpreter, Environment env) { - final FOL2BoolTranslator approximator = new FOL2BoolTranslator(new FOL2BoolCache(annotated), interpreter, env) { - - @Override - public final BooleanMatrix visit(BinaryExpression binExpr) { - final BooleanMatrix ret = lookup(binExpr); - if (ret != null) - return ret; - switch (binExpr.op()) { - case DIFFERENCE : - return cache(binExpr, binExpr.left().accept(this)); - case OVERRIDE : - return cache(binExpr, binExpr.left().accept(this).or(binExpr.right().accept(this))); - default : - return super.visit(binExpr); - } - } - - @Override - public final BooleanMatrix visit(Comprehension cexpr) { - final BooleanMatrix ret = lookup(cexpr); - return ret != null ? ret : cache(cexpr, super.visit((Comprehension) Formula.TRUE.comprehension(cexpr.decls()))); - } - - @Override - public BooleanMatrix visit(IfExpression ifExpr) { - final BooleanMatrix ret = lookup(ifExpr); - return ret != null ? ret : cache(ifExpr, ifExpr.thenExpr().accept(this).or(ifExpr.elseExpr().accept(this))); - } - - @Override - public BooleanMatrix visit(IntToExprCast castExpr) { - BooleanMatrix ret = lookup(castExpr); - if (ret != null) - return ret; - switch (castExpr.op()) { - case INTCAST : - return cache(castExpr, Expression.INTS.accept(this)); - case BITSETCAST : - final BooleanFactory factory = super.interpreter.factory(); - ret = factory.matrix(Dimensions.square(super.interpreter.universe().size(), 1)); - final IntSet ints = super.interpreter.ints(); - final int msb = factory.bitwidth() - 1; - // handle all bits but the sign bit - for (int i = 0; i < msb; i++) { - int pow2 = 1 << i; - if (ints.contains(pow2)) { - ret.set(super.interpreter.interpret(pow2), BooleanConstant.TRUE); - } - } - // handle the sign bit - if (ints.contains(-1 << msb)) { - ret.set(super.interpreter.interpret(-1 << msb), BooleanConstant.TRUE); - } - return cache(castExpr, ret); - default : - throw new IllegalArgumentException("Unknown operator: " + castExpr.op()); - } - - } - }; - return annotated.node().accept(approximator); - } - - /*---------------------------------------------------------*/ - - private final LeafInterpreter interpreter; - /* - * When visiting the body of a quantified formula or a comprehension, this - * environment contains the current values of the enclosing quantified - * variable(s), as well as overflow circuits accumulated during execution - */ - private Environment env; - - private final FOL2BoolCache cache; - - /* - * Holds variables discovered while visiting an expression to be cast to Int. - * (because, for the new "overflow" semantics of quantifiers, we want to know - * the variables that contribute to every Int - */ - // [AM] - private NestedSet vars = NestedSet.empty(); - - private final Map leafCache; - - /** - * Constructs a new translator that will use the given translation cache and - * interpreter to perform the translation. - * - * @ensures this.node' = manager.node - */ - private FOL2BoolTranslator(FOL2BoolCache cache, LeafInterpreter interpreter) { - this.cache = cache; - this.interpreter = interpreter; - this.env = Environment.empty(); - this.leafCache = new HashMap(64); - } - - /** - * Constructs a new translator that will use the given translation cache, - * interpreter and environment to perform the translation. - * - * @ensures this.node' = manager.node - */ - private FOL2BoolTranslator(FOL2BoolCache cache, LeafInterpreter interpreter, Environment env) { - this.interpreter = interpreter; - this.env = env; - this.cache = cache; - this.leafCache = new HashMap(64); - } - - private void addSkolems(Set skolemRelations) { - // for (Relation r : skolemRelations) { - // env = env.extend(r.getSkolemVar(), r.getSkolemVarDomain(), null, - // r.getSkolemVarQuant()); - // } - } - - /** - * Retrieves the cached translation for the given node, if any. Otherwise - * returns null. - * - * @return the cached translation for the given node, if any. Otherwise returns - * null. - */ - @SuppressWarnings("unchecked" ) - final T lookup(Node node) { - return (T) cache.lookup(node, env); - } - - /** - * The translation is cached, if necessary, and returned. - * - * @return translation - * @ensures the translation may be cached - */ - final T cache(Node node, T translation) { - return cache.cache(node, translation, env); - } - - /** - * The translation is cached, if necessary, and returned. - * - * @return translation - * @ensures the translation may be cached - */ - BooleanValue cache(Formula formula, BooleanValue translation) { - return cache.cache(formula, translation, env); - } - - /** - * Calls lookup(decls) and returns the cached value, if any. If a translation - * has not been cached, translates decls into a list of translations of its - * children, calls cache(...) on it and returns it. - * - * @return let t = lookup(decls) | some t => t, cache(decl, - * decls.declarations.expression.accept(this)) - */ - @Override - public final List visit(Decls decls) { - List ret = lookup(decls); - if (ret != null) - return ret; - ret = new ArrayList(decls.size()); - for (Decl decl : decls) { - ret.add(visit(decl)); - } - return cache(decls, ret); - } - - /** - * Calls lookup(decl) and returns the cached value, if any. If a translation has - * not been cached, translates decl.expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(decl) | some t => t, cache(decl, - * decl.expression.accept(this)) - */ - @Override - public final BooleanMatrix visit(Decl decl) { - BooleanMatrix matrix = lookup(decl); - if (matrix != null) - return matrix; - if (decl.multiplicity() != Multiplicity.ONE) - throw new HigherOrderDeclException(decl); - return cache(decl, decl.expression().accept(this)); - } - - /** - * Calls this.env.lookup(variable) and returns the current binding for the given - * variable and adds it to the current level of nested variables - * (cars). If no binding is found, an UnboundLeafException is - * thrown. - * - * @return this.env.lookup(variable) - * @throws UnboundLeafException no this.env.lookup(variable) - */ - @Override - public final BooleanMatrix visit(Variable variable) { - final BooleanMatrix ret = env.lookup(variable); - if (ret == null) - throw new UnboundLeafException("Unbound variable", variable); - vars.add(variable); - return ret; - } - - /** - * Returns this.interpreter.interpret(relation). - * - * @return this.interpreter.interpret(relation) - */ - @Override - public final BooleanMatrix visit(Relation relation) { - BooleanMatrix ret = leafCache.get(relation); - if (relation.isSkolem()) - vars.add(relation.getSkolemVar()); - if (ret == null) { - ret = interpreter.interpret(relation); - leafCache.put(relation, ret); - } - return ret; - } - - /** - * Returns this.interpreter.interpret(constExpr). - * - * @return this.interpreter.interpret(constExpr). - */ - @Override - public final BooleanMatrix visit(ConstantExpression constExpr) { - BooleanMatrix ret = leafCache.get(constExpr); - if (ret == null) { - ret = interpreter.interpret(constExpr); - leafCache.put(constExpr, ret); - } - return ret; - } - - /** - * Calls lookup(binExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(binExpr) | some t => t, let op = - * (binExpr.op).(UNION->or + INTERSECTION->and + DIFFERENCE->difference - * + OVERRIDE->override + JOIN->dot + PRODUCT->cross) | cache(binExpr, - * op(binExpr.left.accept(this), binExpr.right.accept(this))) - */ - @Override - public BooleanMatrix visit(BinaryExpression binExpr) { - BooleanMatrix ret = lookup(binExpr); - if (ret != null) - return ret; - - final BooleanMatrix left = binExpr.left().accept(this); - final BooleanMatrix right = binExpr.right().accept(this); - final ExprOperator op = binExpr.op(); - - switch (op) { - case UNION : - ret = left.or(right); - break; - case INTERSECTION : - ret = left.and(right); - break; - case DIFFERENCE : - ret = left.difference(right); - break; - case OVERRIDE : - ret = left.override(right); - break; - case JOIN : - ret = left.dot(right); - break; - case PRODUCT : - ret = left.cross(right); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + op); - } - - return cache(binExpr, ret); - } - - /** - * Calls lookup(expr) and returns the cached value, if any. If a translation has - * not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(expr) | some t => t, let op = (expr.op).(UNION->or + - * INTERSECTION->and + DIFFERENCE->difference + OVERRIDE->override + - * JOIN->dot + PRODUCT->cross) | cache(expr, op(expr.left.accept(this), - * expr.right.accept(this))) - */ - @Override - public BooleanMatrix visit(NaryExpression expr) { - BooleanMatrix ret = lookup(expr); - if (ret != null) - return ret; - - final ExprOperator op = expr.op(); - final BooleanMatrix first = expr.child(0).accept(this); - final BooleanMatrix[] rest = new BooleanMatrix[expr.size() - 1]; - for (int i = 0; i < rest.length; i++) { - rest[i] = expr.child(i + 1).accept(this); - } - - switch (op) { - case UNION : - ret = first.or(rest); - break; - case INTERSECTION : - ret = first.and(rest); - break; - case OVERRIDE : - ret = first.override(rest); - break; - case PRODUCT : - ret = first.cross(rest); - break; - default : - throw new IllegalArgumentException("Unknown associative operator: " + op); - } - - return cache(expr, ret); - } - - /** - * Calls lookup(unaryExpr) and returns the cached value, if any. If a - * translation has not been cached, translates the expression, calls cache(...) - * on it and returns it. - * - * @return let t = lookup(unaryExpr) | some t => t, let op = - * (unaryExpr.op).(TRANSPOSE->transpose + CLOSURE->closure + - * REFLEXIVE_CLOSURE->(lambda(m)(m.closure().or(iden))) | - * cache(unaryExpr, op(unaryExpr.child)) - */ - @Override - public final BooleanMatrix visit(UnaryExpression unaryExpr) { - BooleanMatrix ret = lookup(unaryExpr); - if (ret != null) - return ret; - - final BooleanMatrix child = unaryExpr.expression().accept(this); - final ExprOperator op = unaryExpr.op(); - - switch (op) { - case TRANSPOSE : - ret = child.transpose(); - break; - case CLOSURE : - ret = child.closure(); - break; - case REFLEXIVE_CLOSURE : - ret = child.closure().or(visit((ConstantExpression) Expression.IDEN)); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + op); - } - return cache(unaryExpr, ret); - } - - /** - * Translates the given comprehension as follows (where A_0...A_|A| stand for - * boolean variables that represent the tuples of the expression A, etc.): let - * comprehension = "{ a: A, b: B, ..., x: X | F(a, b, ..., x) }" | { a: A, b: B, - * ..., x: X | a in A && b in B && ... && x in X && F(a, b, ..., x) }. - * - * @param decls the declarations comprehension - * @param param formula the body of the comprehension - * @param currentDecl currently processed declaration; should be 0 initially - * @param declConstraints the constraints implied by the declarations; should be - * Boolean.TRUE intially - * @param partialIndex partial index into the provided matrix; should be 0 - * initially - * @param matrix boolean matrix that will retain the final results; should be an - * empty matrix of dimensions universe.size^decls.length initially - * @ensures the given matrix contains the translation of the comprehension "{ - * decls | formula }" - */ - private final void comprehension(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, int partialIndex, BooleanMatrix matrix) { - final BooleanFactory factory = interpreter.factory(); - - if (currentDecl == decls.size()) { - // TODO: what about this and overflow??? - matrix.set(partialIndex, factory.and(declConstraints, formula.accept(this))); - return; - } - - final Decl decl = decls.get(currentDecl); - final BooleanMatrix declTransl = visit(decl); - final int position = (int) StrictMath.pow(interpreter.universe().size(), decls.size() - currentDecl - 1); - final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions()); - env = env.extend(decl.variable(), decl.expression(), groundValue); - for (IndexedEntry entry : declTransl) { - groundValue.set(entry.index(), BooleanConstant.TRUE); - comprehension(decls, formula, currentDecl + 1, factory.and(entry.value(), declConstraints), partialIndex + entry.index() * position, matrix); - groundValue.set(entry.index(), BooleanConstant.FALSE); - } - env = env.parent(); - } - - /** - * Calls lookup(cexpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(cexpr) | some t => t, cache(cexpr, translate(cexpr)) - */ - @Override - public BooleanMatrix visit(Comprehension cexpr) { - BooleanMatrix ret = lookup(cexpr); - if (ret != null) - return ret; - - ret = interpreter.factory().matrix(Dimensions.square(interpreter.universe().size(), cexpr.decls().size())); - comprehension(cexpr.decls(), cexpr.formula(), 0, BooleanConstant.TRUE, 0, ret); - - return cache(cexpr, ret); - } - - /** - * Calls lookup(ifExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(ifExpr) | some t => t, cache(ifExpr, - * ifExpr.condition.accept(this).choice(ifExpr.then.accept(this), - * ifExpr.else.accept(this))) - */ - @Override - public BooleanMatrix visit(IfExpression ifExpr) { - BooleanMatrix ret = lookup(ifExpr); - if (ret != null) - return ret; - - final BooleanValue condition = ifExpr.condition().accept(this); - final BooleanMatrix thenExpr = ifExpr.thenExpr().accept(this); - final BooleanMatrix elseExpr = ifExpr.elseExpr().accept(this); - ret = thenExpr.choice(condition, elseExpr); - - return cache(ifExpr, ret); - } - - /** - * Calls lookup(project) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(project) | some t => t, cache(project, - * project.expression.accept(this).project(translate(project.columns)) - */ - @Override - public final BooleanMatrix visit(ProjectExpression project) { - BooleanMatrix ret = lookup(project); - if (ret != null) - return ret; - - final Int[] cols = new Int[project.arity()]; - for (int i = 0, arity = project.arity(); i < arity; i++) { - cols[i] = project.column(i).accept(this); - } - - return cache(project, project.expression().accept(this).project(cols)); - } - - /** - * @return constant = ConstantFormula.TRUE => BooleanConstant.TRUE, - * BooleanConstant.FALSE - */ - @Override - public final BooleanValue visit(ConstantFormula constant) { - return cache(constant, BooleanConstant.constant(constant.booleanValue())); - } - - /** - * Translates the given universally quantified formula as follows (where - * A_0...A_|A| stand for boolean variables that represent the tuples of the - * expression A, etc.): let quantFormula = "all a: A, b: B, ..., x: X | F(a, b, - * ..., x)" | (A_0 && B_0 && ... && X_0 => translate(F(A_0, B_0, ..., X_0))) && - * ... && (A_|A| && B_|B| && ... && X_|X| => translate(F(A_|A|, B_|B|, ..., - * X_|X|))) If the noOverflow option is specified, then the translation looks - * like: let quantFormula = "all a: A, b: B, ..., x: X | F(a, b, ..., x)" | (A_0 - * && B_0 && ... && X_0 => (!of(F(A_0, B_0, ..., X_0)) => translate(F(A_0, B_0, - * ..., X_0)))) && ... && (A_|A| && B_|B| && ... && X_|X| => (!of(F(A_|A|, - * B_|B|, ..., X_|X|)) => translate(F(A_|A|, B_|B|, ..., X_|X|)))) where - * of(F(A_|a|, B_|b|, ..., X_|x|)) is the portion of the overflow circuit - * generated by the translation of F(A_|a|, B_|b|, ..., X_|x|) contributed by - * arithmetic operations over only the integer variables of this quantifier - * - * @param decls formula declarations - * @param formula the formula body - * @param currentDecl currently processed declaration; should be 0 initially - * @param declConstraints the constraints implied by the declarations; should be - * Boolean.FALSE initially - * @param acc the accumulator that contains the top level conjunction; should be - * an empty AND accumulator initially - * @ensures the given accumulator contains the translation of the formula "all - * decls | formula" - */ - private void all(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, BooleanAccumulator acc) { - if (acc.isShortCircuited()) - return; - final BooleanFactory factory = interpreter.factory(); - - if (decls.size() == currentDecl) { - BooleanValue formulaCircuit = formula.accept(this); - BooleanValue finalCircuit = factory.or(declConstraints, formulaCircuit); - acc.add(finalCircuit); - return; - } - - final Decl decl = decls.get(currentDecl); - final BooleanMatrix declTransl = visit(decl); - final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions()); - env = env.extend(decl.variable(), decl.expression(), groundValue, Quantifier.ALL); - for (IndexedEntry entry : declTransl) { - groundValue.set(entry.index(), BooleanConstant.TRUE); - all(decls, formula, currentDecl + 1, factory.or(factory.not(entry.value()), declConstraints), acc); - groundValue.set(entry.index(), BooleanConstant.FALSE); - } - env = env.parent(); - } - - /** - * Translates the given existentially quantified formula as follows (where - * A_0...A_|A| stand for boolean variables that represent the tuples of the - * expression A, etc.): let quantFormula = "some a: A, b: B, ..., x: X | F(a, b, - * ..., x)" | (A_0 && B_0 && ... && X_0 && translate(F(A_0, B_0, ..., X_0))) || - * ... || (A_|A| && B_|B| && ... && X_|X| && translate(F(A_|A|, B_|B|, ..., - * X_|X|)) If the noOverflow option is specified, then the translation looks - * like: let quantFormula = "some a: A, b: B, ..., x: X | F(a, b, ..., x)" | - * (A_0 && B_0 && ... && X_0 && !of(F(A_0, B_0, ..., X_0)) && translate(F(A_0, - * B_0, ..., X_0))) || ... || (A_|A| && B_|B| && ... && X_|X| && !of(F(A_|A|, - * B_|B|, ..., X_|X|)) && translate(F(A_|A|, B_|B|, ..., X_|X|)) where - * of(F(A_|a|, B_|b|, ..., X_|x|)) is the portion of the overflow circuit - * generated by the translation of F(A_|a|, B_|b|, ..., X_|x|) contributed by - * arithmetic operations over only the integer variables of this quantifier - * - * @param decls formula declarations - * @param formula the formula body - * @param currentDecl currently processed declaration; should be 0 initially - * @param declConstraints the constraints implied by the declarations; should be - * Boolean.TRUE intially - * @param acc the accumulator that contains the top level conjunction; should be - * an empty OR accumulator initially - * @ensures the given accumulator contains the translation of the formula "some - * decls | formula" - */ - private void some(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, BooleanAccumulator acc) { - if (acc.isShortCircuited()) - return; - final BooleanFactory factory = interpreter.factory(); - - if (decls.size() == currentDecl) { - BooleanValue formulaCircuit = formula.accept(this); - BooleanValue finalCircuit = factory.and(declConstraints, formulaCircuit); - acc.add(finalCircuit); - return; - } - - final Decl decl = decls.get(currentDecl); - final BooleanMatrix declTransl = visit(decl); - final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions()); - env = env.extend(decl.variable(), decl.expression(), groundValue, Quantifier.SOME); - for (IndexedEntry entry : declTransl) { - groundValue.set(entry.index(), BooleanConstant.TRUE); - some(decls, formula, currentDecl + 1, factory.and(entry.value(), declConstraints), acc); - groundValue.set(entry.index(), BooleanConstant.FALSE); - } - env = env.parent(); - } - - /** - * Calls lookup(quantFormula) and returns the cached value, if any. If a - * translation has not been cached, translates the formula, calls cache(...) on - * it and returns it. - * - * @return let t = lookup(quantFormula) | some t => t, cache(quantFormula, - * translate(quantFormula)) - */ - @Override - public final BooleanValue visit(QuantifiedFormula quantFormula) { - BooleanValue ret = lookup(quantFormula); - if (ret != null) - return ret; - - final Quantifier quantifier = quantFormula.quantifier(); - switch (quantifier) { - case ALL : - final BooleanAccumulator and = BooleanAccumulator.treeGate(Operator.AND); - all(quantFormula.decls(), quantFormula.formula(), 0, BooleanConstant.FALSE, and); - ret = interpreter.factory().accumulate(and); - break; - case SOME : - final BooleanAccumulator or = BooleanAccumulator.treeGate(Operator.OR); - some(quantFormula.decls(), quantFormula.formula(), 0, BooleanConstant.TRUE, or); - ret = interpreter.factory().accumulate(or); - break; - default : - throw new IllegalArgumentException("Unknown quantifier: " + quantifier); - } - return cache(quantFormula, ret); - } - - @Override - public BooleanValue visit(FixFormula fixFormula) { - // cannot translate this to FOL - throw new HigherOrderDeclException(fixFormula); - } - - /** - * Calls lookup(formula) and returns the cached value, if any. If a translation - * has not been cached, translates the formula, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(formula) | some t => t, cache(formula, - * formula.op(formula.left.accept(this), formula.right.accept(this)) - */ - @Override - public final BooleanValue visit(NaryFormula formula) { - final BooleanValue ret = lookup(formula); - if (ret != null) - return ret; - - final FormulaOperator op = formula.op(); - final Operator.Nary boolOp; - - switch (op) { - case AND : - boolOp = Operator.AND; - break; - case OR : - boolOp = Operator.OR; - break; - default : - throw new IllegalArgumentException("Unknown nary operator: " + op); - } - - final BooleanAccumulator acc = BooleanAccumulator.treeGate(boolOp); - final BooleanValue shortCircuit = boolOp.shortCircuit(); - for (Formula child : formula) { - if (acc.add(child.accept(this)) == shortCircuit) - break; - } - - return cache(formula, interpreter.factory().accumulate(acc)); - } - - /** - * Calls lookup(binFormula) and returns the cached value, if any. If a - * translation has not been cached, translates the formula, calls cache(...) on - * it and returns it. - * - * @return let t = lookup(binFormula) | some t => t, cache(binFormula, - * binFormula.op(binFormula.left.accept(this), - * binFormula.right.accept(this)) - */ - @Override - public final BooleanValue visit(BinaryFormula binFormula) { - BooleanValue ret = lookup(binFormula); - if (ret != null) - return ret; - - final BooleanValue left = binFormula.left().accept(this); - final BooleanValue right = binFormula.right().accept(this); - final FormulaOperator op = binFormula.op(); - final BooleanFactory f = interpreter.factory(); - - switch (op) { - case AND : - ret = f.and(left, right); - break; - case OR : - ret = f.or(left, right); - break; - case IMPLIES : - ret = f.implies(left, right); - break; - case IFF : - ret = f.iff(left, right); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + op); - } - return cache(binFormula, ret); - } - - /** - * Calls lookup(not) and returns the cached value, if any. If a translation has - * not been cached, translates the formula, calls cache(...) on it and returns - * it. - * - * @return let t = lookup(not) | some t => t, cache(not, - * !not.formula.accept(this)) - */ - @Override - public final BooleanValue visit(NotFormula not) { - BooleanValue ret = lookup(not); - if (ret != null) - return ret; - env.negate(); - ret = cache(not, interpreter.factory().not(not.formula().accept(this))); - env.negate(); - return ret; - } - - /** - * Calls lookup(compFormula) and returns the cached value, if any. If a - * translation has not been cached, translates the formula, calls cache(...) on - * it and returns it. - * - * @return let t = lookup(compFormula) | some t => t, let op = - * (binExpr.op).(SUBSET->subset + EQUALS->eq) | cache(compFormula, - * op(compFormula.left.accept(this), compFormula.right.accept(this))) - */ - @Override - public final BooleanValue visit(ComparisonFormula compFormula) { - BooleanValue ret = lookup(compFormula); - if (ret != null) - return ret; - - final BooleanMatrix left = compFormula.left().accept(this); - final BooleanMatrix right = compFormula.right().accept(this); - final ExprCompOperator op = compFormula.op(); - - switch (op) { - case SUBSET : - ret = left.subset(right, env); - break; - case EQUALS : - ret = left.eq(right, env); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + compFormula.op()); - } - return cache(compFormula, ret); - } - - /** - * Calls lookup(multFormula) and returns the cached value, if any. If a - * translation has not been cached, translates the formula, calls cache(...) on - * it and returns it. - * - * @return let t = lookup(multFormula) | some t => t, let op = - * (multFormula.mult).(NO->none + SOME->some + ONE->one + LONE->lone) | - * cache(multFormula, op(multFormula.expression.accept(this))) - */ - @Override - public final BooleanValue visit(MultiplicityFormula multFormula) { - BooleanValue ret = lookup(multFormula); - if (ret != null) - return ret; - - final BooleanMatrix child = multFormula.expression().accept(this); - final Multiplicity mult = multFormula.multiplicity(); - - switch (mult) { - case NO : - ret = child.none(env); - break; - case SOME : - ret = child.some(env); - break; - case ONE : - ret = child.one(env); - break; - case LONE : - ret = child.lone(env); - break; - default : - throw new IllegalArgumentException("Unknown multiplicity: " + mult); - } - - return cache(multFormula, ret); - } - - /** - * Calls lookup(pred) and returns the cached value, if any. If a translation has - * not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(pred) | some t => t, cache(pred, - * pred.toConstraints().accept(this)) - */ - @Override - public final BooleanValue visit(RelationPredicate pred) { - BooleanValue ret = lookup(pred); - return ret != null ? ret : cache(pred, pred.toConstraints().accept(this)); - } - - /** - * Calls lookup(castExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(castExpr) | some t => t, cache(castExpr, - * translate(castExpr)) - */ - @Override - public BooleanMatrix visit(IntToExprCast castExpr) { - BooleanMatrix ret = lookup(castExpr); - if (ret != null) - return ret; - - final Int child = castExpr.intExpr().accept(this); - final BooleanFactory factory = interpreter.factory(); - final IntSet ints = interpreter.ints(); - - ret = factory.matrix(Dimensions.square(interpreter.universe().size(), 1)); - - switch (castExpr.op()) { - case INTCAST : - for (IntIterator iter = ints.iterator(); iter.hasNext();) { - int i = iter.next(); - int atomIndex = interpreter.interpret(i); - ret.set(atomIndex, factory.or(ret.get(atomIndex), child.eq(factory.integer(i)))); - } - ret.setDefCond(child.defCond()); - break; - case BITSETCAST : - final List twosComplement = child.twosComplementBits(); - final int msb = twosComplement.size() - 1; - // handle all bits but the sign bit - for (int i = 0; i < msb; i++) { - int pow2 = 1 << i; - if (ints.contains(pow2)) { - ret.set(interpreter.interpret(pow2), twosComplement.get(i)); - } - } - // handle the sign bit - if (ints.contains(-1 << msb)) { - ret.set(interpreter.interpret(-1 << msb), twosComplement.get(msb)); - } - break; - default : - throw new IllegalArgumentException("Unknown cast operator: " + castExpr.op()); - } - - return cache(castExpr, ret); - } - - /** - * @return this.interpreter.factory.integer(intConst.value) - */ - @Override - public final Int visit(IntConstant intConst) { - Int ret = interpreter.factory().integer(intConst.value()); - return ret; - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(intExpr) | some t => t, cache(intExpr, - * intExpr.condition.accept(this).choice(intExpr.then.accept(this), - * intExpr.else.accept(this))) - */ - @Override - public final Int visit(IfIntExpression intExpr) { - Int ret = lookup(intExpr); - if (ret != null) - return ret; - - final BooleanValue condition = intExpr.condition().accept(this); - final Int thenExpr = intExpr.thenExpr().accept(this); - final Int elseExpr = intExpr.elseExpr().accept(this); - ret = thenExpr.choice(condition, elseExpr); - return cache(intExpr, ret); - } - - /** - * Returns an Int that represents the sum of all the integers that correspond to - * non-FALSE entries in the given matrix. - * - * @param iter an iterator over all the bound integers. Initial should be - * this.manager.ints().iterator(). - * @param lo the first element of the current partial sum. Initial should be 0. - * @param hi the last element of the current partial sum. Initial should be - * size-1, where size is the total number of elements returned by the - * iterator. - * @return an Int that represents the sum of all the integers that correspond to - * non-FALSE entries in the given matrix. - */ - private final Int sum(BooleanMatrix m, IntIterator iter, int low, int high) { - if (low > high) - return interpreter.factory().integer(0); - else if (low == high) { - int i = iter.next(); - return interpreter.factory().integer(i, m.get(interpreter.interpret(i))); - } else { - final int mid = (low + high) / 2; - final Int lsum = sum(m, iter, low, mid); - final Int hsum = sum(m, iter, mid + 1, high); - return lsum.plus(hsum); - } - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(intExpr) | some t => t, cache(intExpr, - * translate(intExpr)) - */ - @Override - public final Int visit(ExprToIntCast intExpr) { - Int ret = lookup(intExpr); - if (ret != null) - return ret; - vars = vars.createNested(); - BooleanMatrix expr = intExpr.expression().accept(this); - switch (intExpr.op()) { - case CARDINALITY : - ret = expr.cardinality(); - break; - case SUM : - final IntSet ints = interpreter.ints(); - ret = sum(expr, ints.iterator(), 0, ints.size() - 1); - break; - default : - throw new IllegalArgumentException("unknown operator: " + intExpr.op()); - } - for (Variable v : vars) - ret.defCond().addVar(v); - vars = vars.parent(); - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(intExpr) | some t => t, cache(intExpr, - * intExpr.left.accept(this) intExpr.op intExpr.right.accept(this)) - */ - @Override - public final Int visit(BinaryIntExpression intExpr) { - Int ret = lookup(intExpr); - if (ret != null) - return ret; - final Int left = intExpr.left().accept(this); - final Int right = intExpr.right().accept(this); - switch (intExpr.op()) { - case PLUS : - ret = left.plus(right); - break; - case MINUS : - ret = left.minus(right); - break; - case MULTIPLY : - ret = left.multiply(right); - break; - case DIVIDE : - ret = left.divide(right); - break; - case MODULO : - ret = left.modulo(right); - break; - case AND : - ret = left.and(right); - break; - case OR : - ret = left.or(right); - break; - case XOR : - ret = left.xor(right); - break; - case SHL : - ret = left.shl(right); - break; - case SHR : - ret = left.shr(right); - break; - case SHA : - ret = left.sha(right); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + intExpr.op()); - } - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(intExpr) | some t => t, cache(intExpr, - * intExpr.left.accept(this) intExpr.op intExpr.right.accept(this)) - */ - @Override - public final Int visit(NaryIntExpression intExpr) { - Int ret = lookup(intExpr); - if (ret != null) - return ret; - final Int first = intExpr.child(0).accept(this); - final Int[] rest = new Int[intExpr.size() - 1]; - for (int i = 0; i < rest.length; i++) { - rest[i] = intExpr.child(i + 1).accept(this); - } - switch (intExpr.op()) { - case PLUS : - ret = first.plus(rest); - break; - case MULTIPLY : - ret = first.multiply(rest); - break; - case AND : - ret = first.and(rest); - break; - case OR : - ret = first.or(rest); - break; - default : - throw new IllegalArgumentException("Unknown nary operator: " + intExpr.op()); - } - return cache(intExpr, ret); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(intExpr) | some t => t, cache(intExpr, - * intExpr.op(intExpr.expression.accept(this))) - */ - @Override - public final Int visit(UnaryIntExpression intExpr) { - Int ret = lookup(intExpr); - if (ret != null) - return ret; - final Int child = intExpr.intExpr().accept(this); - switch (intExpr.op()) { - case NEG : - ret = child.negate(); - break; - case NOT : - ret = child.not(); - break; - case ABS : - ret = child.abs(); - break; - case SGN : - ret = child.sgn(); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + intExpr.op()); - } - return cache(intExpr, ret); - } - - /** - * Translates the given sum expression as follows (where A_0...A_|A| stand for - * boolean variables that represent the tuples of the expression A, etc.): let - * sum = "sum a: A, b: B, ..., x: X | IE(a, b, ..., x) " | sum a: A, b: B, ..., - * x: X | if (a in A && b in B && ... && x in X) then IE(a, b, ..., x) else 0 }. - * - * @param decls intexpr declarations - * @param formula the formula body - * @param currentDecl currently processed declaration; should be 0 initially - * @param declConstraints the constraints implied by the declarations; should be - * Boolean.TRUE intially - * @param values integer values computed so far - */ - private final void sum(Decls decls, IntExpression expr, int currentDecl, BooleanValue declConstraints, List values) { - final BooleanFactory factory = interpreter.factory(); - if (decls.size() == currentDecl) { - Int intExpr = expr.accept(this); - Int newInt = intExpr.choice(declConstraints, factory.integer(0)); - values.add(newInt); - return; - } - - final Decl decl = decls.get(currentDecl); - final BooleanMatrix declTransl = visit(decl); - final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions()); - env = env.extend(decl.variable(), decl.expression(), groundValue); - for (IndexedEntry entry : declTransl) { - groundValue.set(entry.index(), BooleanConstant.TRUE); - sum(decls, expr, currentDecl + 1, factory.and(entry.value(), declConstraints), values); - groundValue.set(entry.index(), BooleanConstant.FALSE); - } - env = env.parent(); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If a translation - * has not been cached, translates the expression, calls cache(...) on it and - * returns it. - * - * @return let t = lookup(intExpr) | some t => t, cache(intExpr, - * translate(intExpr)) - */ - @Override - public final Int visit(SumExpression intExpr) { - final Int ret = lookup(intExpr); - if (ret != null) - return ret; - final List values = new ArrayList(); - sum(intExpr.decls(), intExpr.intExpr(), 0, BooleanConstant.TRUE, values); - for (int sums = values.size(); sums > 1; sums -= sums / 2) { - final int max = sums - 1; - for (int i = 0; i < max; i += 2) { - values.set(i / 2, values.get(i).plus(values.get(i + 1))); - } - if (max % 2 == 0) { // even max => odd number of entries - values.set(max / 2, values.get(max)); - } - } - if (values.isEmpty()) { - return cache(intExpr, interpreter.factory().integer(0)); - } else { - Int sumValue = values.get(0); - return cache(intExpr, sumValue); - } - } - - /** - * Calls lookup(intComp) and returns the cached value, if any. If a translation - * has not been cached, translates the formula, calls cache(...) on it and - * returns it. This is the only place where Ints are turned into - * formulas, so that's where the overflow circuits of individual - * Ints are built into the translated formula. - * - * @return let t = lookup(intComp) | some t => t, cache(intComp, - * intComp.left.accept(this) intComp.op intComp.right.accept(this)) - */ - @Override - public final BooleanValue visit(IntComparisonFormula intComp) { - BooleanValue ret = lookup(intComp); - if (ret != null) - return ret; - final Int left = intComp.left().accept(this); - final Int right = intComp.right().accept(this); - switch (intComp.op()) { - case EQ : - ret = left.eq(right, env); - break; - case NEQ : - ret = left.neq(right, env); - break; - case LT : - ret = left.lt(right, env); - break; - case LTE : - ret = left.lte(right, env); - break; - case GT : - ret = left.gt(right, env); - break; - case GTE : - ret = left.gte(right, env); - break; - default : - throw new IllegalArgumentException("Unknown operator: " + intComp.op()); - } - return cache(intComp, ret); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FileLogger.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FileLogger.java deleted file mode 100644 index f2d7100cf..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FileLogger.java +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import kodkod.ast.ConstantFormula; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.engine.Solver; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.BooleanValue; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.util.collections.Containers; -import kodkod.util.collections.FixedMap; -import kodkod.util.ints.Ints; -import kodkod.util.nodes.AnnotatedNode; -import kodkod.util.nodes.Nodes; - -/** - * A file-based translation logger that logs translation events to a temporary - * file. - * - * @specfield originalFormula: Formula // the - * {@linkplain Solver#solve(Formula, kodkod.instance.Bounds) - * original} formula, provided by the user - * @specfield originalBounds: Bounds // the - * {@linkplain Solver#solve(Formula, kodkod.instance.Bounds) - * original} bounds, provided by the user - * @specfield formula: Formula // desugaring of this.formula that was translated - * @specfield bounds: Bounds // translation bounds - * @specfield records: (formula.*children & Formula) -> BooleanValue -> - * Environment - * @invariant Solver.solve(formula, bounds).instance() == null iff - * Solver.solve(originalFormula, originalBounds).instance() == null - * @author Emina Torlak - */ -final class FileLogger extends TranslationLogger { - - private final FixedMap logMap; - private final AnnotatedNode annotated; - private final File file; - private DataOutputStream out; - private final Bounds bounds; - - /** - * Constructs a new file logger from the given annotated formula. - * - * @ensures this.formula' = annotated.node - * @ensures this.originalFormula' = annotated.source[annotated.node] - * @ensures this.bounds' = bounds - * @ensures this.log().roots() = Nodes.conjuncts(annotated) - * @ensures no this.records' - */ - FileLogger(final AnnotatedNode annotated, Bounds bounds) { - this.annotated = annotated; - try { - this.file = File.createTempFile("kodkod", ".log"); - this.out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); - } catch (IOException e1) { - throw new RuntimeException(e1); - } - - final Map> freeVarMap = freeVars(annotated); - final Variable[] empty = new Variable[0]; - - this.logMap = new FixedMap(freeVarMap.keySet()); - - for (Map.Entry e : logMap.entrySet()) { - Set vars = freeVarMap.get(e.getKey()); - int size = vars.size(); - if (size == 0) { - e.setValue(empty); - } else { - e.setValue(Containers.identitySort(vars.toArray(new Variable[size]))); - } - } - this.bounds = bounds.unmodifiableView(); - } - - /** - * Returns a map from all formulas in the given annotated node to their free - * variables. - * - * @return a map from all formulas in the given annotated node to their free - * variables. - */ - @SuppressWarnings("unchecked" ) - private static Map> freeVars(final AnnotatedNode annotated) { - final Map> freeVarMap = new IdentityHashMap>(); - final FreeVariableCollector collector = new FreeVariableCollector(annotated.sharedNodes()) { - - @Override - protected Set cache(Node node, Set freeVars) { - if (node instanceof Formula) { - freeVarMap.put((Formula) node, freeVars); - } - return super.cache(node, freeVars); - } - - @Override - public Set visit(ConstantFormula constant) { - return cache(constant, Collections.EMPTY_SET); - } - - }; - annotated.node().accept(collector); - return freeVarMap; - } - - /** - * @see kodkod.engine.fol2sat.TranslationLogger#close() - */ - @Override - void close() { - try { - if (out != null) { - out.close(); - } - } catch (IOException e1) { - /* unused */ - } finally { - out = null; - } - } - - /** - * Records the translation of the source of the given transformed formula to the - * given boolean value in the specified environment. - * - * @requires some this.transforms.f - * @ensures this.records' = this.records + this.transforms.f -> translation -> - * freeVariables(f)<:env - * @throws IllegalArgumentException no this.transforms.f - * @throws IllegalStateException this log has been closed - */ - @Override - void log(Formula f, BooleanValue v, Environment env) { - if (out == null) - throw new IllegalStateException(); - - final int index = logMap.indexOf(f); - if (index < 0) - throw new IllegalArgumentException(); - - final Variable[] vars = logMap.get(index); - - try { - out.writeInt(index); - out.writeInt(v.label()); - for (Variable var : vars) { - out.writeInt(env.lookup(var).denseIndices().min()); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** - * @see kodkod.engine.fol2sat.TranslationLogger#log() - */ - @Override - TranslationLog log() { - return new FileLog(annotated, logMap, file, bounds); - } - - /** - * @see java.lang.Object#finalize() - */ - @Override - protected final void finalize() { - close(); - } - - /** - * A file-based translation log, written by a FileLogger. - * - * @author Emina Torlak - */ - private static final class FileLog extends TranslationLog { - - private final Set roots; - private final Node[] original; - private final Formula[] translated; - private final Variable[][] freeVars; - private final File file; - private final Bounds bounds; - - /** - * Constructs a new file log for the sources of the given annotated formula, - * using the provided fixed map, file, and tuplefactory. - * - * @requires all f: annotated.node.*children & Formula | logMap.get(f) = - * freeVariables(f) - * @requires the file was written by a FileLogger using the given map - */ - FileLog(AnnotatedNode annotated, FixedMap logMap, File file, Bounds bounds) { - this.file = file; - this.bounds = bounds; - this.roots = Nodes.conjuncts(annotated.node()); - - final int size = logMap.entrySet().size(); - this.original = new Node[size]; - this.translated = new Formula[size]; - this.freeVars = new Variable[size][]; - int index = 0; - for (Map.Entry e : logMap.entrySet()) { - translated[index] = e.getKey(); - original[index] = annotated.sourceOf(e.getKey()); - freeVars[index] = e.getValue(); - index++; - } - } - - /** - * Deletes the log file. - * - * @see java.lang.Object#finalize() - */ - @Override - protected final void finalize() { - file.delete(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLog#roots() - */ - @Override - public Set roots() { - return roots; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLog#bounds() - */ - @Override - public Bounds bounds() { - return bounds; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLog#replay(kodkod.engine.fol2sat.RecordFilter) - */ - @Override - public Iterator replay(final RecordFilter filter) { - try { - return new Iterator() { - - final TupleFactory factory = bounds.universe().factory(); - final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); - final MutableRecord current = new MutableRecord(), next = new MutableRecord(); - long remaining = file.length(); - - @Override - public boolean hasNext() { - while (remaining > 0 && next.node == null) { - try { - final long indexLiteral = in.readLong(); - final int literal = (int) (indexLiteral); - final int index = (int) (indexLiteral >>> 32); - final Variable[] freeVars = FileLog.this.freeVars[index]; - final Map env; - if (freeVars.length == 0) { - env = Collections.emptyMap(); - } else { - env = new FixedMap(freeVars); - for (int i = 0; i < freeVars.length; i++) { - env.put(freeVars[i], factory.setOf(1, Ints.singleton(in.readInt()))); - } - } - if (filter.accept(original[index], translated[index], literal, env)) { - next.setAll(original[index], translated[index], literal, env); - } - remaining -= (8 + (freeVars.length << 2)); - - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (next.node == null) { - try { - in.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return false; - } else { - return true; - } - } - - @Override - public TranslationRecord next() { - if (!hasNext()) - throw new NoSuchElementException(); - return current.setAll(next); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - protected final void finalize() { - try { - in.close(); - } catch (IOException e) { /* unused */ } - } - }; - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } - } - - /** - * A mutable translation record. - * - * @author Emina Torlak - */ - private static final class MutableRecord extends TranslationRecord { - - Node node = null; - Formula translated = null; - int literal = 0; - Map env = null; - - @Override - public Map env() { - return env; - } - - @Override - public int literal() { - return literal; - } - - @Override - public Node node() { - return node; - } - - void setAll(Node node, Formula translated, int literal, Map env) { - this.node = node; - this.translated = translated; - this.literal = literal; - this.env = env; - } - - TranslationRecord setAll(MutableRecord other) { - setAll(other.node, other.translated, other.literal, other.env); - other.setAll(null, null, 0, null); - return this; - } - - @Override - public Formula translated() { - return translated; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FormulaFlattener.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FormulaFlattener.java deleted file mode 100644 index c4c3f22ba..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FormulaFlattener.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import static kodkod.ast.operator.FormulaOperator.AND; -import static kodkod.ast.operator.FormulaOperator.IFF; -import static kodkod.ast.operator.FormulaOperator.IMPLIES; -import static kodkod.ast.operator.FormulaOperator.OR; -import static kodkod.ast.operator.Quantifier.ALL; -import static kodkod.ast.operator.Quantifier.SOME; - -import java.util.ArrayList; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decls; -import kodkod.ast.Formula; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.RelationPredicate; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.AbstractVoidVisitor; -import kodkod.util.nodes.AnnotatedNode; - -/** - * Flattens a given formula by putting into negation normal form and, - * optionally, by breaking up universally quantifier formulas whenever possible. - * - * @author Emina Torlak - */ -public final class FormulaFlattener extends AbstractVoidVisitor { - - /** - * Flattens the given formula into a set of conjuncts by pushing negations - * through quantifier-free formulas, if breakupQuantifiers is false. Otherwise, - * pushes the negations through all formulas, breaking up universal quantifiers - * whenever possible. The source map of the returned annotated node reflects the - * source relationships from the descendants of the returned formula to the - * sources of the corresponding descendants of annotated.node. - * - * @return a map that binds each flattened conjuncts to the corresponding - * subformula of annotated.node - */ - public static AnnotatedNode flatten(AnnotatedNode annotated, boolean breakupQuantifiers) { - final FormulaFlattener flat = new FormulaFlattener(annotated.sharedNodes(), breakupQuantifiers); - annotated.node().accept(flat); - final List roots = new ArrayList(flat.conjuncts.size()); - roots.addAll(flat.conjuncts.keySet()); - for (Iterator> itr = flat.conjuncts.entrySet().iterator(); itr.hasNext();) { - final Map.Entry entry = itr.next(); - final Node source = annotated.sourceOf(entry.getValue()); - if (entry.getKey() == source) { - itr.remove(); - } else { - entry.setValue(source); - } - } - return AnnotatedNode.annotate(Formula.and(roots), flat.conjuncts); - } - - private Map conjuncts; - private final Map visited; - private final Set shared; - private boolean negated; - private final boolean breakupQuantifiers; - - /** - * Constructs a flattener for a formula in which the given nodes are shared. - */ - private FormulaFlattener(Set shared, boolean breakupQuantifiers) { - this.conjuncts = new LinkedHashMap(); - this.shared = shared; - this.visited = new IdentityHashMap(); - this.negated = false; - this.breakupQuantifiers = breakupQuantifiers; - } - - /** - * Returns the result of applying this visitor to the given annotated formula. - * - * @return the result of applying this visitor to the given annotated formula. - */ - final AnnotatedNode apply(AnnotatedNode annotated) { - annotated.node().accept(this); - final List roots = new ArrayList(conjuncts.size()); - roots.addAll(conjuncts.keySet()); - for (Iterator> itr = conjuncts.entrySet().iterator(); itr.hasNext();) { - final Map.Entry entry = itr.next(); - final Node source = annotated.sourceOf(entry.getValue()); - if (entry.getKey() == source) { - itr.remove(); - } else { - entry.setValue(source); - } - } - return AnnotatedNode.annotate(Formula.and(roots), conjuncts); - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visited(kodkod.ast.Node) - */ - @Override - protected boolean visited(Node n) { - if (shared.contains(n)) { - if (visited.containsKey(n)) { - final Boolean val = visited.get(n); - if (val == null || val.booleanValue() == negated) { - return true; - } else { - visited.put(n, null); - return false; - } - } else { - visited.put(n, Boolean.valueOf(negated)); - return false; - } - } - return false; - } - - /** - * Calls nf.formula.accept(this) after flipping the negation flag. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.NotFormula) - */ - @Override - public final void visit(NotFormula nf) { - if (visited(nf)) - return; - - final Map oldConjuncts = conjuncts; - conjuncts = new LinkedHashMap(); - negated = !negated; - nf.formula().accept(this); - negated = !negated; - if (conjuncts.size() > 1) { // was broken down further - oldConjuncts.putAll(conjuncts); - conjuncts = oldConjuncts; - } else { // wasn't broken down further - conjuncts = oldConjuncts; - conjuncts.put(negated ? nf.formula() : nf, nf); - } - } - - /** - * Adds the given formula (or its negation, depending on the value of the - * negated flag) to this.conjuncts. - */ - private final void addConjunct(Formula conjunct) { - conjuncts.put(negated ? conjunct.not() : conjunct, conjunct); - } - - /** - * Visits the formula's children with appropriate settings for the negated flag - * if bf has not been visited before. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.BinaryFormula) - */ - @Override - public final void visit(BinaryFormula bf) { - if (visited(bf)) - return; - final FormulaOperator op = bf.op(); - if (op == IFF || (negated && op == AND) || (!negated && (op == OR || op == IMPLIES))) { // can't - // break - // down - // further - // in - // these - // cases - addConjunct(bf); - } else { // will break down further - if (negated && op == IMPLIES) { // !(a => b) = !(!a || b) = a && !b - negated = !negated; - bf.left().accept(this); - negated = !negated; - bf.right().accept(this); - } else { - bf.left().accept(this); - bf.right().accept(this); - } - } - } - - /** - * Visits the formula's children with appropriate settings for the negated flag - * if bf has not been visited before. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.NaryFormula) - */ - @Override - public final void visit(NaryFormula nf) { - if (visited(nf)) - return; - final FormulaOperator op = nf.op(); - if ((negated && op == AND) || (!negated && op == OR)) { // can't break - // down further - // in these - // cases - addConjunct(nf); - } else { // will break down further - for (Formula f : nf) { - f.accept(this); - } - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.QuantifiedFormula) - */ - @Override - public final void visit(QuantifiedFormula qf) { - if (visited(qf)) - return; - - if (breakupQuantifiers) { - - final Quantifier quant = qf.quantifier(); - - if ((!negated && quant == ALL) || (negated && quant == SOME)) { // may - // break - // down - // further - final Map oldConjuncts = conjuncts; - conjuncts = new LinkedHashMap(); - qf.formula().accept(this); - if (conjuncts.size() > 1) { // was broken down further - final Decls decls = qf.decls(); - for (Map.Entry entry : conjuncts.entrySet()) { - oldConjuncts.put(entry.getKey().forAll(decls), entry.getValue()); - } - conjuncts = oldConjuncts; - return; - } else { // wasn't broken down further - conjuncts = oldConjuncts; - } - } // won't break down further - } - - addConjunct(qf); - - } - - /** - * Adds f (resp. f.not()) to this.conjuncts if the negated flag is false (resp. - * true) and the given node has not been visited; otherwise does nothing. - * - * @ensures !this.visited(f) => (this.conjuncts' = conjuncts + (negated => - * f.not() else f)) else (this.conjuncts' = this.conjuncts) - */ - final void visitFormula(Formula f) { - if (visited(f)) - return; - addConjunct(f); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(ComparisonFormula cf) { - visitFormula(cf); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(IntComparisonFormula cf) { - visitFormula(cf); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(MultiplicityFormula mf) { - visitFormula(mf); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(ConstantFormula constant) { - visitFormula(constant); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(RelationPredicate pred) { - visitFormula(pred); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FreeVariableCollector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FreeVariableCollector.java deleted file mode 100644 index 618e31759..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FreeVariableCollector.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import kodkod.ast.Comprehension; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.Node; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.SumExpression; -import kodkod.ast.Variable; -import kodkod.ast.visitor.AbstractCollector; -import kodkod.util.collections.ArrayStack; -import kodkod.util.collections.Stack; - -/** - * Collects free variables in a given Node. Subclasses can customize the - * collection policy by overriding the cache method. By default, the - * cache will contain only the free variables of the shared nodes. The default - * implementation of {@link #newSet()} ensures that the collected free variables - * will be returned in the order in which they were encountered during - * traversal. - * - * @specfield cached: set Node - * @specfield cache: Node -> lone Set - * @specfield varsInScope: Stack // variables currently in scope - * @author Emina Torlak - */ -abstract class FreeVariableCollector extends AbstractCollector { - - /* - * Holds the variables that are currently in scope, with the variable at the top - * of the stack being the last declared variable. - */ - protected final Stack varsInScope; - - /** - * Constructs a new collector using the given structural information. The given - * set is required to contain the syntactically shared subtrees of the node for - * which we are computing caching information. - */ - protected FreeVariableCollector(Set cached) { - super(cached); - this.varsInScope = new ArrayStack(); - } - - /** - * @see kodkod.ast.visitor.AbstractCollector#newSet() - */ - @Override - protected Set newSet() { - return new LinkedHashSet(2); - } - - /** - * Visits the given comprehension, quantified formula, or sum expression. The - * method returns a set that contains all the free variables in the declarations - * and the body, minus the variables that are actually bound in the - * declarations. - */ - @SuppressWarnings("unchecked" ) - private Set visit(Node creator, Decls decls, Node body) { - Set ret = lookup(creator); - if (ret != null) - return ret; - - ret = newSet(); - final Set boundVars = newSet(); - - // add the declared variables to the scoped variables stack; - // compute free vars for each decl, and the difference of the - // computed set and previously bound variables to ret - for (Decl decl : decls) { - for (Variable v : visit(decl)) { - if (!boundVars.contains(v)) - ret.add(v); - } - varsInScope.push(decl.variable()); - boundVars.add(decl.variable()); - } - - // add to ret the free variables in the body, minus the bound variables - for (Variable v : (Set) body.accept(this)) { - if (!boundVars.contains(v)) - ret.add(v); - } - - // remove the declared variables from the in-scope stack - for (int i = decls.size(); i > 0; i--) { - varsInScope.pop(); - } - - return cache(creator, ret); - } - - /** - * Returns the free variables in the given declaration. - * - * @return freeVars(decl.expression) - */ - @Override - public Set visit(Decl decl) { - final Set ret = lookup(decl); - return ret != null ? ret : cache(decl, decl.expression().accept(this)); - } - - /** - * Returns the singleton set containing the given variable. - * - * @return {variable} - */ - @Override - public Set visit(Variable variable) { - return cache(variable, Collections.singleton(variable)); - } - - /** - * Calls lookup(comprehension) and returns the cached value, if any. If no - * cached value exists, computes, caches and returns the set of free variables - * in comprehension. - * - * @return let x = lookup(comprehension), d = comprehension.declarations, f = - * comprehension.formula | x != null => x, cache(comprehension, - * (f.accept(this) - d.children.variable) + {v: Variable | some i: - * [0..d.size) | v in d.declarations[i].accept(this) - - * d.declarations[0..i).variable } ) - */ - @Override - public Set visit(Comprehension comprehension) { - return visit(comprehension, comprehension.decls(), comprehension.formula()); - } - - /** - * Calls lookup(intExpr) and returns the cached value, if any. If no cached - * value exists, computes, caches and returns the set of free variables in - * intExpr. - * - * @return let x = lookup(intExpr), d = intExpr.declarations, e = - * intExpr.intExpr | x != null => x, cache(intExpr, (e.accept(this) - - * d.children.variable) + {v: Variable | some i: [0..d.size) | v in - * d.declarations[i].accept(this) - d.declarations[0..i).variable } ) - */ - @Override - public Set visit(SumExpression intExpr) { - return visit(intExpr, intExpr.decls(), intExpr.intExpr()); - } - - /** - * Calls lookup(quantFormula) and returns the cached value, if any. If no cached - * value exists, computes, caches and returns the set of free variables in - * quantFormula. - * - * @return let x = lookup(quantFormula), d = quantFormula.declarations, f = - * quantFormula.formula | x != null => x, cache(quantFormula, - * (f.accept(this) - d.children.variable) + {v: Variable | some i: - * [0..d.size) | v in d.declarations[i].accept(this) - - * d.declarations[0..i).variable } ) - */ - @Override - public Set visit(QuantifiedFormula quantFormula) { - return visit(quantFormula, quantFormula.decls(), quantFormula.formula()); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FullNegationPropagator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FullNegationPropagator.java deleted file mode 100644 index 136d52716..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/FullNegationPropagator.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2011, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import static kodkod.ast.operator.FormulaOperator.AND; -import static kodkod.ast.operator.FormulaOperator.OR; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.ConstantFormula; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.RelationPredicate; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.AbstractVoidVisitor; -import kodkod.engine.config.Reporter; -import kodkod.util.nodes.AnnotatedNode; - -/** - * Propagates negations all the way down to the leafs, but without crossing - * quantification boundaries. It also eliminates negations wherever possible - * (e.g. double negation, !(a>b) --> a<=b, etc.) Breaks up all implications (=>) - * and two-way implications (<=>), so that the resulting formula only contains - * the following boolean operators: AND (&&), OR (||), and NOT (!) at the leaf - * positions. - */ -public final class FullNegationPropagator extends AbstractVoidVisitor { - - public static AnnotatedNode toNNF(AnnotatedNode annotated) { - return toNNF(annotated, null); - } - - public static AnnotatedNode toNNF(AnnotatedNode annotated, Reporter reporter) { - if (reporter != null) - reporter.convertingToNNF(); - final FullNegationPropagator flat = new FullNegationPropagator(annotated.sharedNodes()); - annotated.node().accept(flat); - final List roots = new ArrayList(flat.annotations.size()); - roots.addAll(flat.annotations.keySet()); - for (Iterator> itr = flat.annotations.entrySet().iterator(); itr.hasNext();) { - final Map.Entry entry = itr.next(); - final Node source = annotated.sourceOf(entry.getValue()); - if (entry.getKey() == source) { - itr.remove(); - /* TODO: what is this for? */ } else { - entry.setValue(source); - } - } - return AnnotatedNode.annotate(Formula.and(flat.conjuncts), flat.annotations); - } - - private List conjuncts; - private Map annotations; - private final Set shared; - private boolean negated; - private boolean hasChanged; - - /** - * Constructs a flattener for a formula in which the given nodes are shared. - */ - private FullNegationPropagator(Set shared) { - this(shared, new LinkedHashMap()); - } - - private FullNegationPropagator(Set shared, Map annotations) { - this.conjuncts = new LinkedList(); - this.annotations = annotations; - this.shared = shared; - this.negated = false; - } - - /** - * {@inheritDoc} - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visited(kodkod.ast.Node) - */ - @Override - protected boolean visited(Node n) { - return false; - } - - /** - * Calls nf.formula.accept(this) after flipping the negation flag. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.NotFormula) - */ - @Override - public final void visit(NotFormula nf) { - if (visited(nf)) - return; - - FullNegationPropagator fne = new FullNegationPropagator(shared, annotations); - fne.negated = !negated; - nf.formula().accept(fne); - if (fne.hasChanged) { - addConjunct(Formula.and(fne.conjuncts), false, nf); - hasChanged = true; - } else { - addConjunct(nf); - } - } - - /** - * Visits the formula's children with appropriate settings for the negated flag - * if bf has not been visited before. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.BinaryFormula) - */ - @Override - public final void visit(BinaryFormula bf) { - if (visited(bf)) - return; - final FormulaOperator op = bf.op(); - switch (op) { - case AND : - if (!negated) { - // left && right - bf.left().accept(this); - bf.right().accept(this); - } else { - // !(left && right) --> !left || !right - FullNegationPropagator fne1 = new FullNegationPropagator(shared, annotations); - bf.left().not().accept(fne1); - - FullNegationPropagator fne2 = new FullNegationPropagator(shared, annotations); - bf.right().not().accept(fne2); - - addConjunct(Formula.and(fne1.conjuncts).or(Formula.and(fne2.conjuncts)), false, bf); - hasChanged = true; - } - break; - case OR : - if (!negated) { - // left || right - FullNegationPropagator fne1 = new FullNegationPropagator(shared, annotations); - bf.left().accept(fne1); - - FullNegationPropagator fne2 = new FullNegationPropagator(shared, annotations); - bf.right().accept(fne2); - - if (!fne1.hasChanged && !fne2.hasChanged) { - addConjunct(bf); - } else { - addConjunct(Formula.and(fne1.conjuncts).or(Formula.and(fne2.conjuncts)), false, bf); - hasChanged = true; - } - } else { - // !(left || right) --> !left && !right - bf.left().accept(this); - bf.right().accept(this); - hasChanged = true; - } - break; - case IMPLIES : - if (!negated) { - // left => right --> !left || right - FullNegationPropagator fne1 = new FullNegationPropagator(shared, annotations); - bf.left().not().accept(fne1); - - FullNegationPropagator fne2 = new FullNegationPropagator(shared, annotations); - bf.right().accept(fne2); - - addConjunct(Formula.and(fne1.conjuncts).or(Formula.and(fne2.conjuncts)), false, bf); - } else { - // !(left => right) --> left && !right - negated = false; - bf.left().accept(this); - negated = true; - bf.right().accept(this); - } - hasChanged = true; - break; - case IFF : - FullNegationPropagator fne1 = new FullNegationPropagator(shared, annotations); - FullNegationPropagator fne2 = new FullNegationPropagator(shared, annotations); - if (!negated) { - // a <=> b --> (a && b) || (!a && !b) - bf.left().and(bf.right()).accept(fne1); - bf.left().not().and(bf.right().not()).accept(fne2); - } else { - // !(a = b) --> (a && !b) || (!a && b) - Formula orLhs = bf.left().and(bf.right().not()); - orLhs.accept(fne1); - Formula orRhs = bf.left().not().and(bf.right()); - orRhs.accept(fne2); - } - addConjunct(Formula.and(fne1.conjuncts).or(Formula.and(fne2.conjuncts)), false, bf); - hasChanged = true; - break; - default : - addConjunct(bf); - } - } - - /** - * Visits the formula's children with appropriate settings for the negated flag - * if bf has not been visited before. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.NaryFormula) - */ - @Override - public final void visit(NaryFormula nf) { - if (visited(nf)) - return; - final FormulaOperator op = nf.op(); - if (negated && op == AND) { - List formulas = new LinkedList(); - for (Formula f : nf) { - FullNegationPropagator fne = new FullNegationPropagator(shared, annotations); - f.not().accept(fne); - formulas.add(Formula.and(fne.conjuncts)); - } - addConjunct(Formula.or(formulas), false, nf); - hasChanged = true; - } else if (!negated && op == OR) { - List formulas = new LinkedList(); - boolean changed = false; - for (Formula f : nf) { - FullNegationPropagator fne = new FullNegationPropagator(shared, annotations); - f.accept(fne); - changed = changed || fne.hasChanged; - formulas.add(Formula.and(fne.conjuncts)); - } - if (changed) { - addConjunct(Formula.or(formulas), false, nf); - hasChanged = true; - } else { - addConjunct(nf); - } - } else { - for (Formula f : nf) { - f.accept(this); - } - hasChanged = negated; - } - } - - /** - * Adds f (resp. f.not()) to this.conjuncts if the negated flag is false (resp. - * true) and the given node has not been visited; otherwise does nothing. - * - * @ensures !this.visited(f) => (this.conjuncts' = conjuncts + (negated => - * f.not() else f)) else (this.conjuncts' = this.conjuncts) - */ - final void visitFormula(Formula f) { - if (visited(f)) - return; - addConjunct(f); - } - - @Override - public final void visit(QuantifiedFormula qf) { - if (visited(qf)) - return; - FullNegationPropagator fneBody = new FullNegationPropagator(shared, annotations); - fneBody.negated = negated; - boolean wasNegated = negated; - negated = false; - qf.body().accept(fneBody); - - FullNegationPropagator fneDomain = new FullNegationPropagator(shared, annotations); - qf.domain().accept(fneDomain); - - if (fneBody.hasChanged || fneDomain.hasChanged || wasNegated) { - Formula qfBody = Formula.and(fneBody.conjuncts); - Quantifier quant = wasNegated ? qf.quantifier().opposite : qf.quantifier(); - addConjunct(qfBody.quantify(quant, qf.decls(), Formula.and(fneDomain.conjuncts)), false, qf); - hasChanged = true; - } else { - addConjunct(qf); - } - negated = wasNegated; - } - - @Override - public final void visit(FixFormula qf) { - addConjunct(qf); - // if (visited(qf)) return; - // if (!negated) { - // addConjunct(qf, false, qf); - // } else { - // negated = false; - // qf.formula().accept(this); - // hasChanged = true; - // negated = true; - // } - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(ComparisonFormula cf) { - visitFormula(cf); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(IntComparisonFormula cf) { - if (visited(cf)) - return; - if (!negated) { - addConjunct(cf); - } else { - switch (cf.op()) { - case GT : - addConjunct(cf.left().lte(cf.right()), false, cf); - hasChanged = true; - break; - case GTE : - addConjunct(cf.left().lt(cf.right()), false, cf); - hasChanged = true; - break; - case LT : - addConjunct(cf.left().gte(cf.right()), false, cf); - hasChanged = true; - break; - case LTE : - addConjunct(cf.left().gt(cf.right()), false, cf); - hasChanged = true; - break; - case EQ : - addConjunct(cf.left().neq(cf.right()), false, cf); - hasChanged = true; - break; - case NEQ : - addConjunct(cf.left().eq(cf.right()), false, cf); - hasChanged = true; - break; - default : - addConjunct(cf); - } - } - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(MultiplicityFormula mf) { - visitFormula(mf); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(ConstantFormula constant) { - visitFormula(constant); - } - - /** @see #visitFormula(Formula) */ - @Override - public final void visit(RelationPredicate pred) { - visitFormula(pred); - } - - /** - * Adds the given formula (or its negation, depending on the value of the - * negated flag) to this.conjuncts. - */ - private final void addConjunct(Formula conjunct) { - addConjunct(conjunct, negated, conjunct); - } - - private final void addConjunct(Formula conjunct, boolean neg, Node source) { - Formula f = neg ? not(conjunct) : conjunct; - conjuncts.add(f); - annotations.put(f, source); - } - - private Formula not(Formula f) { - return f instanceof NotFormula ? ((NotFormula) f).formula() : f.not(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/HigherOrderDeclException.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/HigherOrderDeclException.java deleted file mode 100644 index 32f568a8b..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/HigherOrderDeclException.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import kodkod.ast.Decl; -import kodkod.ast.FixFormula; -import kodkod.ast.Node; -import kodkod.ast.operator.Multiplicity; - -/** - * Thrown when a node contains a higher order declaration that cannot be - * skolemized, or it can be skolemized but skolemization is disabled. - * - * @specfield decl: Decl // higher order decl that caused the exception to be - * thrown - * @author Emina Torlak - */ -public final class HigherOrderDeclException extends RuntimeException { - - private final Node node; - private final boolean isDecl; - private static final long serialVersionUID = 1892780864484615171L; - - /** - * Constructs a HigherOrderDeclException for the given decl. - * - * @requires decl.multiplicity != ONE - * @ensures this.decl' = decl - */ - public HigherOrderDeclException(Decl decl) { - super("Higher order declaration: " + decl); - assert decl.multiplicity() != Multiplicity.ONE; - this.node = decl; - this.isDecl = true; - } - - public HigherOrderDeclException(FixFormula ff) { - super("Fixed point formula: " + ff); - this.node = ff; - this.isDecl = false; - } - - /** - * Returns this.decl - * - * @return this.decl - */ - public Decl decl() { - return isDecl ? (Decl) node : null; - } - - public Node node() { - return node; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/LeafInterpreter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/LeafInterpreter.java deleted file mode 100644 index f41c0ec2c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/LeafInterpreter.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.ConstantExpression; -import kodkod.ast.Expression; -import kodkod.ast.Relation; -import kodkod.engine.bool.BooleanFactory; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.Dimensions; -import kodkod.engine.config.Options; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntRange; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; -import kodkod.util.ints.SparseSequence; - -/** - *

- * Interprets the unquantified leaf expressions of a kodkod ast, - * {@link kodkod.ast.Relation relations} and - * {@link kodkod.ast.ConstantExpression constant expressions}, as - * {@link kodkod.engine.bool.BooleanMatrix matrices} of - * {@link kodkod.engine.bool.BooleanValue boolean values}, and primitive - * integers as corresponding to particular atoms in the - * {@link kodkod.instance.Universe universe of discourse} - *

- * - * @specfield universe: Universe - * @specfield relations: set Relation - * @specfield ints: set int - * @specfield lbounds: relations ->one TupleSet - * @specfield ubounds: relations ->one TupleSet - * @specfield ibounds: ints -> one TupleSet - * @specfield factory: BooleanFactory - * @specfield vars: relations -> set BooleanVariable - * @invariant all r: relations | r.arity = lbounds[r].arity = ubounds[r].arity - * && ubounds[r].containsAll(lbounds[r]) - * @invariant all r: relations | lbounds[r].atoms + ubounds[r].atoms in universe - * @invariant all r: relations | #vars[r] = ubounds[r].size() - - * lbounds[r].size() - * @invariant all disj r, r': relations | no vars[r] & vars[r'] - * @invariant all i: ints | ibounds[i].arity = ibounds[i].size() = 1 - * @invariant vars[relations] in factory.components - * @author Emina Torlak - */ -final class LeafInterpreter { - - private final BooleanFactory factory; - private final Universe universe; - private final Map vars; - private final Map lowers, uppers; - private final SparseSequence ints; - - /** - * Constructs a new LeafInterpreter using the given values. - * - * @requires lowers.keySet() = uppers.keySet() - * @ensures this.universe' = universe && this.relations' = lowers.keySet() && - * this.ints' = ints.indices && this.factory' = factory && - * this.ubounds' = uppers && this.lbounds' = lowers && this.ibounds' = - * ints - */ - private LeafInterpreter(Universe universe, Map lowers, Map uppers, SparseSequence ints, BooleanFactory factory, Map vars) { - this.universe = universe; - this.lowers = lowers; - this.uppers = uppers; - this.ints = ints; - this.factory = factory; - this.vars = vars; - } - - /** - * Constructs a new LeafInterpreter using the given values. - * - * @requires lowers.keySet() = uppers.keySet() - * @ensures this.universe' = universe && this.relations' = lowers.keySet() && - * this.ints' = ints.indices && this.factory' = factory && - * this.ubounds' = uppers && this.lbounds' = lowers && this.ibounds' = - * ints - */ - @SuppressWarnings("unchecked" ) - private LeafInterpreter(Universe universe, Map rbound, SparseSequence ints, Options options) { - this(universe, rbound, rbound, ints, BooleanFactory.constantFactory(options), Collections.EMPTY_MAP); - } - - /** - * Returns an overapproximating interpreter for the given bounds and options. - * - * @return some l: LeafInterpreter | l.universe = bounds.universe && l.relations - * = bounds.relations() && l.ints = bounds.ints() && l.lbounds = - * l.ubounds = bounds.upperBound && l.ibounds = bounds.intBound && - * l.factory = BooleanFactory.constantFactory(options) && no l.vars - */ - static final LeafInterpreter overapproximating(Bounds bounds, Options options) { - return new LeafInterpreter(bounds.universe(), bounds.upperBounds(), bounds.intBounds(), options); - } - - /** - * Returns an exact leaf interpreter based on the given instance and options. - * - * @return some l: LeafInterpreter | l.universe = instance.universe && - * l.relations = instance.relations() && l.ints = instance.ints() && - * l.lbounds = l.ubounds = instance.relationTuples() && l.ibounds = - * instance.intTuples && l.factory = - * BooleanFactory.constantFactory(options) && no l.vars - */ - static final LeafInterpreter exact(Instance instance, Options options) { - return new LeafInterpreter(instance.universe(), instance.relationTuples(), instance.intTuples(), options); - } - - /** - * Returns an exact interpreter for the given bounds and options. If - * {@code incremental} is true, then the resulting interpreter can - * be {@linkplain #extend(Set, Map, Map) extended} with new bindings. Otherwise, - * the interpreter will throw an exception if extension is attempted. - * - * @return some l: LeafInterpreter | l.universe = bounds.universe && l.relations - * = bounds.relations() && l.ints = bounds.ints() && l.lbounds = - * bounds.lowerBound && l.ubounds = bounds.upperBound && l.ibounds = - * bounds.intBound && l.factory = BooleanFactory.factory(sum(r: - * l.relations | #(l.ubounds[r]-l.lbounds[r]))-1, options) && - * l.vars[relations] = l.factory & BooleanVariable - */ - static final LeafInterpreter exact(Bounds bounds, Options options, boolean incremental) { - final Map vars = new LinkedHashMap(); - final Map lowers = incremental ? new LinkedHashMap(bounds.lowerBounds()) : bounds.lowerBounds(); - final Map uppers = incremental ? new LinkedHashMap(bounds.upperBounds()) : bounds.upperBounds(); - final int numVars = allocateVars(1, vars, bounds.relations(), lowers, uppers); - return new LeafInterpreter(bounds.universe(), lowers, uppers, bounds.intBounds(), BooleanFactory.factory(numVars, options), vars); - } - - /** - * Returns an empty interpreter which cannot be - * {@linkplain #extend(Set, Map, Map) extended} with new mappings. - * - * @return some l: LeafInterpreter | l.universe = universe && no l.relations && - * no l.ints && l.factory = BooleanFactory.constantFactory(options) - */ - @SuppressWarnings("unchecked" ) - static final LeafInterpreter empty(Universe universe, Options options) { - return new LeafInterpreter(universe, (Map) Collections.EMPTY_MAP, (SparseSequence) Ints.EMPTY_SEQUENCE, options); - } - - /** - * Populates the {@code vars} map with bindings from each relation in - * {@code rels} to an integer range, which specifies the identifiers of the - * variables used to encode the contents of that relation. The resulting integer - * ranges put together form a complete range that starts at {@code minVar}. - * - * @requires lowers.universe = uppers.universe - * @requires all r: rels | lowers.get(r).tuples in uppers.get(r).tuples - * @ensures vars.map' = vars.map ++ { r: rels, v: IntRange | v.size() = - * uppers.get(r).size() - lowers.get(r).size() && v.size() > 0 } - * @ensures min(vars.map'[rels]) = minVar && max(vars.map'[rels]) = minVar + - * (sum r: rels | vars.map'[r].size()) - 1 - * @return sum r: rels | vars.map'[r].size() - */ - private static int allocateVars(int minVar, Map vars, Set rels, Map lowers, Map uppers) { - int maxLit = minVar; - for (Relation r : rels) { - int rLits = uppers.get(r).size() - lowers.get(r).size(); - if (rLits > 0) { - vars.put(r, Ints.range(maxLit, maxLit + rLits - 1)); - maxLit += rLits; - } - } - return maxLit - minVar; - } - - /** - * Returns this.factory. - * - * @return this.factory. - */ - public final BooleanFactory factory() { - return this.factory; - } - - /** - * Returns the universe of discourse. - * - * @return this.universe - */ - public final Universe universe() { - return universe; - } - - /** - * Returns this.vars. - * - * @return this.vars. - */ - public final Map vars() { - final Map ret = new LinkedHashMap((vars.size() * 4) / 3); - for (Map.Entry e : vars.entrySet()) { - ret.put(e.getKey(), Ints.rangeSet(e.getValue())); - } - return ret; - } - - /** - * Returns a set view of the variables assigned to the given relation, or empty - * set if no variables were assigned to the given relation. - * - * @return this.vars[r] - */ - public final IntSet vars(Relation r) { - final IntRange v = vars.get(r); - return v == null ? Ints.EMPTY_SET : Ints.rangeSet(v); - } - - /** - * Extends this interpreter with interpretations for the given relations, based - * on the specified lower and upper bound on each relation's value. Note that - * this method may fail if the underlying boolean factory does not permit - * introduction of new variables. - * - * @requires no rels & this.relations - * @requires rels in lowers.keySet() && rels in uppers.keySet() - * @requires all r: rels | let lr = lowers.get(r), ur = uppers.get(r) | - * lr.tuples in ur.tuples && lr.universe = ur.universe = this.universe - * @ensures this.relations' = this.relations + rels && this.lbounds' = - * this.lbounds + rels<:(lowers.map) && this.ubounds' = this.ubounds + - * rels<:(uppers.map) && let newVars = this.factory.components' - - * this.factory.components | newVars in BooleanVariable && #newVars = - * (sum r: rels | uppers.get(r).size() - lowers.get(r).size()) && - * (this.vars' - this.vars) in rels -> newVars - * @return this - */ - public final void extend(Set rels, Map lowers, Map uppers) { - for (Relation r : rels) { - this.lowers.put(r, lowers.get(r)); - this.uppers.put(r, uppers.get(r)); - } - factory.addVariables(allocateVars(factory.maxFormula() + 1, vars, rels, lowers, uppers)); - } - - /** - * Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of - * {@link kodkod.engine.bool.BooleanValue boolean formulas} representing the - * specified relation. - * - * @requires r in this.relations - * @return { m: BooleanMatrix | let lset = - * (this.rBounds[r].TupleSet).tuples.index, hset = - * (this.rBounds[r][TupleSet]).tuples.index, dset = - * [0..this.universe.size()^r.arity) | m.dimensions.dimensions = - * [0..r.arity) ->one this.universe.size() && m.elements[lset] = TRUE && - * m.elements[dset-hset] = FALSE && all disj i, j: hset-lset | - * m.elements[i]+m.elements[j] in this.vars[r] && m.elements[i].label < - * m.elements[j].label <=> i < j } - * @throws UnboundLeafException r !in this.relations - */ - public final BooleanMatrix interpret(Relation r) { - if (!lowers.containsKey(r)) - throw new UnboundLeafException("Unbound relation: ", r); - final IntSet lowerBound = lowers.get(r).indexView(); - final IntSet upperBound = uppers.get(r).indexView(); - - final BooleanMatrix m = factory.matrix(Dimensions.square(universe().size(), r.arity()), upperBound, lowerBound); - - if (upperBound.size() > lowerBound.size()) { - int varId = vars.get(r).min(); - for (IntIterator indeces = upperBound.iterator(); indeces.hasNext();) { - int tupleIndex = indeces.next(); - if (!lowerBound.contains(tupleIndex)) - m.set(tupleIndex, factory.variable(varId++)); - } - } - return m; - } - - /** - * Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of - * {@link kodkod.engine.bool.BooleanValue boolean formulas} representing the - * specified constant expression. - * - * @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity) | - * m.dimensions.dimensions = [0..c.arity) ->one this.universe.size() && - * c = UNIV => m.elements[dset] = TRUE, c = NONE => m.elements[dset] = - * FALSE, c = IDEN => (all i: dset | (some j: int | i = - * j*(1+this.universe.size())) => m.elements[i] = TRUE, m.elements[i] = - * FALSE), c = INT => (all i: dset | (some j: int | this.interpret(j)=i) - * => m.elements[i] = TRUE, m.elements[i] = FALSE } - */ - public final BooleanMatrix interpret(ConstantExpression c) { - final int univSize = universe().size(); - if (c == Expression.UNIV) { - final IntSet all = Ints.rangeSet(Ints.range(0, univSize - 1)); - return factory().matrix(Dimensions.square(univSize, 1), all, all); - } else if (c == Expression.IDEN) { - final Dimensions dim2 = Dimensions.square(univSize, 2); - final IntSet iden = Ints.bestSet(dim2.capacity()); - for (int i = 0; i < univSize; i++) { - iden.add(i * univSize + i); - } - return factory().matrix(dim2, iden, iden); - } else if (c == Expression.NONE) { - return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET); - } else if (c == Expression.INTS) { - final IntSet ints = Ints.bestSet(univSize); - for (IntIterator iter = ints().iterator(); iter.hasNext();) { - ints.add(interpret(iter.next())); - } - return factory().matrix(Dimensions.square(univSize, 1), ints, ints); - } else { - throw new IllegalArgumentException("unknown constant expression: " + c); - } - } - - /** - * Returns the set of all integers corresponding to some atom in this.universe. - * - * @return this.ints - */ - public final IntSet ints() { - return ints.indices(); - } - - /** - * Returns the index of the atom from this.universe which represents the given - * integer. - * - * @requires i in this.ints - * @return this.ibounds[i].indexView().min() - */ - public final int interpret(int i) { - return ints.get(i).indexView().min(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/MemoryLogger.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/MemoryLogger.java deleted file mode 100644 index 944157736..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/MemoryLogger.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.engine.Solver; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.BooleanValue; -import kodkod.instance.Bounds; -import kodkod.instance.TupleSet; -import kodkod.util.collections.FixedMap; -import kodkod.util.nodes.AnnotatedNode; -import kodkod.util.nodes.Nodes; - -/** - * A translation logger that logs translation events for the - * {@linkplain Nodes#conjuncts(Formula) conjuncts} of a given formula to memory. - * In other words, this logger only logs the translations for the children of - * the given formula, if the formula is a conjunction. Otherwise, it simply logs - * the translation for the formula itself. The translation events for the - * conjuncts' descendants are ignored. - * - * @specfield originalFormula: Formula // the - * {@linkplain Solver#solve(Formula, kodkod.instance.Bounds) - * original} formula, provided by the user - * @specfield originalBounds: Bounds // the - * {@linkplain Solver#solve(Formula, kodkod.instance.Bounds) - * original} bounds, provided by the user - * @specfield formula: Formula // desugaring of this.formula that was translated - * @specfield bounds: Bounds // translation bounds - * @specfield records: (formula.*children & Formula) -> BooleanValue -> - * Environment - * @invariant Solver.solve(formula, bounds).instance() == null iff - * Solver.solve(originalFormula, originalBounds).instance() == null - * @author Emina Torlak - */ -final class MemoryLogger extends TranslationLogger { - - private final FixedMap logMap; - private final AnnotatedNode annotated; - private final Bounds bounds; - - /** - * Constructs a new memory logger from the given annotated formula. - * - * @ensures this.formula' = annotated.node - * @ensures this.bounds' = bounds - * @ensures no this.records' - * @ensures this.log().roots() = Nodes.conjuncts(annotated) - */ - MemoryLogger(final AnnotatedNode annotated, Bounds bounds) { - this.annotated = annotated; - this.bounds = bounds; - this.logMap = new FixedMap(Nodes.conjuncts(annotated.node())); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLogger#close() - */ - @Override - void close() {} - - /** - * Logs the translation of the given formula if and only if f is a root of - * this.formula. - * - * @ensures f in Nodes.conjuncts(this.formula) and no this.records[f] => - * this.records' = this.records ++ f -> translation -> env - * @throws IllegalArgumentException some this.records[f] and this.records[f] != - * translation -> env - * @see kodkod.engine.fol2sat.TranslationLogger#log(kodkod.ast.Formula, - * kodkod.engine.bool.BooleanValue, kodkod.engine.fol2sat.Environment) - */ - @Override - void log(Formula f, BooleanValue translation, Environment env) { - if (logMap.containsKey(f)) { - // assert env.isEmpty(); - final BooleanValue old = logMap.put(f, translation); - if (old != null && old != translation) - throw new IllegalArgumentException("translation of root corresponding to the formula has already been logged: " + f); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLogger#log() - */ - @Override - TranslationLog log() { - return new MemoryLog(annotated, logMap, bounds); - } - - /** - * A memory-based translation log, written by a MemoryLogger. - * - * @author Emina Torlak - */ - private static class MemoryLog extends TranslationLog { - - private final Set roots; - private final Bounds bounds; - private final Node[] original; - private final int[] transl; - - /** - * Constructs a new memory log out of the given node and its corresponding log - * map. - */ - MemoryLog(AnnotatedNode annotated, FixedMap logMap, Bounds bounds) { - this.bounds = bounds; - this.roots = Nodes.conjuncts(annotated.node()); - assert roots.size() == logMap.size(); - this.transl = new int[roots.size()]; - this.original = new Node[roots.size()]; - final Iterator itr = roots.iterator(); - for (int i = 0; i < transl.length; i++) { - final Formula root = itr.next(); - transl[i] = logMap.get(root).label(); - original[i] = annotated.sourceOf(root); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLog#bounds() - */ - @Override - public Bounds bounds() { - return bounds; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLog#replay(kodkod.engine.fol2sat.RecordFilter) - */ - @Override - public Iterator replay(final RecordFilter filter) { - return new Iterator() { - - final Iterator itr = roots.iterator(); - boolean ready = false; - int index = -1; - Formula root = null; - final TranslationRecord current = new TranslationRecord() { - - @Override - public Map env() { - return Collections.emptyMap(); - } - - @Override - public int literal() { - return transl[index]; - } - - @Override - public Node node() { - return original[index]; - } - - @Override - public Formula translated() { - return root; - } - - }; - - @Override - @SuppressWarnings("unchecked" ) - public boolean hasNext() { - while (!ready && itr.hasNext()) { - root = itr.next(); - index++; - if (filter.accept(original[index], root, transl[index], Collections.EMPTY_MAP)) { - ready = true; - break; - } - } - return ready; - } - - @Override - public TranslationRecord next() { - if (!hasNext()) - throw new NoSuchElementException(); - ready = false; - return current; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.TranslationLog#roots() - */ - @Override - public Set roots() { - return roots; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/NestedSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/NestedSet.java deleted file mode 100644 index 2f01b45e4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/NestedSet.java +++ /dev/null @@ -1,57 +0,0 @@ -package kodkod.engine.fol2sat; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -/** - * Implements a data structure that contains sets of values at different nesting - * levels. - * - * @author aleks - */ -@SuppressWarnings("unchecked" ) -public class NestedSet implements Iterable { - - private final NestedSet parent; - private final Set elems; - - private NestedSet(NestedSet parent) { - this(parent, new HashSet()); - } - - private NestedSet(NestedSet parent, Set elems) { - this.parent = parent; - this.elems = elems; - } - - public NestedSet createNested() { - return new NestedSet(this); - } - - public void add(T elem) { - this.elems.add(elem); - } - - public void addAll(Collection< ? extends T> elems) { - this.elems.addAll(elems); - } - - public NestedSet parent() { - return parent; - } - - @Override - public Iterator iterator() { - return elems.iterator(); - } - - @SuppressWarnings("rawtypes" ) - private static final NestedSet EMPTY = new NestedSet(null); - - public static NestedSet empty() { - return EMPTY; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/PrenexNFConverter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/PrenexNFConverter.java deleted file mode 100644 index 9a0eae21d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/PrenexNFConverter.java +++ /dev/null @@ -1,190 +0,0 @@ -package kodkod.engine.fol2sat; - -import java.util.ArrayList; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.Formula; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.AbstractReplacer; -import kodkod.util.nodes.AnnotatedNode; -import kodkod.util.nodes.Nodes; - -/* - * TODO: - * what if we have something like - * - * some N && - * all n: N | ... - * - * That is not necessarily equisatisfiable to - * - * all n: N | - * some N && - * ... - * - * Potential solution: - * check that there are no constraints on quantification domains - */ -public class PrenexNFConverter extends AbstractReplacer { - - public static AnnotatedNode toPNF(AnnotatedNode annotated) { - final PrenexNFConverter pnfConv = new PrenexNFConverter(annotated.sharedNodes()); - List conj = new ArrayList(); - for (Formula f : Nodes.allConjuncts(annotated.node(), null)) - conj.add(f.accept(pnfConv)); - Formula ans = Formula.and(conj); - - final List roots = new ArrayList(pnfConv.annotations.size()); - roots.addAll(pnfConv.annotations.keySet()); - for (Iterator> itr = pnfConv.annotations.entrySet().iterator(); itr.hasNext();) { - final Map.Entry entry = itr.next(); - final Node source = annotated.sourceOf(entry.getValue()); - if (entry.getKey() == source) { - itr.remove(); - } else { - entry.setValue(source); - } - } - - return AnnotatedNode.annotate(ans, pnfConv.annotations); - } - - private Map annotations; - - public PrenexNFConverter(Set shared) { - super(shared, new IdentityHashMap()); - this.annotations = new LinkedHashMap(); - } - - @Override - public Formula visit(BinaryFormula bf) { - Formula ans; - switch (bf.op()) { - case AND : - case OR : - Formula left = bf.left().accept(this); - Formula right = bf.right().accept(this); - Pair p = new Pair(left, right); - if (p.hasNoQuant() && left == bf.left() && right == bf.right()) - ans = bf; - else - ans = p.compose(bf.op()); - break; - case IMPLIES : - ans = bf.left().not().or(bf.right()).accept(this); - break; - case IFF : - ans = bf.left().and(bf.right()).or(bf.left().not().and(bf.right().not())).accept(this); - break; - default : - throw new IllegalStateException("Unknown BinaryFormula operator: " + bf.op()); - } - return saveMapping(ans, bf); - } - - @Override - public Formula visit(NotFormula not) { - Formula sub = not.formula().accept(this); - Pair p = new Pair(sub, null); - Formula ans; - if (p.hasNoQuant() && sub == not.formula()) - ans = not; - else if (p.hasNoQuant()) - ans = sub.not(); - else - ans = pushNegation(p.leftQF); - return saveMapping(ans, not); - } - - @Override - public Formula visit(NaryFormula formula) { - final ArrayList children = new ArrayList(formula.size()); - boolean allSame = true; - boolean noQuant = true; - for (Formula ch : formula) { - Formula ch2 = ch.accept(this); - allSame = allSame && ch == ch2; - noQuant = noQuant && !(ch2 instanceof QuantifiedFormula); - children.add(ch2); - } - Formula ans; - if (allSame && noQuant) { - ans = formula; - } else { - ans = children.get(0); - for (int i = 1; i < children.size(); i++) - ans = new Pair(ans, children.get(i)).compose(formula.op()); - } - return saveMapping(ans, formula); - } - - protected Formula pushNegation(QuantifiedFormula f) { - return pushNegation(f.formula()).quantify(f.quantifier().opposite, f.decls()); - } - - protected Formula pushNegation(Formula f) { - if (f instanceof QuantifiedFormula) - return pushNegation((QuantifiedFormula) f); - return f.not(); - } - - protected Formula saveMapping(Formula f, Node source) { - annotations.put(f, source); - return f; - } - - class Pair { - - public final Formula left; - public final QuantifiedFormula leftQF; - public final Formula right; - public final QuantifiedFormula rightQF; - - Pair(Formula left, Formula right) { - this.left = left; - this.leftQF = (left instanceof QuantifiedFormula) ? (QuantifiedFormula) left : null; - this.right = right; - this.rightQF = (right instanceof QuantifiedFormula) ? (QuantifiedFormula) right : null; - } - - boolean hasNoQuant() { - return leftQF == null && rightQF == null; - } - - Formula compose(FormulaOperator op) { - if (leftQF == null && rightQF == null) { - return left.compose(op, right); - } else if (leftQF != null && rightQF != null) { - // TODO do var renaming - QuantifiedFormula l = leftQF, r = rightQF; - if (r.decls().get(0).multiplicity() == Multiplicity.SET && l.decls().get(0).multiplicity() != Multiplicity.SET) { - l = rightQF; - r = leftQF; - } - Formula newBody = l.formula().compose(op, r.formula()); - return newBody.quantify(r.quantifier(), r.decls()).quantify(l.quantifier(), l.decls()); - } else { - // TODO do var renaming - QuantifiedFormula qf = leftQF != null ? leftQF : rightQF; - // Formula other = leftQF != null ? right: left; - // TODO: check that other doesn't constraint qf.decls.expression - Formula leftBody = leftQF != null ? leftQF.formula() : left; - Formula rightBody = rightQF != null ? rightQF.formula() : right; - Formula newBody = new Pair(leftBody, rightBody).compose(op); - return newBody.quantify(qf.quantifier(), qf.decls()); - } - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/RecordFilter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/RecordFilter.java deleted file mode 100644 index 456e7b894..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/RecordFilter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Map; - -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.instance.TupleSet; - -/** - * A filter for TranslationRecords, based on the value of a record's node and - * literal fields. - **/ -public interface RecordFilter { - - /** - * Returns true if the records with the given node, formula derived from the - * node, literal, and environment should be returned by iterators produced by - * the {@linkplain TranslationLog#replay()} method. - * - * @return true if the records with the given node, formula derived from the - * node, literal, and environment should be returned by iterators - * produced by {@linkplain TranslationLog#replay()}. - */ - public abstract boolean accept(Node node, Formula translated, int literal, Map env); - - /** - * A record filter that accepts all records. - */ - public static RecordFilter ALL = new RecordFilter() { - - /** - * Returns true. - * - * @return true - */ - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return true; - } - }; - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Skolemizer.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Skolemizer.java deleted file mode 100644 index 8400441fd..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Skolemizer.java +++ /dev/null @@ -1,667 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import static kodkod.ast.operator.FormulaOperator.AND; -import static kodkod.ast.operator.FormulaOperator.IFF; -import static kodkod.ast.operator.FormulaOperator.IMPLIES; -import static kodkod.ast.operator.FormulaOperator.OR; -import static kodkod.ast.operator.Quantifier.ALL; -import static kodkod.ast.operator.Quantifier.SOME; -import static kodkod.util.nodes.AnnotatedNode.annotate; - -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntExpression; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.AbstractDetector; -import kodkod.ast.visitor.AbstractReplacer; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.config.Options; -import kodkod.engine.config.Reporter; -import kodkod.instance.Bounds; -import kodkod.instance.TupleSet; -import kodkod.util.nodes.AnnotatedNode; - -/** - * Skolemizes existential quantifiers, up to a given number of nestings (within - * universal quantifiers). - * - * @author Emina Torlak - */ -public abstract class Skolemizer extends AbstractReplacer { - - /** - * Skolemizes the given annotated formula using the given bounds and options. If - * Options.logTranslation is set and the formula is skolemizable, the resulting - * annotated formula will contain transitive source information for each of its - * subformulas. Specifically, let f be the returned annotated formula, t be a - * descendant of f.node, and s a descendant of annotated.node from which t was - * derived. Then, f.source[t] = annotated.source[s]. If options.logTranslation - * is false, no source information will be recorded (i.e. f.source[t] = t for - * all descendants t of f). - * - * @ensures upper bound mappings for skolem constants, if any, are added to the - * bounds - * @return the skolemized version of the given formula - * @throws NullPointerException any of the arguments are null - * @throws IllegalArgumentException some Relation & annotated.node.^children - - * bounds.relations - * @throws UnsupportedOperationException bounds is unmodifiable - */ - public static AnnotatedNode skolemize(final AnnotatedNode annotated, Bounds bounds, Options options) { - if (options.logTranslation() > 0) { - final Map source = new IdentityHashMap(); - final Skolemizer r = new Skolemizer(annotated, bounds, options) { - - @Override - protected Formula source(Formula f, Node n) { - // System.out.println("logging " + f + " <-- " + n); - final Node nsource = annotated.sourceOf(n); - if (f != nsource) - source.put(f, nsource); - return f; - } - }; - final Formula f = annotated.node().accept(r); - return f == annotated.node() ? annotated : annotate(f, source); - } else { - final Skolemizer r = new Skolemizer(annotated, bounds, options) {}; - final Formula f = annotated.node().accept(r); - return f == annotated.node() ? annotated : annotate(f); - } - } - - /** - * Contains info about an approximate bound for a non-skolemizable decl. - * - * @specfield decl: Decl - * @specfield upperBound: lone BooleanMatrix - * @invariant decl.expression in upperBound - * @author Emina Torlak - */ - private static final class DeclInfo { - - final Decl decl; - BooleanMatrix upperBound; - - /** - * Constructs a DeclInfo for the given decl. - * - * @ensures this.decl' = decl && this.upperBound' = null - */ - DeclInfo(Decl decl) { - this.decl = decl; - this.upperBound = null; - } - } - - /* - * replacement environment; maps skolemized variables to their skolem - * expressions, and non-skolemized variables to themselves - */ - private Environment repEnv; - /* - * the interpreter used to determine the upper bounds for skolem constants; the - * upper bounds for skolem constants will be added to interpreter.bounds - */ - private final LeafInterpreter interpreter; - /* bounds on which the interpreter is based */ - private final Bounds bounds; - /* reporter */ - private final Reporter reporter; - /* - * non-skolemizable quantified declarations in the current scope, in the order - * of declaration (most recent decl is last in the list) - */ - private final List nonSkolems; - /* a Decl-only view of the nonSkolems list */ - private final List nonSkolemsView; - private final List topSkolemConstraints; - /* - * true if the polarity of the currently visited node is negative, otherwise - * false - */ - private boolean negated; - /* - * depth to which to skolemize; negative depth indicates that no skolemization - * can be done at that point - */ - private int skolemDepth; - - /** - * Constructs a skolem replacer from the given arguments. - */ - private Skolemizer(AnnotatedNode annotated, Bounds bounds, Options options) { - super(annotated.sharedNodes()); - - // only cache intermediate computations for expressions with no free - // variables - // and formulas with no free variables and no quantified descendents - for (Node n : annotated.sharedNodes()) { - final AbstractDetector fvdetect = annotated.freeVariableDetector(); - final AbstractDetector qdetect = annotated.quantifiedFormulaDetector(); - if (!(Boolean) n.accept(fvdetect)) { - if (!(n instanceof Formula) || !((Boolean) n.accept(qdetect))) - this.cache.put(n, null); - } - } - this.reporter = options.reporter(); - this.bounds = bounds; - this.interpreter = LeafInterpreter.overapproximating(bounds, options); - this.repEnv = Environment.empty(); - this.nonSkolems = new ArrayList(); - this.nonSkolemsView = new AbstractList() { - - @Override - public Decl get(int index) { - return nonSkolems.get(index).decl; - } - - @Override - public int size() { - return nonSkolems.size(); - } - }; - this.topSkolemConstraints = new ArrayList(); - this.negated = false; - this.skolemDepth = options.skolemDepth(); - } - - /** - * Caches the given replacement for the specified node, if the node is a - * syntactically shared expression, int expression or declaration with no free - * variables. Otherwise does nothing. The method returns the replacement node. - * - * @return replacement - */ - @Override - protected final N cache(N node, N replacement) { - if (cache.containsKey(node)) { - cache.put(node, replacement); - } - return replacement; - } - - /** - * Records that the given node is the source of the specified formula, if this - * is a tracking skolemizer. Otherwise does nothing. This method is always - * called when the result of visiting a node n will result in the creation of a - * formula f such that f != n. - * - * @return f - * @ensures Records that the given node is the source of the specified formula, - * if this is a tracking skolemizer. Otherwise does nothing. - */ - protected Formula source(Formula f, Node n) { - return f; - } - - /*-------declarations---------*/ - /** - * Visits the given decl's expression. Note that we must not visit variables in - * case they are re-used. For example, consider the formula some x: X | all x: Y - * | F(x). Since x bound by the existential quantifier is going to be - * skolemized, if we visited the variable in the enclosed declaration, we would - * get the skolem constant as a return value and a ClassCastException would be - * thrown. - * - * @return { d: Declaration | d.variable = decl.variable && d.multiplicity = - * decl.multiplicity && d.expression = decl.expression.accept(this) } - */ - @Override - public final Decl visit(Decl decl) { - Decl ret = lookup(decl); - if (ret != null) - return ret; - final int oldDepth = skolemDepth; - skolemDepth = -1; // can't skolemize inside a decl - final Expression expression = decl.expression().accept(this); - skolemDepth = oldDepth; - ret = (expression == decl.expression()) ? decl : decl.variable().declare(decl.multiplicity(), expression); - return cache(decl, ret); - } - - /** - * This method should be accessed only from the context of a non-skolemizable - * node, because it extends the replacement environment with identity mappings - * for the variables declared in the given decls. To ensure that the environment - * is always extended, the method should be called using the visit((Decls) - * node.declarations()) syntax, since the accept syntax may dynamically dispatch - * the call to the {@link #visit(Decl)} method, producing UnboundLeafExceptions. - * - * @ensures this.repEnv in this.repEnv'.^parent && #(this.repEnv'.*parent - - * this.repEnv.*parent) = decls.size() && all v: decls.variable | - * this.repEnv'.lookup(v) = v - * @requires this.skolemDepth < 0 - * @return { d: Decls | d.size = decls.size && all i: [0..d.size) | - * d.declarations[i] = decls.declarations[i].accept(this) } - */ - @Override - public final Decls visit(Decls decls) { - Decls ret = lookup(decls); - if (ret == null) { - Decls visitedDecls = null; - boolean allSame = true; - for (Decl decl : decls) { - Decls newDecl = visit(decl); - if (newDecl != decl) - allSame = false; - visitedDecls = (visitedDecls == null) ? newDecl : visitedDecls.and(newDecl); - repEnv = repEnv.extend(decl.variable(), decl.expression(), decl.variable()); - } - ret = allSame ? decls : visitedDecls; - return cache(decls, ret); - } else { // just extend the replacement environment - for (Decl decl : decls) { - repEnv = repEnv.extend(decl.variable(), decl.expression(), decl.variable()); - } - return ret; - } - } - - /*-------expressions and intexpressions---------*/ - /* - * INVARIANT: whenever an expression or intexpression is visited, skolemDepth < - * 0 - */ - /** - * Returns the binding for the given variable in the current replacement - * environment. - * - * @return the binding for the given variable in the current replacement - * environment. - * @throws UnboundLeafException variable not bound in teh replacement - * environment. - */ - @Override - public final Expression visit(Variable variable) { - final Expression ret = repEnv.lookup(variable); - if (ret == null) - throw new UnboundLeafException("Unbound variable", variable); - return ret; - } - - /** - * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.Comprehension) - */ - @Override - public final Expression visit(Comprehension expr) { - Expression ret = lookup(expr); - if (ret != null) - return ret; - final Environment oldRepEnv = repEnv; // skolemDepth - // < 0 - // at - // this - // point - final Decls decls = visit(expr.decls()); - final Formula formula = expr.formula().accept(this); - ret = (decls == expr.decls() && formula == expr.formula()) ? expr : formula.comprehension(decls); - repEnv = oldRepEnv; - return cache(expr, ret); - } - - /** - * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.SumExpression) - */ - @Override - public final IntExpression visit(SumExpression intExpr) { - IntExpression ret = lookup(intExpr); - if (ret != null) - return ret; - final Environment oldRepEnv = repEnv; // skolemDepth - // < 0 - // at - // this - // point - final Decls decls = visit(intExpr.decls()); - final IntExpression expr = intExpr.intExpr().accept(this); - ret = (decls == intExpr.decls() && expr == intExpr.intExpr()) ? intExpr : expr.sum(decls); - repEnv = oldRepEnv; - return cache(intExpr, ret); - } - - /*-------formulas---------*/ - /** - * Returns the least sound upper bound on the value of expr - * - * @return the least sound upper bound on the value of expr - */ - private final BooleanMatrix upperBound(Expression expr, Environment env) { - return FOL2BoolTranslator.approximate(annotate(expr), interpreter, env); - } - - /** - * Adds a bound for the given skolem relation to this.bounds, and returns the - * expression that should replace skolemDecl.variable in the final formula. - * - * @requires skolem !in this.bounds.relations - * @requires skolem.arity = nonSkolems.size() + skolemDecl.variable().arity() - * @ensures adds a sound upper bound for the given skolem relation to - * this.bounds - * @return the expression that should replace skolemDecl.variable in the final - * formula - */ - private Expression skolemExpr(Decl skolemDecl, Relation skolem) { - final int depth = nonSkolems.size(); - final int arity = depth + skolemDecl.variable().arity(); - - Expression skolemExpr = skolem; - Environment skolemEnv = Environment.empty(); - - for (DeclInfo info : nonSkolems) { - if (info.upperBound == null) { - info.upperBound = upperBound(info.decl.expression(), skolemEnv); - } - skolemEnv = skolemEnv.extend(info.decl.variable(), info.decl.expression(), info.upperBound); - skolemExpr = info.decl.variable().join(skolemExpr); - } - - BooleanMatrix matrixBound = upperBound(skolemDecl.expression(), skolemEnv); - for (int i = depth - 1; i >= 0; i--) { - matrixBound = nonSkolems.get(i).upperBound.cross(matrixBound); - } - - final TupleSet skolemBound = bounds.universe().factory().setOf(arity, matrixBound.denseIndices()); - bounds.bound(skolem, skolemBound); - - return skolemExpr; - } - - /** - * Returns a formula that properly constrains the given skolem's domain. - * - * @requires !nonSkolems.isEmpty() - * @return a formula that properly constrains the given skolem's domain. - */ - private Formula domainConstraint(Decl skolemDecl, Relation skolem) { - final Iterator itr = nonSkolems.iterator(); - Decls rangeDecls = null; - while (itr.hasNext()) { - Decl d = itr.next().decl; - Decl dd = d.variable().oneOf(d.expression()); - rangeDecls = rangeDecls != null ? rangeDecls.and(dd) : dd; - } - // System.out.println(skolemDecl.expression()); - Expression skolemDomain = skolem; - for (int i = 0, max = skolemDecl.variable().arity(); i < max; i++) { - skolemDomain = skolemDomain.join(Expression.UNIV); - } - return skolemDomain.in(Formula.TRUE.comprehension(rangeDecls)); - } - - /** - * Skolemizes the given formula, if possible, otherwise returns the result of - * replacing its free variables according to the current replacement - * environment. - * - * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.QuantifiedFormula) - */ - @Override - public final Formula visit(QuantifiedFormula qf) { - Formula ret = lookup(qf); - if (ret != null) - return ret; - - final Environment oldRepEnv = repEnv; - final Quantifier quant = qf.quantifier(); - final Decls decls = qf.decls(); - - if (skolemDepth >= 0 && (negated && quant == ALL || !negated && quant == SOME)) { // skolemizable - // formula - final List rangeConstraints = new LinkedList(); - final List domConstraints = new LinkedList(); - - for (Decl decl : decls) { - final Decl skolemDecl = visit(decl); - - Variable skVar = skolemDecl.variable(); - final Relation skolem = Relation.skolem("$" + skVar.name(), nonSkolems.size() + skVar.arity(), skVar, skolemDecl, quant); - reporter.skolemizing(decl, skolem, nonSkolemsView); - - final Expression skolemExpr = skolemExpr(skolemDecl, skolem); - - final Multiplicity mult = decl.multiplicity(); - rangeConstraints.add(source(skolemExpr.in(skolemDecl.expression()), decl)); - if (mult != Multiplicity.SET) { - rangeConstraints.add(source(skolemExpr.apply(mult), decl)); - } - - if (!nonSkolems.isEmpty()) - domConstraints.add(source(domainConstraint(skolemDecl, skolem), decl)); - - repEnv = repEnv.extend(decl.variable(), decl.expression(), skolemExpr); - } - - ret = source(Formula.and(rangeConstraints), decls).compose(negated ? IMPLIES : AND, qf.formula().accept(this)); - - if (!domConstraints.isEmpty()) - topSkolemConstraints.add(source(Formula.and(domConstraints), decls)); - - } else { // non-skolemizable formula - - final Decls newDecls = visit(qf.decls()); - if (skolemDepth >= nonSkolems.size() + newDecls.size()) { // could - // skolemize - // below - for (Decl d : newDecls) { - nonSkolems.add(new DeclInfo(d)); - } - final Formula domain = qf.domain().accept(this); - final Formula body = qf.body().accept(this); - ret = ((newDecls == decls && domain == qf.domain() && body == qf.body()) ? qf : body.quantify(quant, newDecls, domain)); - for (int i = newDecls.size(); i > 0; i--) { - nonSkolems.remove(nonSkolems.size() - 1); - } - } else { // can't skolemize below - final int oldDepth = skolemDepth; - skolemDepth = -1; - final Formula domain = qf.domain().accept(this); - final Formula body = qf.body().accept(this); - ret = ((newDecls == decls && domain == qf.domain() && body == qf.body()) ? qf : body.quantify(quant, newDecls, domain)); - skolemDepth = oldDepth; - } - } - - repEnv = oldRepEnv; - if (repEnv.isEmpty() && !topSkolemConstraints.isEmpty()) { - ret = source(Formula.and(topSkolemConstraints), qf).compose(negated ? IMPLIES : AND, ret); - } - return source(cache(qf, ret), qf); - } - - /** - * Calls not.formula.accept(this) after flipping the negation flag and returns - * the result. - * - * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.NotFormula) - **/ - @Override - public final Formula visit(NotFormula not) { - Formula ret = lookup(not); - if (ret != null) - return ret; - negated = !negated; // flip the negation flag - final Formula retChild = not.formula().accept(this); - negated = !negated; - return retChild == not.formula() ? cache(not, not) : source(cache(not, retChild.not()), not); - } - - /** - * If not cached, visits the formula's children with appropriate settings for - * the negated flag and the skolemDepth parameter. - * - * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.BinaryFormula) - */ - @Override - public final Formula visit(BinaryFormula bf) { - Formula ret = lookup(bf); - if (ret != null) - return ret; - final FormulaOperator op = bf.op(); - final int oldDepth = skolemDepth; - if (op == IFF || (negated && op == AND) || (!negated && (op == OR || op == IMPLIES))) { // cannot - // skolemize - // in - // these - // cases - skolemDepth = -1; - } - final Formula left, right; - if (negated && op == IMPLIES) { // !(a => b) = !(!a || b) = a && !b - negated = !negated; - left = bf.left().accept(this); - negated = !negated; - right = bf.right().accept(this); - } else { - left = bf.left().accept(this); - right = bf.right().accept(this); - } - skolemDepth = oldDepth; - ret = (left == bf.left() && right == bf.right()) ? bf : left.compose(op, right); - return source(cache(bf, ret), bf); - } - - /** - * If not cached, visits the formula's children with appropriate settings for - * the negated flag and the skolemDepth parameter. - * - * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.NaryFormula) - */ - @Override - public final Formula visit(NaryFormula bf) { - Formula ret = lookup(bf); - if (ret != null) - return ret; - - final int oldDepth = skolemDepth; - final FormulaOperator op = bf.op(); - - switch (op) { - case AND : - if (negated) - skolemDepth = -1; - break; - case OR : - if (!negated) - skolemDepth = -1; - break; - default : - throw new IllegalArgumentException("Unknown nary operator: " + op); - } - - final Formula[] visited = new Formula[bf.size()]; - boolean allSame = true; - for (int i = 0; i < visited.length; i++) { - final Formula child = bf.child(i); - visited[i] = child.accept(this); - allSame = allSame && (child == visited[i]); - } - ret = allSame ? bf : Formula.compose(op, visited); - - skolemDepth = oldDepth; - - return source(cache(bf, ret), bf); - } - - /** - * Calls super.visit(icf) after disabling skolemization and returns the result. - * - * @return super.visit(icf) - **/ - @Override - public final Formula visit(IntComparisonFormula icf) { - final int oldDepth = skolemDepth; - skolemDepth = -1; // cannot skolemize inside an int comparison formula - final Formula ret = super.visit(icf); - skolemDepth = oldDepth; - return source(ret, icf); - } - - /** - * Calls super.visit(cf) after disabling skolemization and returns the result. - * - * @return super.visit(cf) - **/ - @Override - public final Formula visit(ComparisonFormula cf) { - final int oldDepth = skolemDepth; - skolemDepth = -1; // cannot skolemize inside a comparison formula - final Formula ret = super.visit(cf); - skolemDepth = oldDepth; - return source(ret, cf); - } - - /** - * Calls super.visit(mf) after disabling skolemization and returns the result. - * - * @return super.visit(mf) - **/ - @Override - public final Formula visit(MultiplicityFormula mf) { - final int oldDepth = skolemDepth; - skolemDepth = -1; // cannot skolemize inside a multiplicity formula - final Formula ret = super.visit(mf); - skolemDepth = oldDepth; - return source(ret, mf); - } - - /** - * Calls super.visit(pred) after disabling skolemization and returns the result. - * - * @return super.visit(pred) - **/ - @Override - public final Formula visit(RelationPredicate pred) { - final int oldDepth = skolemDepth; - skolemDepth = -1; // cannot skolemize inside a relation predicate - final Formula ret = super.visit(pred); - skolemDepth = oldDepth; - return source(ret, pred); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/SymmetryBreaker.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/SymmetryBreaker.java deleted file mode 100644 index e1ce05dcc..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/SymmetryBreaker.java +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import static kodkod.ast.RelationPredicate.Name.ACYCLIC; -import static kodkod.ast.RelationPredicate.Name.TOTAL_ORDERING; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.RelationPredicate.Name; -import kodkod.engine.bool.BooleanAccumulator; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanFactory; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.BooleanValue; -import kodkod.engine.bool.Operator; -import kodkod.engine.config.Options; -import kodkod.engine.config.Reporter; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; -import kodkod.util.nodes.AnnotatedNode; - -/** - * Breaks symmetries for a given problem. Symmetries are broken for total - * orders, acyclic relations, and via a generic lex-leader predicate. - * - * @specfield bounds: Bounds // problem bounds - * @specfield symmetries: set IntSet - * @specfield broken: set RelationPredicate - * @author Emina Torlak - */ -public final class SymmetryBreaker { - - private final Bounds bounds; - private final Set symmetries; - private final int usize; - private final AnnotatedNode formula; - - /** - * Constructs a new symmetry breaker for the given Bounds, and calls the given - * reporter's {@linkplain Reporter#detectedSymmetries(Set)} method with the - * detected symmetries. Note that the constructor does not make a local copy - * of the given bounds, so the caller must ensure that all modifications of the - * given bounds are symmetry preserving. - * - * @ensures reporter.detectedSymmetries(this.symmteries') - * @ensures this.bounds' = bounds && this.symmetries' = - * SymmetryDetector.partition(bounds) && no this.broken' - **/ - public SymmetryBreaker(Bounds bounds, AnnotatedNode annotated, Reporter reporter) { - this.bounds = bounds; - this.formula = annotated; - this.usize = bounds.universe().size(); - reporter.detectingSymmetries(bounds); - this.symmetries = SymmetryDetector.partition(bounds, formula != null ? formula.atomRelations() : null, null); - reporter.detectedSymmetries(symmetries); - // System.out.println(symmetries); - } - - public SymmetryBreaker(Bounds bounds, Reporter reporter) { - this(bounds, null, reporter); - } - - /** - * Breaks matrix symmetries on the relations in this.bounds that are constrained - * by the total ordering and acyclic predicates, drawn from preds.values(), that - * make up the keyset of the returned map. After this method returns, the - * following constraint holds. Let m be the map returned by the method, and - * m.keySet() be the subset of preds.values() used for symmetry breaking. Then, - * if we let [[b]] denote the set of constraints specified by a Bounds object b, - * the formulas "p and [[this.bounds]]" and "m.get(p) and [[this.bounds']]" are - * equisatisfiable for all p in m.keySet(). - *

- * The value of the "aggressive" flag determines how the symmetries are broken. - * In particular, if the aggressive flag is true, then the symmetries are broken - * efficiently, at the cost of losing the information needed to determine - * whether a predicate in m.keySet() belongs to an unsatisfiable core or not. If - * the aggressive flag is false, then a less efficient algorithm is applied, - * which preserves the information necessary for unsatisfiable core extraction. - *

- *

- * The aggressive symmetry breaking algorithm works as follows. Let t1...tn and - * c1...ck be the total ordering and acyclic predicates in m.keySet(). For each - * t in {t1...tn}, this.bounds is modified so that the bounds for t.first, - * t.last, t.ordered and t.relation are the following constants: t.first is the - * first atom in the upper bound of t.ordered, t.last is the last atom in the - * upper bound of t.ordered, t.ordered's lower bound is changed to be equal to - * its upper bound, and t.relation imposes a total ordering on t.ordered that - * corresponds to the ordering of the atoms in this.bounds.universe. Then, m is - * updated with a binding from t to the constant formula TRUE. For each c in - * {c1...ck}, this.bounds is modified so that the upper bound for c.relation is - * a tupleset whose equivalent matrix has FALSE in the entries on or below the - * main diagonal. Then, m is updated with a binding from c to the constant - * formula TRUE. - *

- *

- * The lossless symmetry breaking algorithm works as follows. Let t1...tn and - * c1...ck be the total ordering and acyclic predicates in m.keySet(). For each - * t in {t1...tn}, three fresh relations are added to this.bounds-- t_first, - * t_last, t_ordered, and t_order--and constrained as follows: t_first is the - * first atom in the upper bound of t.ordered, t_last is the last atom in the - * upper bound of t.ordered, t_ordered is the upper bound of t.ordered, and - * t_order imposes a total ordering on t.ordered that corresponds to the - * ordering of the atoms in this.bounds.universe. Then, m is updated with a - * binding from t to the formula "t.first = t_first and t.last = t_last and - * t.ordered = t_ordered and t.relation = t.order." For each c in {c1...ck}, a - * fresh relation c_acyclic is added to this.bounds and constrained to be a - * constant whose equivalent matrix has no entries on or below the main - * diagonal. The map m is then updated with a binding from c to the constraint - * "c in c_acyclic". - *

- * - * @ensures this.bounds' is modified as described above - * @ensures this.symmetries' is modified to no longer contain the partitions - * that made up the bounds of the relations on which symmetries have - * been broken - * @return a map m such that m.keySet() in preds.values(), and for all - * predicates p in m.keySet(), the formulas "p and [[this.bounds]]" and - * "m.get(p) and [[this.bounds']]" are equisatisfiable - */ - public Map breakMatrixSymmetries(Map> preds, boolean aggressive) { - final Set totals = preds.get(TOTAL_ORDERING); - final Set acyclics = preds.get(ACYCLIC); - final Map broken = new IdentityHashMap(); - - for (RelationPredicate.TotalOrdering pred : sort(totals.toArray(new RelationPredicate.TotalOrdering[totals.size()]))) { - Formula replacement = breakTotalOrder(pred, aggressive); - if (replacement != null) - broken.put(pred, replacement); - } - - for (RelationPredicate.Acyclic pred : sort(acyclics.toArray(new RelationPredicate.Acyclic[acyclics.size()]))) { - Formula replacement = breakAcyclic(pred, aggressive); - if (replacement != null) - broken.put(pred, replacement); - } - - return broken; - } - - /** - * Generates a lex leader symmetry breaking predicate for this.symmetries (if - * any), using the specified leaf interpreter and options.symmetryBreaking. It - * also invokes options.reporter().generatingSBP() if a non-constant predicate - * is generated. - * - * @requires interpreter.relations in this.bounds.relations - * @ensures options.reporter().generatingSBP() if a non-constant predicate is - * generated. - * @return a symmetry breaking predicate for this.symmetries - */ - public final BooleanValue generateSBP(LeafInterpreter interpreter, Options options) { - final int predLength = options.symmetryBreaking(); - if (symmetries.isEmpty() || predLength == 0) - return BooleanConstant.TRUE; - options.reporter().generatingSBP(); - - final List relParts = relParts(); - final BooleanFactory factory = interpreter.factory(); - final BooleanAccumulator sbp = BooleanAccumulator.treeGate(Operator.AND); - final List original = new ArrayList(predLength); - final List permuted = new ArrayList(predLength); - - for (IntSet sym : symmetries) { - - IntIterator indeces = sym.iterator(); - for (int prevIndex = indeces.next(); indeces.hasNext();) { - int curIndex = indeces.next(); - for (Iterator rIter = relParts.iterator(); rIter.hasNext() && original.size() < predLength;) { - - RelationParts rparts = rIter.next(); - Relation r = rparts.relation; - - if (!rparts.representatives.contains(sym.min())) - continue; // r does not range over sym - - BooleanMatrix m = interpreter.interpret(r); - for (IndexedEntry entry : m) { - int permIndex = permutation(r.arity(), entry.index(), prevIndex, curIndex); - BooleanValue permValue = m.get(permIndex); - if (permIndex == entry.index() || atSameIndex(original, permValue, permuted, entry.value())) - continue; - - original.add(entry.value()); - permuted.add(permValue); - } - } - - sbp.add(leq(factory, original, permuted)); - original.clear(); - permuted.clear(); - prevIndex = curIndex; - } - } - symmetries.clear(); // no symmetries left to break (this is - // conservative) - return factory.accumulate(sbp); - } - - /** - * Returns a list of RelationParts that map each non-constant r in - * this.bounds.relations to the representatives of the sets from this.symmetries - * contained in the upper bound of r. The entries are sorted by relations' - * arities and names. - * - * @return a list of RelationParts that contains an entry for each non-constant - * r in this.bounds.relations and the representatives of sets from - * this.symmetries contained in the upper bound of r. - */ - private List relParts() { - final List relParts = new ArrayList(bounds.relations().size()); - for (Relation r : bounds.relations()) { - IntSet upper = bounds.upperBound(r).indexView(); - if (upper.size() == bounds.lowerBound(r).size()) - continue; // skip constant relation - IntSet reps = Ints.bestSet(usize); - for (IntIterator tuples = upper.iterator(); tuples.hasNext();) { - for (int tIndex = tuples.next(), i = r.arity(); i > 0; i--, tIndex /= usize) { - for (IntSet symm : symmetries) { - if (symm.contains(tIndex % usize)) { - reps.add(symm.min()); - break; - } - } - } - } - relParts.add(new RelationParts(r, reps)); - } - final Comparator cmp = new Comparator() { - - @Override - public int compare(RelationParts o1, RelationParts o2) { - final int acmp = o1.relation.arity() - o2.relation.arity(); - return acmp != 0 ? acmp : String.valueOf(o1.relation.name()).compareTo(String.valueOf(o2.relation.name())); - } - }; - Collections.sort(relParts, cmp); - return relParts; - } - - /** - * Returns a BooleanValue that is true iff the string of bits represented by l0 - * is lexicographically less than or equal to the string of bits reprented by - * l1. - * - * @requires l0.size()==l1.size() - * @return a circuit that compares l0 and l1 - */ - private static final BooleanValue leq(BooleanFactory f, List l0, List l1) { - final BooleanAccumulator cmp = BooleanAccumulator.treeGate(Operator.AND); - BooleanValue prevEquals = BooleanConstant.TRUE; - for (int i = 0; i < l0.size(); i++) { - cmp.add(f.implies(prevEquals, f.implies(l0.get(i), l1.get(i)))); - prevEquals = f.and(prevEquals, f.iff(l0.get(i), l1.get(i))); - } - return f.accumulate(cmp); - } - - /** - * Let t be the tuple represent by the given arity and tupleIndex. This method - * returns the tuple index of the tuple t' such t' is equal to t with each - * occurence of atomIndex0 replaced by atomIndex1 and vice versa. - * - * @return the index of the tuple to which the given symmetry maps the tuple - * specified by arith and tupleIndex - */ - private final int permutation(int arity, int tupleIndex, int atomIndex0, int atomIndex1) { - int permIndex = 0; - for (int u = 1; arity > 0; arity--, tupleIndex /= usize, u *= usize) { - int atomIndex = tupleIndex % usize; - if (atomIndex == atomIndex0) - permIndex += atomIndex1 * u; - else if (atomIndex == atomIndex1) { - permIndex += atomIndex0 * u; - } else { - permIndex += atomIndex * u; - } - } - return permIndex; - } - - /** - * Returns true if there is some index i such that l0[i] = v0 and l1[i] = v1. - * - * @requires l0.size()=l1.size() - * @return some i: int | l0[i] = v0 && l1[i] = v1 - */ - private static boolean atSameIndex(List l0, BooleanValue v0, List l1, BooleanValue v1) { - for (int i = 0; i < l0.size(); i++) { - if (l0.get(i).equals(v0) && l1.get(i).equals(v1)) - return true; - } - return false; - } - - /** - * Sorts the predicates in the given array in the ascending order of the names - * of the predicates' relations, and returns it. - * - * @return broken' - * @ensures all i: [0..preds.size()) | all j: [0..i) | broken[j].relation.name - * <= broken[i].relation.name - */ - private static final

P[] sort(final P[] preds) { - final Comparator cmp = new Comparator() { - - @Override - public int compare(RelationPredicate o1, RelationPredicate o2) { - return String.valueOf(o1.relation().name()).compareTo(String.valueOf(o2.relation().name())); - } - }; - Arrays.sort(preds, cmp); - return preds; - } - - /** - * If possible, breaks symmetry on the given acyclic predicate and returns a - * formula f such that the meaning of acyclic with respect to this.bounds is - * equivalent to the meaning of f with respect to this.bounds'. If symmetry - * cannot be broken on the given predicate, returns null. - *

- * We break symmetry on the relation constrained by the given predicate iff - * this.bounds.upperBound[acyclic.relation] is the cross product of some - * partition in this.symmetries with itself. Assuming that this is the case, we - * then break symmetry on acyclic.relation using one of the methods described in - * {@linkplain #breakMatrixSymmetries(Map, boolean)}; the method used depends on - * the value of the "agressive" flag. The partition that formed the upper bound - * of acylic.relation is removed from this.symmetries. - *

- * - * @return null if symmetry cannot be broken on acyclic; otherwise returns a - * formula f such that the meaning of acyclic with respect to - * this.bounds is equivalent to the meaning of f with respect to - * this.bounds' - * @ensures this.symmetries and this.bounds are modified as described in - * {@linkplain #breakMatrixSymmetries(Map, boolean)} iff - * this.bounds.upperBound[acyclic.relation] is the cross product of - * some partition in this.symmetries with itself - * @see #breakMatrixSymmetries(Map,boolean) - */ - private final Formula breakAcyclic(RelationPredicate.Acyclic acyclic, boolean aggressive) { - final IntSet[] colParts = symmetricColumnPartitions(acyclic.relation()); - if (colParts != null) { - final Relation relation = acyclic.relation(); - final IntSet upper = bounds.upperBound(relation).indexView(); - final IntSet reduced = Ints.bestSet(usize * usize); - for (IntIterator tuples = upper.iterator(); tuples.hasNext();) { - int tuple = tuples.next(); - int mirror = (tuple / usize) + (tuple % usize) * usize; - if (tuple != mirror) { - if (!upper.contains(mirror)) - return null; - if (!reduced.contains(mirror)) - reduced.add(tuple); - } - } - - // remove the partition from the set of symmetric partitions - removePartition(colParts[0].min()); - - if (aggressive) { - bounds.bound(relation, bounds.universe().factory().setOf(2, reduced)); - return Formula.TRUE; - } else { - final Relation acyclicConst = Relation.binary("SYM_BREAK_CONST_" + acyclic.relation().name()); - bounds.boundExactly(acyclicConst, bounds.universe().factory().setOf(2, reduced)); - return relation.in(acyclicConst); - } - } - return null; - } - - /** - * If possible, breaks symmetry on the given total ordering predicate and - * returns a formula f such that the meaning of total with respect to - * this.bounds is equivalent to the meaning of f with respect to this.bounds'. - * If symmetry cannot be broken on the given predicate, returns null. - *

- * We break symmetry on the relation constrained by the given predicate iff - * total.first, total.last, and total.ordered have the same upper bound, which, - * when cross-multiplied with itself gives the upper bound of total.relation. - * Assuming that this is the case, we then break symmetry on total.relation, - * total.first, total.last, and total.ordered using one of the methods described - * in {@linkplain #breakMatrixSymmetries(Map, boolean)}; the method used depends - * on the value of the "agressive" flag. The partition that formed the upper - * bound of total.ordered is removed from this.symmetries. - *

- * - * @return null if symmetry cannot be broken on total; otherwise returns a - * formula f such that the meaning of total with respect to this.bounds - * is equivalent to the meaning of f with respect to this.bounds' - * @ensures this.symmetries and this.bounds are modified as desribed in - * {@linkplain #breakMatrixSymmetries(Map, boolean)} iff total.first, - * total.last, and total.ordered have the same upper bound, which, when - * cross-multiplied with itself gives the upper bound of total.relation - * @see #breakMatrixSymmetries(Map,boolean) - */ - private final Formula breakTotalOrder(RelationPredicate.TotalOrdering total, boolean aggressive) { - final Relation first = total.first(), last = total.last(), ordered = total.ordered(), - relation = total.relation(); - final IntSet domain = bounds.upperBound(ordered).indexView(); - - if (symmetricColumnPartitions(ordered) != null && bounds.upperBound(first).indexView().contains(domain.min()) && bounds.upperBound(last).indexView().contains(domain.max())) { - - // construct the natural ordering that corresponds to the ordering - // of the atoms in the universe - final IntSet ordering = Ints.bestSet(usize * usize); - int prev = domain.min(); - for (IntIterator atoms = domain.iterator(prev + 1, usize); atoms.hasNext();) { - int next = atoms.next(); - ordering.add(prev * usize + next); - prev = next; - } - - if (ordering.containsAll(bounds.lowerBound(relation).indexView()) && bounds.upperBound(relation).indexView().containsAll(ordering)) { - - // remove the ordered partition from the set of symmetric - // partitions - removePartition(domain.min()); - - final TupleFactory f = bounds.universe().factory(); - - if (aggressive) { - bounds.boundExactly(first, f.setOf(f.tuple(1, domain.min()))); - bounds.boundExactly(last, f.setOf(f.tuple(1, domain.max()))); - bounds.boundExactly(ordered, bounds.upperBound(total.ordered())); - bounds.boundExactly(relation, f.setOf(2, ordering)); - - return Formula.TRUE; - - } else { - final Relation firstConst = Relation.unary("SYM_BREAK_CONST_" + first.name()); - final Relation lastConst = Relation.unary("SYM_BREAK_CONST_" + last.name()); - final Relation ordConst = Relation.unary("SYM_BREAK_CONST_" + ordered.name()); - final Relation relConst = Relation.binary("SYM_BREAK_CONST_" + relation.name()); - bounds.boundExactly(firstConst, f.setOf(f.tuple(1, domain.min()))); - bounds.boundExactly(lastConst, f.setOf(f.tuple(1, domain.max()))); - bounds.boundExactly(ordConst, bounds.upperBound(total.ordered())); - bounds.boundExactly(relConst, f.setOf(2, ordering)); - - return Formula.and(first.eq(firstConst), last.eq(lastConst), ordered.eq(ordConst), relation.eq(relConst)); - // return first.eq(firstConst).and(last.eq(lastConst)).and( - // ordered.eq(ordConst)).and( relation.eq(relConst)); - } - - } - } - - return null; - } - - /** - * Removes from this.symmetries the partition that contains the specified atom. - * - * @ensures this.symmetries' = { s: this.symmetries | !s.contains(atom) } - */ - private final void removePartition(int atom) { - for (Iterator symIter = symmetries.iterator(); symIter.hasNext();) { - if (symIter.next().contains(atom)) { - symIter.remove(); - break; - } - } - } - - /** - * If all columns of the upper bound of r are symmetric partitions, those - * partitions are returned. Otherwise null is returned. - * - * @return (all i: [0..r.arity) | some s: symmetries[int] | - * bounds.upperBound[r].project(i).indexView() = s) => {colParts: - * [0..r.arity)->IntSet | all i: [0..r.arity()) | colParts[i] = - * bounds.upperBound[r].project(i).indexView() }, null - */ - private final IntSet[] symmetricColumnPartitions(Relation r) { - final IntSet upper = bounds.upperBound(r).indexView(); - if (upper.isEmpty()) - return null; - - final IntSet[] colParts = new IntSet[r.arity()]; - for (int i = r.arity() - 1, min = upper.min(); i >= 0; i--, min /= usize) { - for (IntSet part : symmetries) { - if (part.contains(min % usize)) { - colParts[i] = part; - break; - } - } - if (colParts[i] == null) - return null; - } - for (IntIterator tuples = upper.iterator(); tuples.hasNext();) { - for (int i = r.arity() - 1, tuple = tuples.next(); i >= 0; i--, tuple /= usize) { - if (!colParts[i].contains(tuple % usize)) - return null; - } - } - return colParts; - } - - /** - * An entry for a relation and the representative (least atom) for each symmetry - * class in the relation's upper bound. - */ - private static final class RelationParts { - - final Relation relation; - final IntSet representatives; - - RelationParts(Relation relation, IntSet representatives) { - this.relation = relation; - this.representatives = representatives; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/SymmetryDetector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/SymmetryDetector.java deleted file mode 100644 index 3c3c66ee8..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/SymmetryDetector.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Relation; -import kodkod.instance.Bounds; -import kodkod.instance.TupleSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * Partitions a universe into equivalence classes based on the bounding - * constraints given by a Bounds object. In particular, given a {@link Bounds} - * object {@code b}, a {@link SymmetryDetector} computes the coarsest partition - * { s0, ..., sn } of b.universe such that every - * tupleset in b.lowerBound, b.upperBound, and - * b.intBound can be expressed as a union of cross-products of sets - * drawn from { s0, ..., sn }. - * - * @author Emina Torlak - */ -public final class SymmetryDetector { - - private final Bounds bounds; - /* - * invariant: representatives always holds a sequence of IntSets that partition - * bounds.universe - */ - private final List parts; - private final int usize; - private final Collection ignoreAllAtomRelsExcept; - private final Collection ignoreRels; - - /** - * Constructs a new SymmetryDetector for the given bounds. - * - * @ensures this.bounds' = bounds - */ - private SymmetryDetector(Bounds bounds, Collection ignoreAllAtomRelsExcept, Collection ignoreRels) { - this.bounds = bounds; - this.usize = bounds.universe().size(); - this.ignoreAllAtomRelsExcept = ignoreAllAtomRelsExcept; - this.ignoreRels = ignoreRels; - - // start with the maximum partition -- the whole universe. - this.parts = new LinkedList(); - final IntSet set = Ints.bestSet(usize); - for (int i = 0; i < usize; i++) { - set.add(i); - } - this.parts.add(set); - } - - /** - * Returns the coarsest sound partition of {@code bounds.universe} into symmetry - * classes. - * - * @return some symmetries: set IntSet | (symmetries.ints = { i: int | 0 <= i < - * bounds.universe.size() }) && (all p1, p2: symmetries | some p1.ints & - * p2.ints => p1 = p2) && (all ts: bounds.(lowerBound + upperBound + - * intBound)[Relation] | some decomposition: set List | - * decomposition.elements[int] in symmetries && - * decomposition.elements.IntSet = { i: int | 0 <= i < ts.arity } && - * ts.tuples = { t: Tuple | some part: decomposition | all i: [0 .. - * ts.arity-1] | t.atomIndex(i) in part.get(i) }) && (all other: set - * IntSet | #other > #symmetries => some ts: bounds.(lowerBound + - * upperBound + intBound)[Relation] | no decomposition: set List - * | decomposition.elements[int] in other && - * decomposition.elements.IntSet = { i: int | 0 <= i < ts.arity } && - * ts.tuples = { t: Tuple | some part: decomposition | all i: [0 .. - * ts.arity-1] | t.atomIndex(i) in part.get(i) }) - */ - public static Set partition(Bounds bounds) { - // TODO: remove and decide at every call site - return partition(bounds, null, null); // new ArrayList(), - // null); - } - - public static Set partition(Bounds bounds, Collection ignoreAllAtomRelsExcept, Collection ignoreRelations) { - final SymmetryDetector detector = new SymmetryDetector(bounds, ignoreAllAtomRelsExcept, ignoreRelations); - detector.computePartitions(); - final Set parts = new LinkedHashSet(detector.parts); - assert parts.size() == detector.parts.size(); // sanity check - return parts; - } - - /** - * Partitions this.bounds.universe into sets of equivalent atoms. - * - * @ensures all disj s, q: this.parts'[int] | some s.ints && some q.ints && (no - * s.ints & q.ints) && this.parts'[int].ints = - * [0..this.bounds.universe.size()) && (all ts: - * this.bounds.lowerBound[Relation] + this.bounds.upperBound[Relation] - * | all s: this.parts'[int] | all a1, a2: - * this.bounds.universe.atoms[s.ints] | all t1, t2: ts.tuples | - * t1.atoms[0] = a1 && t2.atoms[0] = a2 => t1.atoms[1..ts.arity) = - * t1.atoms[1..ts.arity) || t1.atoms[1..ts.arity) = a1 && - * t1.atoms[1..ts.arity) = a2) - */ - private final void computePartitions() { - if (usize == 1) - return; // nothing more to do - - final Map range2domain = new HashMap((usize * 2) / 3); - - // refine the partitions based on the bounds for each integer - for (IntIterator iter = bounds.ints().iterator(); iter.hasNext();) { - TupleSet exact = bounds.exactBound(iter.next()); - refinePartitions(exact.indexView(), 1, range2domain); - } - - // refine the partitions based on the upper/lower bounds for each - // relation - for (TupleSet s : sort(bounds)) { - if (parts.size() == usize) - return; - refinePartitions(s.indexView(), s.arity(), range2domain); - } - - } - - /** - * Returns an array that contains unique non-empty tuplesets in the given - * bounds, sorted in the order of increasing size. - * - * @return unique non-empty tuplesets in the given bounds, sorted in the order - * of increasing size. - */ - private TupleSet[] sort(Bounds bounds) { - final List sets = new ArrayList(bounds.relations().size()); - for (Relation r : bounds.relations()) { - if (r.isAtom() && ignoreAllAtomRelsExcept != null && !ignoreAllAtomRelsExcept.contains(r)) - continue; - if (ignoreRels != null && ignoreRels.contains(r)) - continue; - final TupleSet lower = bounds.lowerBound(r); - final TupleSet upper = bounds.upperBound(r); - if (!lower.isEmpty() && lower.size() < upper.size()) { - sets.add(lower); - } - if (!upper.isEmpty()) { - sets.add(upper); - } - } - final TupleSet[] sorted = sets.toArray(new TupleSet[sets.size()]); - Arrays.sort(sorted, new Comparator() { - - @Override - public int compare(TupleSet o1, TupleSet o2) { - return o1.size() - o2.size(); - } - }); - return sorted; - } - - /** - * Refines the atomic partitions in this.parts based on the contents of the - * given tupleset, decomposed into its constituent IntSet and arity. The - * range2domain map is used for intermediate computations for efficiency (to - * avoid allocating it in each recursive call). - * - * @requires all disj s, q: this.parts[int] | some s.ints && some q.ints && (no - * s.ints & q.ints) && this.parts[int].ints = - * [0..this.bounds.universe.size()) - * @ensures let usize = this.bounds.universe.size(), firstColFactor = - * usize^(arit-1) | all disj s, q: this.parts'[int] | some s.ints && - * some q.ints && (no s.ints & q.ints) && this.parts'[int].ints = - * [0..usize) && all s: this.parts'[int] | all a1, a2: - * this.bounds.universe.atoms[s.ints] | all t1, t2: set.ints | t1 / - * firstColFactor = a1 && t2 / firstColFactor = a2 => t1 % - * firstColFactor = t2 % firstColFactor || t1 = a1*((1 - - * firstColFactor) / (1 - usize)) && t2 = a2*((1 - firstColFactor) / (1 - * - usize))) - */ - private void refinePartitions(IntSet set, int arity, Map range2domain) { - if (arity == 1) { - refinePartitions(set); - return; - } - - final List otherColumns = new LinkedList(); - int firstColFactor = (int) StrictMath.pow(usize, arity - 1); - IntSet firstCol = Ints.bestSet(usize); - for (IntIterator rbIter = set.iterator(); rbIter.hasNext();) { - firstCol.add(rbIter.next() / firstColFactor); - } - refinePartitions(firstCol); - - int idenFactor = (1 - firstColFactor) / (1 - usize); - for (ListIterator partsIter = parts.listIterator(); partsIter.hasNext();) { - IntSet part = partsIter.next(); - if (firstCol.contains(part.min())) { // contains one, contains them - // all - range2domain.clear(); - for (IntIterator atoms = part.iterator(); atoms.hasNext();) { - int atom = atoms.next(); - IntSet atomRange = Ints.bestSet(firstColFactor); - for (IntIterator rbIter = set.iterator(atom * firstColFactor, (atom + 1) * firstColFactor - 1); rbIter.hasNext();) { - atomRange.add(rbIter.next() % firstColFactor); - } - IntSet atomDomain = range2domain.get(atomRange); - if (atomDomain != null) - atomDomain.add(atom); - else - range2domain.put(atomRange, oneOf(usize, atom)); - } - partsIter.remove(); - IntSet idenPartition = Ints.bestSet(usize); - for (Map.Entry entry : range2domain.entrySet()) { - if (entry.getValue().size() == 1 && entry.getKey().size() == 1 && entry.getKey().min() == entry.getValue().min() * idenFactor) { - idenPartition.add(entry.getValue().min()); - } else { - partsIter.add(entry.getValue()); - otherColumns.add(entry.getKey()); - } - } - if (!idenPartition.isEmpty()) - partsIter.add(idenPartition); - } - } - - // refine based on the remaining columns - for (IntSet otherCol : otherColumns) { - refinePartitions(otherCol, arity - 1, range2domain); - } - } - - /** - * Refines the atomic partitions this.parts based on the contents of the given - * set. - * - * @requires all disj s, q: this.parts[int] | some s.ints && some q.ints && (no - * s.ints & q.ints) && this.parts[int].ints = - * [0..this.bounds.universe.size()) - * @ensures all disj s, q: this.parts'[int] | some s.ints && some q.ints && (no - * s.ints & q.ints) && this.parts'[int].ints = - * [0..this.bounds.universe.size()) && (all i: [0..this.parts'.size()) - * | this.parts'[i].ints in set.ints || no this.parts'[i].ints & - * set.ints) - */ - private void refinePartitions(IntSet set) { - for (ListIterator partsIter = parts.listIterator(); partsIter.hasNext();) { - IntSet part = partsIter.next(); - IntSet intersection = Ints.bestSet(part.min(), part.max()); - intersection.addAll(part); - intersection.retainAll(set); - if (!intersection.isEmpty() && intersection.size() < part.size()) { - part.removeAll(intersection); - partsIter.add(intersection); - } - } - } - - /** - * Returns an IntSet that can store elements in the range [0..size), and that - * holds the given number. - * - * @requries 0 <= num < size - * @return {s: IntSet | s.ints = num } - */ - private static final IntSet oneOf(int size, int num) { - final IntSet set = Ints.bestSet(size); - set.add(num); - return set; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Translation.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Translation.java deleted file mode 100644 index 6b18d1733..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Translation.java +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2012, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Relation; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * Stores the translation of a Kodkod problem to CNF. A problem consists of a - * {@linkplain kodkod.ast.Formula formula}, {@linkplain Bounds bounds} and - * {@linkplain Options}. A translation can be {@linkplain Whole basic} or - * {@linkplain Incremental incremental}. - * - * @specfield originalFormula: Formula // the original formula, as constructed - * by client - * @specfield originalBounds: Bounds // the original bounds, as constructed by - * client - * @specfield formula: Formula // optimization of this.originalFormula that was - * used for translation - * @specfield bounds: Bounds // optimization of this.originalBounds that was - * used for translation - * @specfield options: Options // the options object used to control translation - * @specfield vars: this.bounds.relations -> int // mapping from relations to - * variables that encode their contents - * @specfield solver: SATSolver // a SATSolver containing the CNF representation - * of the formula - * @invariant solver.solve() iff SAT(formula, bounds, options) - * @invariant SAT(formula, bounds, options) iff SAT(originalFormula, - * originalBounds, options) - * @invariant this.originalBounds.relations in this.bounds.relations - * @invariant this.originalBounds.ints().equals(this.bounds.ints()) - * @invariant all r: this.bounds.relations | some vars[r] => #vars[r] = - * this.bounds.upperBound(r).size() - - * this.bounds.lowerBound(r).size() - * @invariant all r: this.bounds.relations, i: vars[r] | min(vars[r]) <= i <= - * max(vars[r]) - * @invariant vars[Relation] in this.solver.variables - * @see Whole - * @see Incremental - * @author Emina Torlak - */ -public abstract class Translation { - - protected final Bounds bounds; - protected final Options options; - - /** - * Creates a translation using the given bounds and options. - * - * @ensures this.bounds' = bounds && this.options' = options - */ - protected Translation(Bounds bounds, Options options) { - this.bounds = bounds; - this.options = options; - } - - /** - * Returns the optimized bounds. Modification of the returned object may cause - * violation of {@link Translation} invariants. - * - * @return this.bounds - */ - public final Bounds bounds() { - return bounds; - } - - /** - * Returns the translation options. Modification of the returned object may - * cause violation of {@link Translation} invariants. - * - * @return this.options - */ - public final Options options() { - return options; - } - - /** - * Returns the set of primary variables that represent the tuples in the given - * relation. If no variables were allocated to the given relation, empty set is - * returned. This set contains exactly - * {@code this.bounds.upperBound(r).size() - this.bounds.lowerBound(r).size()} - * variable identifiers. - * - * @return this.vars[relation] - */ - public abstract IntSet primaryVariables(Relation relation); - - /** - * Returns the number of primary variables allocated during translation. Primary - * variables represent the tuples of relations in this.bounds that have - * different lower and upper bounds (i.e. - * {@code some this.bounds.upperBound[r].tuples - this.bounds.lowerBound[r].tuples}). - * - * @return #this.vars[Relation] - */ - public abstract int numPrimaryVariables(); - - /** - * Returns the SATSolver object containing the CNF encoding of this.formula. - * Satisfiability of the formula can be checked by calling - * {@link kodkod.engine.satlab.SATSolver#solve()}. Modification of the returned - * object may cause violation of {@link Translation} invariants. - * - * @return {s: SATSolver | SAT(s.variables, s.clauses) iff SAT(this.formula, - * this.bounds, this.options) } - */ - public abstract SATSolver cnf(); - - /** - * Returns true iff this translation is trivially true or trivially false. We - * consider a problem defined by {@code this.formula} and {@code this.bounds} to - * be trivially true or false if the {@linkplain Translator} simplifies it to a - * {@linkplain BooleanConstant}. The {@linkplain BooleanConstant#TRUE TRUE} - * value is represented as a {@linkplain #cnf() CNF} with no variables and no - * clauses. The {@linkplain BooleanConstant#FALSE FALSE} value is represented as - * a {@linkplain #cnf() CNF} with no variables and a single, empty clause. Note - * that in the case of a trivially satisfiable problem, the {@link #interpret()} - * method returns the minimal trivial instance for that problem, which consists - * of the lower bounds specified by {@code this.bounds}. - * - * @return this.cnf.numberOfVariables() = 0 - * @see #interpret() - */ - public boolean trivial() { - return cnf().numberOfVariables() == 0; - } - - /** - * If {@code this.solver.solve()} is true, returns an interpretation of the CNF - * solution as a mapping from Relations to sets of Tuples. The returned instance - * maps all relations in {@code this.bounds} and, therefore, all relations in - * {@code this.originalBounds}. The additional relations in {@code this.bounds}, - * if any, consist of generated skolem constants. - *

- * The returned {@code instance} assigns the value {@code instance.tuples(r)} to - * each relation {@code r} in {@code this.bounds.relations} as follows: (1) - * {@code instance.tuples(r)} includes all tuples in - * {@code this.bound.lowerBound(r)}, and (2) it includes the ith tuple from - * {@code this.bounds.upperBound(r) - this.bounds.lowerBound(r)} iff the model - * obtain from {@code this.solver} binds the ith variable in - * {@code this.{@linkplain #primaryVariables(Relation) primaryVariables}(r)} to - * true. In other words, if no primary variables were allocated to {@code r}, - * then the returned instance simply binds {@code r} to its lower bound. Note - * that in the case of a trivially satisfiable problem - * {@code (this.formula, this.bounds, this.options)}, the returned - * {@code instance} is the smallest possible instance for that problem, - * consisting solely of the lower bounds specified by {@code this.bounds}. - *

- * - * @return a new instance of the problem - * {@code (this.formula, this.bounds, this.options)}, as described above - * @throws IllegalStateException this.solver.solve() has not been called or the - * outcome of the last call was not true. - */ - public Instance interpret() { - return interpret(bounds); - } - - public Instance interpret(Bounds bounds) { - final SATSolver solver = cnf(); - final Instance instance = new Instance(bounds.universe()); - final TupleFactory f = bounds.universe().factory(); - for (IndexedEntry entry : bounds.intBounds()) { - instance.add(entry.index(), entry.value()); - } - for (Relation r : bounds.relations()) { - // if (bnds != bounds && bnds.findRelByName(r.name()) == null) - // continue; - TupleSet lower = bounds.lowerBound(r); - IntSet indices = Ints.bestSet(lower.capacity()); - indices.addAll(lower.indexView()); - IntSet vars = primaryVariables(r); - if (!vars.isEmpty()) { - // System.out.println(r + ": [" + vars.min() + ", " + vars.max() - // + "]"); - int lit = vars.min(); - for (IntIterator iter = bounds.upperBound(r).indexView().iterator(); iter.hasNext();) { - final int index = iter.next(); - if (!indices.contains(index) && solver.valueOf(lit++)) - indices.add(index); - } - } - instance.add(r, f.setOf(r.arity(), indices)); - } - return instance; - } - - /** - * A {@linkplain Whole whole} translation stores the complete CNF of encoding of - * a given problem. Unlike an {@link Incremental incremental} translation, a - * whole translation cannot be augmented with additional constraints. The - * tradeoff is that a whole translation is cheaper to store; the encoding may be - * more efficient than if the same problem were translated incrementally; and, - * whole translations support logging and core extraction - * - * @specfield log: lone {@link TranslationLog} // a translation log mapping - * nodes in this.formula to their corresponding literals in - * this.solver - * @invariant some log => log.originalFormula = originalFormula && - * log.originalBounds = originalBounds && log.formula = formula && - * log.bounds = bounds - * @invariant some log iff this.options.logTranslation > 0 - * @invariant vars[this.bounds.relations] = { i: int | 1 <= i <= #vars } - * @see Translator#translate(kodkod.ast.Formula, Bounds, Options) - * @author Emina Torlak - */ - public static final class Whole extends Translation { - - private final SATSolver solver; - private final Map primaryVarUsage; - private final TranslationLog log; - private final int maxPrimaryVar; - - /** - * Creates a whole translation using the given bounds, options, solver, var map, - * and log. - * - * @requires primaryVarUsage.keySet() in { r: bounds.relations | bounds.lower[r] - * != bounds.upper[r] } - * @requires maxPrimaryVar = max(varUsage[Relation].max) - * @requires all i: varUsage.map[Relation].ints | 1 <= i <= maxPrimaryVar - * @requires varUsage.map[Relation].ints in solver.variables - * @ensures this.solver' = solver && this.bounds' = bounds && this.options' = - * options && this.log' = log && this.vars' = varUsage - */ - Whole(Bounds bounds, Options options, SATSolver solver, Map varUsage, int maxPrimaryVar, TranslationLog log) { - super(bounds, options); - this.solver = solver; - this.log = log; - this.maxPrimaryVar = maxPrimaryVar; - this.primaryVarUsage = varUsage; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.Translation#cnf() - */ - @Override - public final SATSolver cnf() { - return solver; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.Translation#primaryVariables(kodkod.ast.Relation) - */ - @Override - public IntSet primaryVariables(Relation relation) { - final IntSet vars = primaryVarUsage.get(relation); - return vars == null ? Ints.EMPTY_SET : vars; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.Translation#numPrimaryVariables() - */ - @Override - public int numPrimaryVariables() { - return maxPrimaryVar; - } - - /** - * If translation logging was enabled (by setting - * {@code this.options.logTranslation > 0}), returns the - * {@linkplain TranslationLog log} of {@linkplain TranslationRecord records} - * generated for this translation. Otherwise returns null. - * - * @return translation log for this translation, if one was generated, or null - * otherwise - */ - public TranslationLog log() { - return log; - } - } - - /** - * An {@linkplain Incremental incremental} translation preserves the internal - * data structures used during translation. This enables the translation to be - * updated with CNF encodings of additional formulas and bounds using the - * {@linkplain Translator#translateIncremental(kodkod.ast.Formula, Bounds, Translation.Incremental)} - * method. - *

- * Incremental translations are more expensive to store than {@link Whole whole} - * translations, and they place some restrictions on the form of problems that - * are translated. In particular, logging must be disabled during translation; - * the translation must use an incremental SAT solver; and the addition of new - * clauses must not violate the invariants guaranteed by the {@link Translation} - * class. All three restrictions are enforced by the - * {@code translateIncremental(...)} methods of the {@link Translator} class. - *

- * - * @specfield symmetries: set IntSet // partition of the universe into - * equivalence classes induced this.originalBounds - * @invariant this.options.logTranslation = 0 && - * this.options.solver.incremental() - * @invariant this.symmetries = {@linkplain SymmetryDetector#partition(Bounds) - * partition}(this.originalBounds) - * @see Translator#translateIncremental(kodkod.ast.Formula, Bounds, Options) - * @see Translator#translateIncremental(kodkod.ast.Formula, Bounds, - * Translation.Incremental) - * @author Emina Torlak - */ - public static final class Incremental extends Translation { - - /** - * @invariant this.interpreter.universe = this.bounds.universe && - * this.interpreter.relations in this.bounds.relations && - * this.interpreter.intBound = this.bounds.ibounds && - * this.interpreter.lowerBound in this.bounds.lbounds && - * this.interpreter.upperBound in this.bounds.ubounds && - * this.interpreter.vars = this.vars.label - **/ - private final LeafInterpreter interpreter; - /** - * @invariant this.incrementer.solver = this.solver - * @invariant this.incrementer.factory = this.interpreter.factory - */ - private final Bool2CNFTranslator incrementer; - private final Set symmetries; - - /** - * Creates an Incremental translation using the given bounds, options, - * symmetries of the original bounds, translator and interpreter. This - * constructor assumes that the symmetries induced by {@code bounds} refine the - * {@code originalSymmetries}, which were obtained from the original problem - * bounds. - * - * @requires options.logTranslation = 0 && options.solver.incremental() - * @requires translator.solver was constructed by calling - * options.solver.instance() - * @requires all s : SymmetryDetector.partition(bounds) | some p : - * originalSymmetries | s.ints in p.ints - * @ensures this.bounds' = bounds && this.options' = options && this.symmetries' - * = originalSymmetries && this.incrementer' = incrementer && - * this.interpreter' = interpreter - */ - Incremental(Bounds bounds, Options options, Set originalSymmetries, LeafInterpreter interpreter, Bool2CNFTranslator translator) { - super(bounds, options); - this.interpreter = interpreter; - this.incrementer = translator; - this.symmetries = originalSymmetries; - } - - /** - * Returns the symmetries induced by the original bounds. - * - * @return this.symmetries - */ - Set symmetries() { - return symmetries; - } - - /** - * Returns this.interpreter. - * - * @return this.interpreter - */ - LeafInterpreter interpreter() { - return interpreter; - } - - /** - * Returns this.incrementer. - * - * @return this.incrementer. - */ - Bool2CNFTranslator incrementer() { - return incrementer; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.Translation#cnf() - */ - @Override - public final SATSolver cnf() { - return incrementer.solver(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.Translation#primaryVariables(kodkod.ast.Relation) - */ - @Override - public IntSet primaryVariables(Relation relation) { - return interpreter.vars(relation); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.fol2sat.Translation#numPrimaryVariables() - */ - @Override - public int numPrimaryVariables() { - return interpreter.factory().numberOfVariables(); - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationLog.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationLog.java deleted file mode 100644 index 056da045b..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationLog.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Iterator; -import java.util.Set; - -import kodkod.ast.Formula; -import kodkod.engine.config.Options; -import kodkod.instance.Bounds; - -/** - * A log of the translations of the descendants of a given formula that are - * either formulas or that desugar to formulas. - * - * @specfield originalFormula: Formula // the original formula, as constructed - * by client - * @specfield originalBounds: Bounds // the original bounds, as constructed by - * client - * @specfield formula: Formula // optimization of this.originalFormula that was - * used for translation - * @specfield bounds: Bounds // optimization of this.originalBounds that was - * used for translation - * @specfield records: set TranslationRecord - * @specfield replay: [0..#records) one->one records // replay order -- i.e. the - * order in the which records were added to the log - * @invariant all r: records | r.node in formula.*children - * @invariant Solver.solve(formula, bounds).instance() == null iff - * Solver.solve(originalFormula, originalBounds).instance() == null - * @author Emina Torlak - */ -public abstract class TranslationLog { - - TranslationLog() {} - - /** - * Returns the roots of this.formula. In other words, returns the subformulas, - * {f0, ..., fk}, of this.formula such that, for all 0<=i<=k, fi [[f0 - * && ... && fk]] <=> [[formula]]. The granularity of the subdivision of - * this.formula into roots depends on the core granularity specified in the - * {@linkplain Options} that were used when translating this.formula. - *

- * Unless a given root translates to a constant, the highest magnitude literal - * corresponding to each root (as given by this.records) is guaranteed to be - * present in the translation of this.formula as a unit clause. All the - * remaining clauses (except those comprising the symmetry breaking predicate, - * encoded with its own unit clause containing the maximum literal) that are - * reachable from such a unit clause represent the translations of the given - * root's descendants. We define reachability over the clauses in a translation - * as follows: let l1 be the highest magnitude literal in the clause c1, and let - * l2 be the highest magnitude literal in c2. If l2 occurs in c1 (in any - * polarity), then there is an edge from c1 and c2. The unit clauses are always - * the last clauses to be added to a SAT solver during translation. - *

- * - * @return roots of this.formula - */ - public abstract Set roots(); - - /** - * Returns this.bounds. - * - * @return this.bounds. - */ - public abstract Bounds bounds(); - - /** - * Returns an iterator over the translation records in this log that are - * accepted by the given filter. The iterator returns the records in the order - * in which they were generated. This guarantees that records for the - * descendants of a node are always returned before the record for the node - * itself. - *

- * Note:The record objects returned by the iterator are not required to - * be immutable. In particular, the state of a record object returned by - * next() is guaranteed to remain the same only until the subsequent - * call to next(). - *

- * - * @return an iterator, in the proper replay sequence, over the translation - * records in this log that are accepted by the given filter. - */ - public abstract Iterator replay(RecordFilter filter); - - /** - * Returns an iterator over all translation records in this log. The iterator - * returns the records in the order in which they were generated. This - * guarantees that records for the descendants of a node are always returned - * before the record for the node itself. The effect of this method is the same - * as calling {@linkplain #replay(RecordFilter) replay(RecordFilter.ALL)}. - *

- * Note:The record objects returned by the iterator are not required to - * be immutable. In particular, the state of a record object returned by - * next() is guaranteed to remain the same only until the subsequent - * call to next(). - *

- * - * @return an iterator over all translation records in this.log, in the proper - * replay sequence. - * @see #replay(RecordFilter) - */ - public final Iterator replay() { - return replay(RecordFilter.ALL); - } - - // /** - // * Compresses this translation log (optional operation) by eliminating - // * redundant records. - // * @ensures all r: this.records | one r': this.records' | r.node = r'.node - // && r.literal = r'.literal && r.env.equals(r'.env) - // * @throws UnsupportedOperationException this log does not support - // compression - // */ - // public abstract void compress(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationLogger.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationLogger.java deleted file mode 100644 index f3df6db91..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationLogger.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.engine.Solver; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.BooleanValue; - -/** - * Logs the translations of all descendants of a user-provided formula that are - * either formulas or that desugar to formulas. - * - * @specfield originalFormula: Formula // the - * {@linkplain Solver#solve(Formula, kodkod.instance.Bounds) - * original} formula, provided by the user - * @specfield originalBounds: Bounds // the - * {@linkplain Solver#solve(Formula, kodkod.instance.Bounds) - * original} bounds, provided by the user - * @specfield formula: Formula // desugaring of this.formula that was translated - * @specfield bounds: Bounds // translation bounds - * @specfield records: (formula.*children & Formula) -> BooleanValue -> - * Environment - * @invariant Solver.solve(formula, bounds).instance() == null iff - * Solver.solve(originalFormula, originalBounds).instance() == null - * @author Emina Torlak - */ -abstract class TranslationLogger { - - /** - * Optionally records the translation of the source of the given transformed - * formula to the given boolean value in the specified environment. - * - * @requires f in this.formula.*children - * @ensures this.records' = this.records or this.records' = this.records + f -> - * translation -> freeVariables(f)<:env - * @throws IllegalArgumentException some aspect of the given translation event - * prevents it from being logged - * @throws IllegalStateException this log has been closed - */ - abstract void log(Formula f, BooleanValue translation, Environment env); - - /** - * Closes this logger and releases associated resources. Attempts to call - * {@link #log(Formula, BooleanValue, Environment)} after the log has been - * closed may result in an IllegalStateException. - * - * @ensures closes this logger and releases associated resources. - */ - abstract void close(); - - /** - * Returns a TranslationLog view of this.records. - * - * @return a TranslationLog view of this.records. - */ - abstract TranslationLog log(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationRecord.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationRecord.java deleted file mode 100644 index 8efb1c528..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/TranslationRecord.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import java.util.Map; - -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.instance.TupleSet; - -/** - * Record of a translation event. Each translation event is described by four - * pieces of information: - *
    - *
  1. the {@linkplain Formula formula} that was translated;
  2. - *
  3. the {@linkplain Node node} from which the translated formula was derived - * by skolemization or through some other optimization;
  4. - *
  5. the environment in which the given formula is translated, given as a - * binding of free variables to scalars (singleton, unary tuplesets);
  6. - *
  7. the CNF literal, expressed as an integer, that represents the meaning of - * the given formula in the given environment.
  8. - *
- * - * @specfield node: Node // node that was transformed to this.translated - * @specfield translated: Formula // the translated formula obtain from - * this.node - * @specfield literal: int // cnf literal representing the meaning of this.node - * in this.env - * @specfield env: Variable ->one TupleSet // bindings for free, non-skolemized - * variables // for which this.node (or its desugared form) evaluates - * to this.literal - * @author Emina Torlak - */ -public abstract class TranslationRecord { - - /** - * Returns this.node. - * - * @return this.node. - */ - public abstract Node node(); - - /** - * Returns this.translated. - * - * @return this.translated - */ - public abstract Formula translated(); - - /** - * Returns this.literal. - * - * @return this.literal - */ - public abstract int literal(); - - /** - * Returns a map view of this.env. - * - * @return this.env - */ - public abstract Map env(); - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder ret = new StringBuilder(); - ret.append("< node: "); - ret.append(node()); - ret.append(", literal: "); - ret.append(literal()); - ret.append(", env: "); - ret.append(env()); - ret.append(">"); - return ret.toString(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Translator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Translator.java deleted file mode 100644 index cc5dc0601..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/Translator.java +++ /dev/null @@ -1,887 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import static kodkod.engine.fol2sat.FormulaFlattener.flatten; -import static kodkod.engine.fol2sat.Skolemizer.skolemize; -import static kodkod.util.collections.Containers.setDifference; -import static kodkod.util.nodes.AnnotatedNode.annotate; -import static kodkod.util.nodes.AnnotatedNode.annotateRoots; - -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntExpression; -import kodkod.ast.Node; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.visitor.AbstractReplacer; -import kodkod.engine.bool.BooleanAccumulator; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanFactory; -import kodkod.engine.bool.BooleanFormula; -import kodkod.engine.bool.BooleanMatrix; -import kodkod.engine.bool.BooleanValue; -import kodkod.engine.bool.Int; -import kodkod.engine.bool.Operator; -import kodkod.engine.config.Options; -import kodkod.engine.hol.HOLTranslation; -import kodkod.engine.hol.HOLTranslator; -import kodkod.engine.hol.Proc; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleSet; -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.IntSet; -import kodkod.util.nodes.AnnotatedNode; - -/** - * Translates, evaluates, and approximates {@link Node nodes} with respect to - * given {@link Bounds bounds} (or {@link Instance instances}) and - * {@link Options}. - * - * @author Emina Torlak - */ -public final class Translator { - - /*---------------------- public methods ----------------------*/ - /** - * Overapproximates the value of the given expression using the provided bounds - * and options. - * - * @return a BooleanMatrix whose TRUE entries represent the tuples contained in - * a sound overapproximation of the expression. - * @throws expression = null || instance = null || options = null - * @throws UnboundLeafException the expression refers to an undeclared variable - * or a relation not mapped by the instance - * @throws HigherOrderDeclException the expression contains a higher order - * declaration - */ - public static BooleanMatrix approximate(Expression expression, Bounds bounds, Options options) { - Environment emptyEnv = Environment.empty(); - return FOL2BoolTranslator.approximate(annotate(expression), LeafInterpreter.overapproximating(bounds, options), emptyEnv); - } - - /** - * Evaluates the given formula to a BooleanConstant using the provided instance - * and options. - * - * @return a BooleanConstant that represents the value of the formula. - * @throws NullPointerException formula = null || instance = null || options = - * null - * @throws UnboundLeafException the formula refers to an undeclared variable or - * a relation not mapped by the instance - * @throws HigherOrderDeclException the formula contains a higher order - * declaration - */ - public static BooleanConstant evaluate(Formula formula, Instance instance, Options options) { - final LeafInterpreter interpreter = LeafInterpreter.exact(instance, options); - final BooleanConstant eval = (BooleanConstant) FOL2BoolTranslator.translate(annotate(formula), interpreter); - // TODO: check OF - // final BooleanFactory factory = interpreter.factory(); - // BooleanConstant overflow = (BooleanConstant) factory.of(); - // if (options.noOverflow() && overflow.booleanValue()) { //[AM] - // eval = BooleanConstant.FALSE; - // } - return eval; - } - - /** - * Evaluates the given expression to a BooleanMatrix using the provided instance - * and options. - * - * @return a BooleanMatrix whose TRUE entries represent the tuples contained by - * the expression. - * @throws NullPointerException expression = null || instance = null || options - * = null - * @throws UnboundLeafException the expression refers to an undeclared variable - * or a relation not mapped by the instance - * @throws HigherOrderDeclException the expression contains a higher order - * declaration - */ - public static BooleanMatrix evaluate(Expression expression, Instance instance, Options options) { - return (BooleanMatrix) FOL2BoolTranslator.translate(annotate(expression), LeafInterpreter.exact(instance, options)); - } - - /** - * Evalutes the given intexpression to an {@link kodkod.engine.bool.Int} using - * the provided instance and options. - * - * @return an {@link kodkod.engine.bool.Int} representing the value of the - * intExpr with respect to the specified instance and options. - * @throws NullPointerException formula = null || instance = null || options = - * null - * @throws UnboundLeafException the expression refers to an undeclared variable - * or a relation not mapped by the instance - * @throws HigherOrderDeclException the expression contains a higher order - * declaration - */ - public static Int evaluate(IntExpression intExpr, Instance instance, Options options) { - LeafInterpreter interpreter = LeafInterpreter.exact(instance, options); - Int ret = (Int) FOL2BoolTranslator.translate(annotate(intExpr), interpreter); - // TODO: check OF - // BooleanFactory factory = interpreter.factory(); - // BooleanConstant bc = (BooleanConstant) factory.of(); - // boolean overflow = false; - // if (options.noOverflow() && bc.booleanValue()) //[AM] - // overflow = true; - // ret.setOverflowFlag(overflow); - return ret; - } - - public static T translateNext(T transl) { - int primaryVars = transl.numPrimaryVariables(); - SATSolver cnf = transl.cnf(); - final int[] notModel = new int[primaryVars]; - for (int i = 1; i <= primaryVars; i++) { - notModel[i - 1] = cnf.valueOf(i) ? -i : i; - } - cnf.addClause(notModel); - return transl; - } - - /** - * Translates the given formula using the specified bounds and options. The CNF - * representation of the given formula and bounds is generated so that the - * magnitude of the literal representing the truth value of a given circuit is - * strictly larger than the magnitudes of the literals representing the truth - * values of the circuit's descendants. - * - * @return some t: Translation.Whole | t.originalFormula = formula && - * t.originalBounds = bounds && t.options = options - * @throws NullPointerException any of the arguments are null - * @throws UnboundLeafException the formula refers to an undeclared variable or - * a relation not mapped by the given bounds. - * @throws HigherOrderDeclException the formula contains a higher order - * declaration that cannot be skolemized, or it can be skolemized - * but options.skolemize is false. - */ - public static Translation.Whole translate(Formula formula, Bounds bounds, Options options) { - return (Translation.Whole) (new Translator(formula, bounds, options)).translate(); - } - - /** - * Translates the given formula using the specified bounds and options in such a - * way that the resulting translation can be extended with additional formulas - * and bounds, subject to the same options. We require that the options specify - * an incremental SAT solver, and no translation logging. The CNF representation - * of the given formula and bounds is generated so that the magnitude of the - * literal representing the truth value of a given circuit is strictly larger - * than the magnitudes of the literals representing the truth values of the - * circuit's descendants. - * - * @requires options.solver.incremental() && options.logTranslation = 0 - * @return some t: Translation.Incremental | t.originalFormula = formula && - * t.originalBounds = bounds && t.options = options - * @throws NullPointerException any of the arguments are null - * @throws UnboundLeafException the formula refers to an undeclared variable or - * a relation not mapped by the given bounds - * @throws HigherOrderDeclException the formula contains a higher order - * declaration - * @throws IllegalArgumentException any of the preconditions on options are - * violated - */ - public static Translation.Incremental translateIncremental(Formula formula, Bounds bounds, Options options) { - checkIncrementalOptions(options); - return (Translation.Incremental) (new Translator(formula, bounds, options, true)).translate(); - } - - /** - * Updates the given translation with - * {@code CNF(formula, translation.originalBounds + bounds, translation.options)}. - * The result of the update is either a new translation instance or the given - * {@code translation}, modified in place. We assume that client did not modify - * any translation state between invocations to - * {@code translateIncremental(...)}. - *

- * We require {@code bounds} and {@code translation} to be consistent in the - * following sense: - *

    - *
  1. {@code bounds} and {@code translation.bounds} share the same - * universe;
  2. - *
  3. {@code bounds} must not specify any integer bounds;
  4. - *
  5. {@code bounds.relations} must not contain any members of - * {@code translation.bounds.relations} (which may be a superset of - * {@code translation.originalBounds.relations} that also includes Skolem - * constants); and,
  6. - *
  7. {@code bounds} must induce a coarser set of equivalence classes on the - * shared universe than {@code translation.originalBounds}.
  8. - *
- *

- *

- * The behavior of this method is unspecified if a prior call to - * {@code translation.cnf.solve()} returned false, or if a prior call to this - * method resulted in an exception. - *

- * - * @requires translation.cnf.solve() - * @requires formula.*components & Relation in (translation.bounds + - * bounds).relations - * @requires translation.bounds.universe = bounds.universe && no bounds.intBound - * && no (translation.bounds.relations & bounds.relations) - * @requires all s: translation.symmetries | some p: - * {@link SymmetryDetector#partition(Bounds) partition}(bounds) | - * s.ints in p.ints - * @return some t: Translation | t.originalFormula = - * translation.originalFormula.and(formula) && - * t.originalBounds.relations = translation.originalBounds.relations + - * bounds.relations && t.originalBounds.upperBound = - * translation.originalBounds.upperBound + bounds.upperBound && - * t.originalBounds.lowerBound = translation.originalBounds.lowerBound + - * bounds.lowerBound && t.originalBounds.intBound = - * translation.originalBounds.intBound - * @throws NullPointerException any of the arguments are null - * @throws UnboundLeafException the formula refers to an undeclared variable or - * a relation not mapped by translation.bounds + bounds - * @throws HigherOrderDeclException the formula contains a higher order - * declaration - * @throws IllegalArgumentException any of the other preconditions on the - * arguments are violated - */ - public static Translation.Incremental translateIncremental(Formula formula, Bounds bounds, Translation.Incremental translation) { - checkIncrementalOptions(translation.options()); - checkIncrementalBounds(bounds, translation); - if (translation.trivial()) { - return translateIncrementalTrivial(formula, bounds, translation); - } else { - return translateIncrementalNonTrivial(formula, bounds, translation); - } - } - - /** - * @requires checkIncrementalBounds(bounds, transl) - * @requires checkIncrementalOptions(transl.options) - * @requires transl.trivial() - * @requires transl.cnf.solve() - * @return see {@link #translateIncremental(Formula, Bounds, Options)} - **/ - private static Translation.Incremental translateIncrementalTrivial(Formula formula, Bounds bounds, Translation.Incremental transl) { - if (!transl.cnf().solve()) - throw new IllegalArgumentException("Expected a satisfiable translation, given " + transl); - - transl.cnf().free(); // release the old empty solver since we are going - // to re-translate - - final Options tOptions = transl.options(); - final Bounds tBounds = transl.bounds(); - - // add new relation bindings to the translation bounds. since the given - // bounds induce - // a coarser set of symmetries on the universe than transl.symmetries, - // adding their (disjoint) bindings to tBounds - // will not change the symmetries of tBounds. note that the ymmetries of - // tBounds refine transl.symmetries, and they - // may be strictly finer if some of the symmetries in transl.symmetries - // were broken via SymmetryBreaker.breakMatrixSymmetries(...) - // during the generation of transl. in particular, any symmetries absent - // from tBounds are precisely those that were broken based - // on the total ordering and acyclic predicates in - // transl.originalFormula. - for (Relation r : bounds.relations()) { - tBounds.bound(r, bounds.lowerBound(r), bounds.upperBound(r)); - } - - // re-translate the given formula with respect to tBounds. note that we - // don't have to re-translate - // the conjunction of transl.formula and formula since transl.formula is - // guaranteed to evaluate to - // TRUE with respect to tBounds (since no bindings that were originally - // in tBounds were changed by the above loop). - final Translation.Incremental updated = translateIncremental(formula, tBounds, tOptions); - - // we can't return the updated translation as is, since we have to make - // sure that updated.symmetries is set to - // transl.symmetries rather than the potentially finer set of symmetries - // induced by tBounds. note that - // the updated translation currently has updated.originalBounds = - // tBounds, while updated.bounds is a copy of - // tBounds with possibly additional skolem relations, as well as new - // bounds for some relations in formula.*components - // due to symmetry breaking. - return new Translation.Incremental(updated.bounds(), tOptions, transl.symmetries(), updated.interpreter(), updated.incrementer()); - } - - /** - * @requires checkIncrementalBounds(bounds, transl) - * @requires checkIncrementalOptions(transl.options) - * @requires !transl.trivial() - * @return see {@link #translateIncremental(Formula, Bounds, Options)} - **/ - private static Translation.Incremental translateIncrementalNonTrivial(Formula formula, Bounds bounds, Translation.Incremental transl) { - - final Options tOptions = transl.options(); - final Bounds tBounds = transl.bounds(); - - // save the set of relations bound in the pre-state - final Set oldRelations = new LinkedHashSet(tBounds.relations()); - - // add new relation bindings to the translation bounds. note that - // skolemization (below) may also cause extra relations to be added. - for (Relation r : bounds.relations()) { - tBounds.bound(r, bounds.lowerBound(r), bounds.upperBound(r)); - } - final AnnotatedNode annotated = (transl.options().skolemDepth() < 0) ? annotate(formula) : skolemize(annotate(formula), tBounds, tOptions); - - // extend the interpreter with variable allocations for new relations, - // either from given bounds - // or those introduced by skolemization - final LeafInterpreter interpreter = transl.interpreter(); - interpreter.extend(setDifference(tBounds.relations(), oldRelations), tBounds.lowerBounds(), tBounds.upperBounds()); - - final BooleanValue circuit = FOL2BoolTranslator.translate(annotated, interpreter); - - if (circuit == BooleanConstant.FALSE) { - // release the old solver and state, and return a fresh trivially - // false incremental translation. - transl.incrementer().solver().free(); - return new Translation.Incremental(tBounds, tOptions, transl.symmetries(), LeafInterpreter.empty(tBounds.universe(), tOptions), Bool2CNFTranslator.translateIncremental(BooleanConstant.FALSE, tOptions.solver())); - } else if (circuit == BooleanConstant.TRUE) { - // must add any newly allocated primary variables to the solver for - // interpretation to work correctly - final int maxVar = interpreter.factory().maxVariable(); - final int cnfVar = transl.cnf().numberOfVariables(); - if (maxVar > cnfVar) { - transl.cnf().addVariables(maxVar - cnfVar); - } - } else { - // circuit is a formula; add its CNF representation to - // transl.incrementer.solver() - Bool2CNFTranslator.translateIncremental((BooleanFormula) circuit, interpreter.factory().maxVariable(), transl.incrementer()); - } - - return transl; - } - - // [HOL] - public static Proc translate2proc(Formula formula, Bounds bounds, Options options) { - return new Translator(formula, bounds, options, true, true).toProc(); - } - - public static HOLTranslation translateHOL(Formula formula, Bounds bounds, Options options) { - return HOLTranslator.proc2transl(translate2proc(formula, bounds, options), options); - } - - /** - * Checks that the given options are suitable for HOL translation. - * - * @requires options.allowHOL && checkIncrementalOptions(options) - * @throws IllegalArgumentException any of the preconditions are violated - */ - public static void checkHOLOptions(Options options) { - if (!options.isAllowHOL()) - throw new IllegalArgumentException("'allowHOL' option must be set: " + options); - checkIncrementalOptions(options); - } - - /** - * Checks that the given options are suitable for incremental translation. - * - * @requires options.solver.incremental() && options.logTranslation = 0 - * @throws IllegalArgumentException any of the preconditions are violated - */ - public static void checkIncrementalOptions(Options options) { - if (!options.solver().incremental()) - throw new IllegalArgumentException("An incremental solver is required for incremental translation: " + options); - if (options.logTranslation() != 0) - throw new IllegalArgumentException("Translation logging must be disabled for incremental translation: " + options); - } - - /** - * Checks that the given {@code inc} bounds are incremental with respect to the - * given {@code translation}. - * - * @requires translation.bounds.universe = inc.universe && no inc.intBound && no - * (translation.bounds.relations & inc.relations) - * @requires all s: translation.symmetries | some p: - * {@link SymmetryDetector#partition(Bounds) partition}(inc) | - * s.elements in p.elements - * @throws IllegalArgumentException any of the preconditions are violated - */ - public static void checkIncrementalBounds(Bounds inc, Translation.Incremental translation) { - final Bounds base = translation.bounds(); - if (!base.universe().equals(inc.universe())) - incBoundErr(inc.universe(), "universe", "equal to", base.universe()); - if (!inc.intBounds().isEmpty()) - incBoundErr(inc.intBounds(), "intBound", "empty, with integer bounds fully specified by", base.intBounds()); - if (inc.relations().isEmpty()) - return; - final Set baseRels = base.relations(); - for (Relation r : inc.relations()) { - if (baseRels.contains(r)) { - incBoundErr(inc.relations(), "relations", "disjoint from", baseRels); - } - } - final Set symmetries = translation.symmetries(); - final Set incSymmetries = SymmetryDetector.partition(inc); - EQUIV_CHECK: for (IntSet part : symmetries) { - for (IntSet incPart : incSymmetries) { - if (incPart.containsAll(part)) - continue EQUIV_CHECK; - } - incBoundErr(incSymmetries, "partition", "coarser than", symmetries); - } - } - - /** - * Throws an {@link IllegalArgumentException} with an error message that - * describes why given bounds cannot be used for incremental translation. - */ - private static void incBoundErr(Object newObj, String desc, String relatedTo, Object translObj) { - final String newDesc = "bounds." + desc, oldDesc = "translation.originalBounds." + desc; - throw new IllegalArgumentException("Expected " + newDesc + " to be " + relatedTo + " " + oldDesc + " for incremental translation; given " + newDesc + " = " + newObj + ", " + oldDesc + " = " + translObj); - } - - /*---------------------- private translation state and methods ----------------------*/ - /** - * @specfield originalFormula: Formula - * @specfield originalBounds: Bounds - * @specfield bounds: Bounds - * @specfield options: Options - * @specfield incremental: boolean - */ - private final Formula originalFormula; - private final Bounds originalBounds; - private final Bounds bounds; - private final Options options; - private final boolean logging; - private final boolean incremental; - private final boolean hol; - - /** - * Constructs a Translator for the given formula, bounds, options and - * incremental flag. If the flag is true, then the translator produces an - * initial {@linkplain Translation.Incremental incremental translation}. - * Otherwise, the translator produces a {@linkplain Translation.Whole basic - * translation}. - * - * @ensures this.originalFormula' = formula and this.options' = options and - * this.originalBounds' = bounds and this.bounds' = bounds.clone() and - * this.incremental' = incremental - */ - private Translator(Formula formula, Bounds bounds, Options options, boolean incremental, boolean hol) { - this.originalFormula = formula; - this.originalBounds = bounds; - this.bounds = bounds.clone(); - this.options = options; - this.logging = options.logTranslation() > 0; - this.incremental = incremental; - this.hol = hol; - if (this.hol) - this.bounds.ensureAtomRelations(); - } - - private Translator(Formula formula, Bounds bounds, Options options, boolean incremental) { - this(formula, bounds, options, incremental, false); - } - - /** - * Constructs a non-incremental Translator for the given formula, bounds and - * options. - * - * @ensures this(formula, bounds, options, false) - */ - private Translator(Formula formula, Bounds bounds, Options options) { - this(formula, bounds, options, false, false); - } - - /** - * Translates this.originalFormula with respect to this.bounds and this.options. - * If this.incremental is true, then the returned translation is - * {@linkplain Translation.Incremental incremental}; otherwise the output is a - * {@linkplain Translation.Whole basic} translation. - * - * @return a {@linkplain Translation} whose solver is a SATSolver instance - * initialized with the CNF representation of the given formula, with - * respect to the given bounds. The CNF is generated in such a way that - * the magnitude of a literal representing the truth value of a given - * formula is strictly larger than the magnitudes of the literals - * representing the truth values of the formula's descendants. - * @throws UnboundLeafException this.originalFormula refers to an undeclared - * variable or a relation not mapped by this.bounds. - * @throws HigherOrderDeclException this.originalFormula contains a higher order - * declaration that cannot be skolemized, or it can be skolemized - * but this.options.skolemDepth < 0 - */ - private Translation translate() { - final AnnotatedNode annotated = logging ? annotateRoots(originalFormula) : annotate(originalFormula); - - // Remove bindings for unused relations/ints if this is not an - // incremental translation. If it is - // an incremental translation, we have to keep all bindings since they - // may be used later on. - if (!incremental) { - bounds.relations().retainAll(annotated.relations()); - if (!annotated.usesInts()) - bounds.ints().clear(); - } - // Detect symmetries. - final SymmetryBreaker breaker = new SymmetryBreaker(bounds, annotated, options.reporter()); - // Optimize formula and bounds by using symmetry information to tighten - // bounds and - // eliminate top-level predicates, and also by skolemizing. Then - // translate the optimize - // formula and bounds to a circuit, augment the circuit with a symmetry - // breaking predicate - // that eliminates any remaining symmetries, and translate everything to - // CNF. - AnnotatedNode optimized = optimizeFormulaAndBounds(annotated, breaker); - return toBoolean(optimized, breaker); - } - - /** - *

- * When logging is disabled, optimizes annotated.node by first breaking matrix - * symmetries on its top-level predicates, replacing them with the simpler - * formulas generated by - * {@linkplain SymmetryBreaker#breakMatrixSymmetries(Map, boolean) - * breaker.breakMatrixSymmetries(...)}, and skolemizing the result, if - * applicable. - *

- *

- * When logging is enabled, optimizes annotated.node by first flattening it into - * a set of conjuncts, assuming that core granularity is 1. This involves - * pushing negations through quantifier-free formulas. We then skolemize, - * followed by an additional layer of flattening (if - * this.options.coreGranularity > 1), possibly through quantifiers (if - * this.options.coreGranuarity is 3). Predicate inlining and breaking of matrix - * symmetries is performed last to prevent any quantified formulas generated by - * predicate inlining from also being flattened (as this wouldn't be meaningful - * at the level of the original formula). - *

- * - * @requires SAT(annotated.node, this.bounds, this.options) iff - * SAT(this.originalFormula, this.originalBounds, this.options) - * @requires annotated.node.*components & Relation = - * this.originalFormula.*components & Relation - * @requires breaker.bounds = this.bounds - * @ensures this.bounds.relations in this.bounds.relations' - * @ensures this.options.reporter().optimizingBoundsAndFormula() - * @return some f: AnnotatedNode | meaning(f.node, this.bounds, - * this.options) = meaning(this.originalFormula, this.originalBounds, - * this.options) - */ - private AnnotatedNode optimizeFormulaAndBounds(AnnotatedNode annotated, SymmetryBreaker breaker) { - options.reporter().optimizingBoundsAndFormula(); - if (logging) { // yes logging - // logging; inlining of predicates *must* happen last when logging - // is enabled - final int coreGranularity = options.coreGranularity(); - if (coreGranularity == 1) { - annotated = FormulaFlattener.flatten(annotated, false); - } - if (options.skolemDepth() >= 0) { - annotated = skolemize(annotated, bounds, options); - } - if (coreGranularity > 1) { - annotated = flatten(annotated, coreGranularity == 3); - } - return inlinePredicates(annotated, breaker.breakMatrixSymmetries(annotated.predicates(), false)); - } else { - annotated = inlinePredicates(annotated, breaker.breakMatrixSymmetries(annotated.predicates(), true).keySet()); - annotated = options.skolemDepth() >= 0 ? Skolemizer.skolemize(annotated, bounds, options) : annotated; - return annotated; - } - } - - /** - * Returns an annotated formula f such that f.node is equivalent to - * annotated.node with its truePreds replaced with the constant formula - * TRUE and the remaining predicates replaced with equivalent constraints. - * - * @requires truePreds in annotated.predicates()[RelationnPredicate.NAME] - * @requires truePreds are trivially true with respect to this.bounds - * @return an annotated formula f such that f.node is equivalent to - * annotated.node with its truePreds replaced with the constant - * formula TRUE and the remaining predicates replaced with equivalent - * constraints. - */ - private AnnotatedNode inlinePredicates(final AnnotatedNode annotated, final Set truePreds) { - final AbstractReplacer inliner = new AbstractReplacer(annotated.sharedNodes()) { - - @Override - public Formula visit(RelationPredicate pred) { - Formula ret = lookup(pred); - if (ret != null) - return ret; - return truePreds.contains(pred) ? cache(pred, Formula.TRUE) : cache(pred, pred.toConstraints()); - } - }; - Formula x = annotated.node().accept(inliner); - return annotate(x); - } - - /** - * Returns an annotated formula f such that f.node is equivalent to - * annotated.node with its simplified predicates replaced with their - * corresponding Formulas and the remaining predicates replaced with equivalent - * constraints. The annotated formula f will contain transitive source - * information for each of the subformulas of f.node. Specifically, let t be a - * subformula of f.node, and s be a descdendent of annotated.node from which t - * was derived. Then, f.source[t] = annotated.source[s]. - *

- * - * @requires simplified.keySet() in - * annotated.predicates()[RelationPredicate.NAME] - * @requires no disj p, p': simplified.keySet() | simplified.get(p) = - * simplifed.get(p') // this must hold in order to maintain the - * invariant that each subformula of the returned formula has exactly - * one source - * @requires for each p in simplified.keySet(), the formulas "p and - * [[this.bounds]]" and "simplified.get(p) and [[this.bounds]]" are - * equisatisfiable - * @return an annotated formula f such that f.node is equivalent to - * annotated.node with its simplified predicates replaced with - * their corresponding Formulas and the remaining predicates replaced - * with equivalent constraints. - */ - private AnnotatedNode inlinePredicates(final AnnotatedNode annotated, final Map simplified) { - final Map sources = new IdentityHashMap(); - final AbstractReplacer inliner = new AbstractReplacer(annotated.sharedNodes()) { - - private RelationPredicate source = null; - - @Override - protected N cache(N node, N replacement) { - if (replacement instanceof Formula) { - if (source == null) { - final Node nsource = annotated.sourceOf(node); - if (replacement != nsource) - sources.put(replacement, nsource); - } else { - sources.put(replacement, source); - } - } - return super.cache(node, replacement); - } - - @Override - public Formula visit(RelationPredicate pred) { - Formula ret = lookup(pred); - if (ret != null) - return ret; - source = pred; - if (simplified.containsKey(pred)) { - ret = simplified.get(pred).accept(this); - } else { - ret = pred.toConstraints().accept(this); - } - source = null; - return cache(pred, ret); - } - }; - - return annotate(annotated.node().accept(inliner), sources); - } - - private Proc toProc() { - final AnnotatedNode annotated = annotate(originalFormula); - final SymmetryBreaker breaker = new SymmetryBreaker(bounds, annotated, options.reporter()); - int oldSkolemDepth = options.skolemDepth(); - options.setSkolemDepth(-1); - AnnotatedNode optimized = optimizeFormulaAndBounds(annotated, breaker); - options.setSkolemDepth(oldSkolemDepth); - return toProc(optimized); - } - - private Proc toProc(AnnotatedNode annotated) { - checkHOLOptions(options); - return HOLTranslator.toProc(annotated, bounds, options); - } - - // private HOLTranslation toHOLTransl(AnnotatedNode annotated, - // SymmetryBreaker breaker) { - // checkHOLOptions(options); - // - // // AnnotatedNode fl = FormulaFlattener.flatten(optimized, true); - // //TODO: need this? - // //AnnotatedNode nnf1 = NNFConverter.toNNF(optimized, - // options.reporter()); - // AnnotatedNode nnf = FullNegationPropagator.toNNF(annotated, - // options.reporter()); - // //AnnotatedNode pnf = PrenexNFConverter.toPNF(nnf); - // AnnotatedNode skl = Skolemizer.skolemize(nnf, bounds, options); - // - // return HOL2ProcTranslator.translate(skl, bounds, options); - // } - - /** - * Translates the given annotated formula to a circuit, conjoins the circuit - * with an SBP generated by the given symmetry breaker, and returns its - * {@linkplain Translation} to CNF. The SBP breaks any symmetries that could not - * be broken during the - * {@linkplain #optimizeFormulaAndBounds(AnnotatedNode, SymmetryBreaker) formula - * and bounds optimization} step. - * - * @requires SAT(annotated.node, this.bounds, this.options) iff - * SAT(this.originalFormula, this.originalBounds, this.options) - * @requires breaker.bounds = this.bounds - * @ensures this.options.logTranslation => some this.log' - * @ensures this.options.reporter().translatingToBoolean(annotated.node(), - * this.bounds) - * @ensures this.options.reporter().generatingSBP() - * @return the translation of annotated.node with respect to this.bounds - */ - private Translation toBoolean(AnnotatedNode annotated, SymmetryBreaker breaker) { - - options.reporter().translatingToBoolean(annotated.node(), bounds); - - final LeafInterpreter interpreter = LeafInterpreter.exact(bounds, options, incremental); - final BooleanFactory factory = interpreter.factory(); - // final BooleanFactory factory = interpreter.factory(); - - if (logging) { - assert !incremental; - final TranslationLogger logger = options.logTranslation() == 1 ? new MemoryLogger(annotated, bounds) : new FileLogger(annotated, bounds); - BooleanAccumulator circuit = FOL2BoolTranslator.translate(annotated, interpreter, logger); - final TranslationLog log = logger.log(); - if (circuit.isShortCircuited()) { - return trivial(circuit.op().shortCircuit(), log); - } else if (circuit.size() == 0) { - return trivial(circuit.op().identity(), log); - } - circuit.add(breaker.generateSBP(interpreter, options)); - return toCNF((BooleanFormula) factory.accumulate(circuit), interpreter, log); - } else { - BooleanValue circuit = (BooleanValue) FOL2BoolTranslator.translate(annotated, interpreter); - if (circuit.op() == Operator.CONST) { - return trivial((BooleanConstant) circuit, null); - } - return toCNF((BooleanFormula) factory.and(circuit, breaker.generateSBP(interpreter, options)), interpreter, null); - } - } - - /** - * Translates the given circuit to CNF, adds the clauses to a SATSolver returned - * by options.solver(), and returns a Translation object constructed from the - * solver and the provided arguments. - * - * @requires SAT(circuit) iff SAT(this.originalFormula, this.originalBounds, - * this.options) - * @requires circuit.factory = interpreter.factory - * @requires interpreter.universe = this.bounds.universe && - * interpreter.relations = this.bounds.relations() && interpreter.ints - * = this.bounds.ints() && interpreter.lbounds = - * this.bounds.lowerBound && this.interpreter.ubounds = - * bounds.upperBound && interpreter.ibounds = bounds.intBound - * @requires log.originalFormula = this.originalFormula && log.bounds = - * this.bounds - * @ensures {@link #completeBounds()} - * @ensures this.options.reporter.translatingToCNF(circuit) - * @return some t: Translation | t.bounds = completeBounds() && t.originalBounds - * = this.originalBounds && t.vars = interpreter.vars && - * t.vars[Relation].int in t.solver.variables && t.solver.solve() iff - * SAT(this.formula, this.bounds, this.options) - */ - private Translation toCNF(BooleanFormula circuit, LeafInterpreter interpreter, TranslationLog log) { - options.reporter().translatingToCNF(circuit); - final int maxPrimaryVar = interpreter.factory().maxVariable(); - if (incremental) { - final Bool2CNFTranslator incrementer = Bool2CNFTranslator.translateIncremental(circuit, maxPrimaryVar, options.solver()); - return new Translation.Incremental(completeBounds(), options, SymmetryDetector.partition(originalBounds), interpreter, incrementer); - } else { - final Map varUsage = interpreter.vars(); - interpreter = null; // enable gc - final SATSolver cnf = Bool2CNFTranslator.translate(circuit, maxPrimaryVar, options.solver()); - return new Translation.Whole(completeBounds(), options, cnf, varUsage, maxPrimaryVar, log); - } - } - - /** - * Returns a whole or incremental translation, depending on the value of - * {@code this.incremental}, using the given trivial outcome, - * {@linkplain #completeBounds() completeBounds()}, {@code this.options}, and - * the given log. - * - * @ensures {@link #completeBounds()} - * @return some t: Translation | t.bounds = completeBounds() && t.originalBounds - * = this.originalBounds && no t.solver.variables && no t.vars && - * (outcome.booleanValue() => no t.solver.clauses else (one - * t.solver.clauses && no t.solver.clauses.literals)) - **/ - @SuppressWarnings("unchecked" ) - private Translation trivial(BooleanConstant outcome, TranslationLog log) { - if (incremental) { - return new Translation.Incremental(completeBounds(), options, SymmetryDetector.partition(originalBounds), LeafInterpreter.empty(bounds.universe(), options), // empty - // interpreter - Bool2CNFTranslator.translateIncremental(outcome, options.solver())); - } else { - return new Translation.Whole(completeBounds(), options, Bool2CNFTranslator.translate(outcome, options.solver()), Collections.EMPTY_MAP, 0, log); - } - } - - /** - * Completes {@code this.bounds} using the bindings from - * {@code this.originalBounds} so that the result satisfies the - * {@linkplain Translation} invariants. This involves updating - * {@code this.bounds} with bindings from {@code this.originalBounds}, if any, - * that had been discarded in the {@link #translate() first step} of the - * translation. The first step of a non-incremental translation is to discard - * bounds for relations that are not constrained by - * {@code this.originalFormula}, and to discard all integer bounds if - * {@code this.originalFormula} contains no integer expressions. This is sound - * since any instance of {@code this.originalFormula} with respect to - * {@code this.originalBounds} only needs to satisfy the lower bound constraint - * on each discarded relation/integer. By updating {@code this.bounds} with the - * bindings for discarded relations/integers for which no variables were - * allocated, we ensure that any instance returned by - * {@linkplain Translation#interpret()} will bind those relations/integers to - * their lower bound, therefore satisfying the original problem - * {@code (this.originalFormula, this.originalBounds, this.options)}. - * - * @requires no this.bounds.intBound or this.bounds.intBound = - * this.originalBounds.intBound - * @ensures this.bounds.relations' = this.bounds.relations + - * this.originalBounds.relations && this.bounds.intBound' = - * this.originalBounds.intBound && this.bounds.lowerBound' = - * this.bounds.lowerBound + (this.originalBounds.relations - - * this.bounds.relations)<:(this.originalBounds.lowerBound) && - * this.bounds.upperBound' = bounds.upperBound + - * (this.originalBounds.relations - - * this.bounds.relations)<:(this.originalBounds.upperBound) - * @return this.bounds - */ - private Bounds completeBounds() { - final Bounds optimized = this.bounds; - final Bounds original = this.originalBounds; - if (optimized.ints().isEmpty()) { - for (IndexedEntry entry : original.intBounds()) { - optimized.boundExactly(entry.index(), entry.value()); - } - } else { - assert optimized.intBounds().equals(original.intBounds()); - } - final Set rels = optimized.relations(); - for (Relation r : original.relations()) { - if (!rels.contains(r)) { - optimized.bound(r, original.lowerBound(r), original.upperBound(r)); - } - } - return optimized; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/UnboundLeafException.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/UnboundLeafException.java deleted file mode 100644 index fd657d821..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/UnboundLeafException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.fol2sat; - -import kodkod.ast.LeafExpression; - -/** - * Thrown when a node contains an undeclared variable or a relation with no - * bounds. - * - * @specfield leaf: LeafExpression // the unbound leaf that caused the exception - * to be thrown - * @author Emina Torlak - */ -public final class UnboundLeafException extends RuntimeException { - - private final LeafExpression leaf; - private static final long serialVersionUID = 2472395272061454465L; - - /** - * Constructs an UnboundLeafException for the given leaf. - * - * @ensures this.leaf' = leaf - */ - UnboundLeafException(String msg, LeafExpression leaf) { - super(msg + ": " + leaf); - this.leaf = leaf; - } - - /** - * Returns this.leaf. - * - * @return this.leaf - */ - public LeafExpression leaf() { - return leaf; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/package.html deleted file mode 100644 index 1163ddca4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/package.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - -Provides a facade for translating, evaluating, and approximating Kodkod -formulas, expressions, and int expressions with respect to a given Bounds -(or Instance) and Options. - -

Package Specification

- -

Provides a facade for translating, evaluating, and approximating Kodkod -formulas, expressions, and int expressions with respect to given Bounds -(or Instance) and Options. The {@linkplain kodkod.engine.fol2sat.Translator} -class contains methods for translating a Kodkod formula to CNF, evaluating -a Node with respect to an instance, and over-approximating the value of an -expression based on the upper bounds in a given Bounds object.

- -

Related Documentation

- -@see kodkod.engine.fol2sat.Translator -@see kodkod.engine.fol2sat.Translation -@see kodkod.engine.fol2sat.TranslationLog -@see kodkod.engine.fol2sat.TranslationRecord - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/fol2sat/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOL2ProcTranslator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOL2ProcTranslator.java deleted file mode 100644 index 6b8cd79ce..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOL2ProcTranslator.java +++ /dev/null @@ -1,116 +0,0 @@ -package kodkod.engine.hol; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.Stack; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.AbstractReplacer; -import kodkod.ast.visitor.AspectReturnVisitor; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.instance.Bounds; -import kodkod.util.nodes.AnnotatedNode; - -public class HOL2ProcTranslator extends AbstractReplacer { - - static class Conversion { - - final QuantifiedFormula origQF; - final QuantifiedFormula newQF; - - Conversion(QuantifiedFormula origQF, QuantifiedFormula newQF) { - this.origQF = origQF; - this.newQF = newQF; - } - } - - class HistoryAspect extends AspectReturnVisitor { - - protected HistoryAspect() { - super(HOL2ProcTranslator.this); - } - - @Override - protected T end(Node n, T ans) { - stack.pop(); - skolemizable.pop(); - return ans; - } - - @Override - protected void start(Node n) { - stack.push(n); - // ***NOTE*** assumes the formula is already in NNF !!! - boolean skolemizableSoFar = skolemizable.empty() ? true : skolemizable.lastElement(); - if (!skolemizableSoFar) { - skolemizable.push(false); - } else { - if ((n instanceof BinaryFormula && ((BinaryFormula) n).op() == FormulaOperator.AND) || (n instanceof NaryFormula && ((NaryFormula) n).op() == FormulaOperator.AND) || (n instanceof QuantifiedFormula && ((QuantifiedFormula) n).quantifier() == Quantifier.SOME)) - skolemizable.push(true); - else - skolemizable.push(false); - } - } - } - - protected final List history = new LinkedList(); - protected final Stack stack = new Stack(); - protected final Stack skolemizable = new Stack(); - protected final List conversions = new ArrayList(); - protected final HistoryAspect historyAspect = new HistoryAspect(); - - HOL2ProcTranslator(Set cached) { - super(cached); - this.delegate = historyAspect; - } - - @Override - public Formula visit(QuantifiedFormula qf) { - for (Decl decl : qf.decls()) { - if (decl.multiplicity() != Multiplicity.ONE) { - if (!isSkolemizableUpToNow()) - throw new HigherOrderDeclException(decl); - assert qf.decls().size() == 1 : "not implemented for quantifiers with multiple decls"; - QuantifiedFormula revQuant = (QuantifiedFormula) qf.formula().quantify(qf.quantifier().opposite, decl); - conversions.add(new Conversion(qf, revQuant)); - return revQuant; - } - } - return super.visit(qf); - } - - public static HOLTranslation translate(AnnotatedNode annotated, Bounds bounds, Options options) { - HOL2ProcTranslator tr = new HOL2ProcTranslator(annotated.sharedNodes()); - Formula converted = annotated.node().accept(tr.withHistory()); - if (tr.conversions.size() == 0) { - return new HOLTranslationOld.FOL(annotated, bounds, options); - } else { - return new HOLTranslationOld.Some4All(annotated, converted, tr.conversions, bounds, options); - } - } - - private HistoryAspect withHistory() { - return historyAspect; - } - - private boolean isSkolemizableUpToNow() { - if (skolemizable.size() <= 1) - return true; - return skolemizable.get(skolemizable.size() - 2); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslation.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslation.java deleted file mode 100644 index b70ddc2f2..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslation.java +++ /dev/null @@ -1,88 +0,0 @@ -package kodkod.engine.hol; - -import kodkod.ast.Formula; -import kodkod.engine.config.AbstractReporter; -import kodkod.engine.config.Options; -import kodkod.engine.config.Reporter; -import kodkod.engine.fol2sat.Translation; -import kodkod.instance.Bounds; - -public abstract class HOLTranslation extends Translation { - - public static class HOLException extends RuntimeException { - - private static final long serialVersionUID = 3431754608057485603L; - - public HOLException() {} - - public HOLException(String message) { - super(message); - } - } - - protected Reporter rep; - protected int depth; - - public HOLTranslation(Bounds bounds, Options options, int depth) { - super(bounds, options); - this.depth = depth; - rep = options.reporter() != null ? options.reporter() : new AbstractReporter() {}; - // rep = new AbstractReporter() { - // public void holLoopStart(HOLTranslation tr, Formula formula, Bounds - // bounds) { - // System.out.println("started: " + formula); - // } - // public void holCandidateFound(HOLTranslation tr, Instance candidate) - // { - // System.out.println(" candidate found"); - // } - // public void holVerifyingCandidate(HOLTranslation tr, Instance - // candidate, Formula checkFormula, Bounds bounds) { - // System.out.println(" verifying: " + checkFormula); - // } - // public void holCandidateVerified(HOLTranslation tr, Instance - // candidate) {} - // public void holCandidateNotVerified(HOLTranslation tr, Instance - // candidate, Instance cex) {} - // public void holFindingNextCandidate(HOLTranslation tr, Formula inc) { - // System.out.println(" finding next: " + inc); - // } - // }; - } - - public abstract Formula formula(); - - public abstract Translation getCurrentFOLTranslation(); - - // TODO: override in subclasses!!! - public Formula formulaWithInc() { - return formula(); - } - - @Override - public boolean trivial() { - return false; - } - - public HOLTranslation next(Formula formula, Bounds bounds) { - throw new RuntimeException("not implemented"); - } - - public HOLTranslation next(Formula formula) { - return next(formula, new Bounds(bounds.universe())); - } - - public HOLTranslation next() { - throw new RuntimeException("not implemented"); - } - - public boolean isFirstOrder() { - return false; - } - - public int depth() { - return depth; - } - - public abstract int numCandidates(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslationNew.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslationNew.java deleted file mode 100644 index 333aab877..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslationNew.java +++ /dev/null @@ -1,690 +0,0 @@ -package kodkod.engine.hol; - -import static kodkod.engine.hol.Proc.foldPlus; -import static kodkod.engine.hol.Proc.map; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Decl; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.UnaryExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.visitor.AbstractReplacer; -import kodkod.engine.Evaluator; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.FullNegationPropagator; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.Translation; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.hol.Proc.Func1; -import kodkod.engine.satlab.SATAbortedException; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleSet; -import kodkod.util.collections.Pair; -import kodkod.util.ints.IntSet; -import kodkod.util.nodes.AnnotatedNode; - -public abstract class HOLTranslationNew extends HOLTranslation { - - /** - * ======================================================================== - * Class HOLTranslationNew.FOL - * ======================================================================== - */ - public static class FOL extends HOLTranslationNew { - - final Proc.FOL proc; - final FOL prev; - Translation folTr; - - public FOL(Proc.FOL proc, Options options, int depth) { - super(proc.bounds(), options); - this.proc = proc; - this.prev = null; - - // TODO: pass annotated instead, so that it doesn't have to - // re-annotate again - folTr = options.solver().incremental() ? Translator.translateIncremental(proc.formula, bounds, options) : Translator.translate(proc.formula, bounds, options); - } - - private FOL(FOL prev, Incremental trNext) { - super(trNext.bounds(), trNext.options()); - this.proc = prev.proc; - this.folTr = trNext; - this.prev = prev; - } - - @Override - public final boolean isFirstOrder() { - return true; - } - - @Override - public Formula formula() { - return proc.formula; - } - - @Override - public Translation getCurrentFOLTranslation() { - return folTr; - } - - @Override - public int numCandidates() { - return 1; - } - - @Override - public IntSet primaryVariables(Relation relation) { - return folTr.primaryVariables(relation); - } - - @Override - public int numPrimaryVariables() { - return folTr.numPrimaryVariables(); - } - - @Override - public SATSolver cnf() { - return folTr.cnf(); - } - - @Override - public HOLTranslation next(Formula formula, Bounds bnds) { - if (folTr.options().solver().incremental()) { - folTr = Translator.translateIncremental(formula, bnds, (Translation.Incremental) folTr); - return this; - } else { - return HOLTranslator.translateHOL(formulaWithInc().and(formula), Proc.union(bounds(), bnds), options); - } - } - - @Override - public HOLTranslationNew next() { - Translator.translateNext(folTr); - return this; - } - } - - /** - * ======================================================================== - * Class HOLTranslationNew.Some4All - * ======================================================================== - */ - public static class Some4All extends HOLTranslationNew { - - public final Proc.Some4All proc; - private HOLTranslation candTr; - private int numCandidates; - - public Some4All(Proc.Some4All proc, Options options, int depth) { - super(proc.bounds(), options, depth); - this.proc = proc; - Proc ffp = proc.fullFlippedProc(); - this.candTr = ffp.translate(options, depth + 1); - this.numCandidates = -1; - } - - @Override - public Formula formula() { - return proc.formula(); - } - - public HOLTranslation convTr() { - return candTr; - } - - @Override - public Translation getCurrentFOLTranslation() { - return candTr.getCurrentFOLTranslation(); - } - - @Override - public HOLTranslation next() { - candTr = candTr.next(); - return this; - } - - @Override - public HOLTranslation next(Formula f, Bounds b) { - candTr = candTr.next(f, b); - return this; - } - - @Override - public int numCandidates() { - return numCandidates; - } - - // Translation methods ----------- - - @Override - public IntSet primaryVariables(Relation relation) { - return candTr.primaryVariables(relation); - } - - @Override - public int numPrimaryVariables() { - return candTr.numPrimaryVariables(); - } - - @Override - public SATSolver cnf() { - return new Solver(); - } - - @Override - public Instance interpret() { - return candTr.interpret(bounds); - } - - // Replacer ---------------------- - - class Replacer extends AbstractReplacer { - - protected Replacer(Set cached) { - super(cached); - } - } - - // SATSolver methods ------------- - - class Solver implements SATSolver { - - @Override - public int numberOfVariables() { - return candTr.cnf().numberOfVariables(); - } - - @Override - public int numberOfClauses() { - return candTr.cnf().numberOfClauses(); - } - - @Override - public void addVariables(int numVars) { - candTr.cnf().addVariables(numVars); - } - - @Override - public boolean addClause(int[] lits) { - return candTr.cnf().addClause(lits); - } - - @Override - public boolean valueOf(int variable) { - return candTr.cnf().valueOf(variable); - } - - @Override - public void free() { - candTr.cnf().free(); - } - - public boolean solveNext() { - // finding the next candidate - int iterCnt = 0; - int maxIter = options.getHolSome4AllMaxIter(); - while (candTr.cnf().solve()) { - iterCnt++; - Instance cand = candTr.interpret(); - rep.holCandidateFound(Some4All.this, cand); - - Formula checkFormula = Formula.and(proc.qpFormulas()).not(); - - // verifying candidate - Bounds pi = bounds.clone(); - for (Relation r : pi.relations()) { - pi.boundExactly(r, cand.tuples(r)); - } - rep.holVerifyingCandidate(Some4All.this, cand, checkFormula, pi); - Options opt = options.clone(); - // opt.setOverflowPolicy(opt.overflowPolicy().dual); - HOLTranslation checkTr = HOLTranslator.translateHOL(checkFormula, pi, opt); - if (!checkTr.cnf().solve()) { - numCandidates = iterCnt; - rep.holCandidateVerified(Some4All.this, cand); - return true; - } else { - if (maxIter > 0 && iterCnt > maxIter) - throw new HOLException("[Some4All] Max number of iterations reached: " + maxIter); - Instance cex = checkTr.interpret(); - rep.holCandidateNotVerified(Some4All.this, cand, cex); - - Collection holSkolems = cand.skolems(); - holSkolems.removeAll(bounds.skolems()); - - List cexInsts = new ArrayList(proc.qpFormulas().length); - top: for (Formula f : proc.qpFormulas()) { - final Map varmap = new HashMap(); - QuantifiedFormula qf = (QuantifiedFormula) f; - for (Decl d : qf.decls()) { - Relation sk = findSkolemRelation(holSkolems, d.variable()); - TupleSet skTuples = cex.tuples(sk.name()); - if (skTuples == null) - continue top; // the cex does not involve - // this qf, so skip to next - varmap.put(d.variable(), pi.ts2expr(skTuples)); - } - cexInsts.add(qf.formula().accept(new AbstractReplacer(new HashSet()) { - - @Override - public Expression visit(Variable variable) { - Expression expr = varmap.get(variable); - if (expr == null) - return super.visit(variable); - if (expr == Expression.NONE) - for (int i = 1; i < variable.arity(); i++) - expr = expr.product(Expression.NONE); - return expr; - } - })); - } - Formula fInc = Formula.and(cexInsts); - Bounds bInc = new Bounds(candTr.bounds().universe()); - Proc x; - if (!options.isHolFullIncrements()) { - Bounds bCand = candTr.bounds(); - x = HOLTranslator.toProc(fInc, bCand, options); - Pair p = x.firstOrderProblem(); - Set diff = new HashSet(p.b.relations()); - diff.removeAll(bCand.relations()); - bInc = new Bounds(bCand.universe()); - for (Relation r : diff) { - bInc.bound(r, p.b.lowerBound(r), p.b.upperBound(r)); - } - fInc = p.a; - } else { - fInc = FullNegationPropagator.toNNF(AnnotatedNode.annotateRoots(fInc)).node(); - } - - rep.holFindingNextCandidate(Some4All.this, fInc); - try { - candTr = candTr.next(fInc, bInc); - } catch (HigherOrderDeclException e) { - candTr = HOLTranslator.translateHOL(candTr.formulaWithInc().and(fInc), candTr.bounds(), options); - } - } - } - numCandidates = iterCnt; - return false; - } - - @Override - public boolean solve() throws SATAbortedException { - rep.holLoopStart(Some4All.this, candTr.formula(), candTr.bounds()); - return solveNext(); - } - } - - public Relation findSkolemRelation(Collection holSkolems, Variable variable) { - for (Relation r : holSkolems) - if (r.getSkolemVar() == variable) - return r; - assert false : "Skolem relation not found for variable " + variable; - return null; - } - } - - /** - * ======================================================================== - * Class HOLTranslationNew.Fixpoint - * ======================================================================== - */ - public static class Fixpoint extends HOLTranslationNew { - - public final Proc.Fixpoint proc; - private HOLTranslation convTr; - private Instance convInst; - private int iterCnt; - - public Fixpoint(Proc.Fixpoint proc, Options options, int depth) { - super(proc.bounds(), options, depth); - this.proc = proc; - this.convTr = proc.fullFlippedProc().translate(options, depth + 1); - } - - @Override - public Formula formula() { - return proc.formula(); - } - - public HOLTranslation convTr() { - return convTr; - } - - @Override - public Translation getCurrentFOLTranslation() { - return convTr.getCurrentFOLTranslation(); - } - - @Override - public HOLTranslation next() { - convTr = convTr.next(); - return this; - } - - @Override - public HOLTranslation next(Formula f, Bounds b) { - convTr = convTr.next(f, b); - return this; - } - - @Override - public int numCandidates() { - return iterCnt; - } - - // Translation methods ----------- - - @Override - public IntSet primaryVariables(Relation relation) { - return convTr.primaryVariables(relation); - } - - @Override - public int numPrimaryVariables() { - return convTr.numPrimaryVariables(); - } - - @Override - public SATSolver cnf() { - return new Solver(); - } - - @Override - public Instance interpret() { - return convInst; - } - - // Replacer ---------------------- - - class Replacer extends AbstractReplacer { - - protected Replacer(Set cached) { - super(cached); - } - } - - // SATSolver methods ------------- - - class Solver implements SATSolver { - - @Override - public int numberOfVariables() { - return convTr.cnf().numberOfVariables(); - } - - @Override - public int numberOfClauses() { - return convTr.cnf().numberOfClauses(); - } - - @Override - public void addVariables(int numVars) { - convTr.cnf().addVariables(numVars); - } - - @Override - public boolean addClause(int[] lits) { - return convTr.cnf().addClause(lits); - } - - @Override - public boolean valueOf(int variable) { - return convTr.cnf().valueOf(variable); - } - - @Override - public void free() { - convTr.cnf().free(); - } - - public boolean solveNext() { - convInst = null; - iterCnt = 0; - int maxIter = options.getHolSome4AllMaxIter(); - HOLTranslation currTr = convTr; - while (currTr.cnf().solve()) { - final Instance currInst = currTr.interpret(); - final Evaluator eval = new Evaluator(currInst); - convTr = currTr; - convInst = currTr.interpret(); - if (iterCnt == 0) - rep.holFixpointFirstSolution(Fixpoint.this, currInst); - else - rep.holFixpointIncrementingOutcome(Fixpoint.this, currInst); - if (maxIter > 0 && iterCnt > maxIter) - throw new HOLException("[Fixpoint] Max number of iterations reached: " + maxIter); - iterCnt++; - // TODO: works only when inc is first order - Formula inc = proc.fullConditionFormula().accept(new AbstractReplacer(new HashSet()) { - - @Override - public Expression visit(UnaryExpression unaryExpr) { - if (unaryExpr.op() != ExprOperator.PRE) - return super.visit(unaryExpr); - TupleSet val = eval.evaluate(unaryExpr.expression()); - return bounds.ts2expr(val); - } - }); - // if (iterCnt == 1) { - // List fix = new - // ArrayList(bounds.relations().size()); - // for (Relation r: bounds.relations()) { - // if (r.isAtom()) continue; - // if (!r.name().endsWith("_clq") && - // !r.name().endsWith("_e")) { - // Expression val = bounds.ts2expr(currInst.tuples(r)); - // fix.add(val == Expression.NONE ? r.no() : r.eq(val)); - // } - // } - // inc = inc.and(Formula.and(fix)); - // } - rep.holFixpointIncrementing(Fixpoint.this, inc); - currTr = currTr.next(inc); - } - if (convInst != null && iterCnt > 0) - rep.holFixpointIncrementingOutcome(Fixpoint.this, null); - return convInst != null; - } - - @Override - public boolean solve() throws SATAbortedException { - rep.holFixpointStart(Fixpoint.this, convTr.formula(), convTr.bounds()); - return solveNext(); - } - } - - public Relation findSkolemRelation(Collection holSkolems, Variable variable) { - for (Relation r : holSkolems) - if (r.getSkolemVar() == variable) - return r; - assert false : "Skolem relation not found for variable " + variable; - return null; - } - } - - /** - * ======================================================================== - * Class HOLTranslationNew.ORSplit - * ======================================================================== - */ - public static class OR extends HOLTranslationNew { - - public final Proc.OR proc; - private final HOLTranslation[] splitTransl; - private HOLTranslation solTr = null; - private int currTrIdx = 0; - - public OR(final Proc.OR proc, final Options options, final int depth) { - super(Proc.union(map(proc.disjuncts, new Bounds[0], new Func1() { - - @Override - public Bounds run(Proc a) { - return a.bounds; - } - })), options, depth); - this.proc = proc; - this.splitTransl = map(proc.disjuncts, new HOLTranslation[0], new Func1() { - - @Override - public HOLTranslation run(Proc a) { - return a.translate(options, depth + 1); - } - }); - } - - public HOLTranslation currTr() { - return splitTransl[currTrIdx]; - } - - @Override - public Formula formula() { - return proc.formula(); - } - - @Override - public Translation getCurrentFOLTranslation() { - return currTr().getCurrentFOLTranslation(); - } - - @Override - public HOLTranslation next() { - splitTransl[currTrIdx] = currTr().next(); - return this; - } - - @Override - public HOLTranslation next(Formula f) { - splitTransl[currTrIdx] = currTr().next(f); - return this; - } - - @Override - public HOLTranslation next(Formula f, Bounds b) { - splitTransl[currTrIdx] = currTr().next(f, b); - return this; - } - - @Override - public int numCandidates() { - return currTrIdx; - } - - // Translation methods ----------- - - @Override - public IntSet primaryVariables(Relation relation) { - return splitTransl[0].primaryVariables(relation); - } // TODO enough? - - @Override - public int numPrimaryVariables() { - return foldPlus(splitTransl, new Func1() { - - @Override - public Integer run(HOLTranslation a) { - return a.numPrimaryVariables(); - } - }); - } - - @Override - public SATSolver cnf() { - return new Solver(); - } - - @Override - public Instance interpret() { - assert solTr != null : "no solution was found"; - return solTr.interpret(); - } - - @Override - public Instance interpret(Bounds bnds) { - assert solTr != null : "no solution was found"; - return solTr.interpret(bnds); - } - - // SATSolver methods ------------- - - class Solver implements SATSolver { - - @Override - public int numberOfVariables() { - return currTr().cnf().numberOfVariables(); - } - - @Override - public int numberOfClauses() { - return currTr().cnf().numberOfClauses(); - } - - @Override - public void addVariables(int numVars) { - currTr().cnf().addVariables(numVars); - } - - @Override - public boolean addClause(int[] lits) { - return currTr().cnf().addClause(lits); - } - - @Override - public boolean valueOf(int variable) { - return currTr().cnf().valueOf(variable); - } - - @Override - public void free() { - currTr().cnf().free(); - } - - public boolean solveNext() throws SATAbortedException { - for (int i = currTrIdx; i < splitTransl.length; i++) { - currTrIdx = i; - HOLTranslation tr = currTr(); - rep.holSplitChoice(OR.this, tr.formula(), tr.bounds()); - if (tr.cnf().solve()) { - solTr = tr; - rep.holSplitChoiceSAT(OR.this, solTr.interpret()); - return true; - } else { - rep.holSplitChoiceUNSAT(OR.this); - } - } - solTr = null; - return false; - } - - @Override - public boolean solve() throws SATAbortedException { - rep.holSplitStart(OR.this, formula()); - currTrIdx = 0; - return solveNext(); - } - } - } - - protected HOLTranslationNew(Bounds bounds, Options options) { - this(bounds, options, 0); - } - - protected HOLTranslationNew(Bounds bounds, Options options, int depth) { - super(bounds, options, depth); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslationOld.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslationOld.java deleted file mode 100644 index fb39a25f5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslationOld.java +++ /dev/null @@ -1,267 +0,0 @@ -package kodkod.engine.hol; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.AbstractReplacer; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.Translation; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.hol.HOL2ProcTranslator.Conversion; -import kodkod.engine.satlab.SATAbortedException; -import kodkod.engine.satlab.SATSolver; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleSet; -import kodkod.util.ints.IntSet; -import kodkod.util.nodes.AnnotatedNode; - -public abstract class HOLTranslationOld extends HOLTranslation { - - public static class FOL extends HOLTranslationOld { - - final AnnotatedNode annotated; - final Translation.Incremental folTr; - final FOL prev; - - public FOL(AnnotatedNode annotated, Bounds bounds, Options options) { - super(bounds, options); - this.annotated = annotated; - this.prev = null; - // TODO: pass annotated instead, so that it doesn't have to - // re-annotate again - folTr = Translator.translateIncremental(annotated.node(), bounds, options); - } - - private FOL(FOL prev, Incremental trNext) { - super(trNext.bounds(), trNext.options()); - this.folTr = trNext; - this.annotated = null; - this.prev = prev; - } - - @Override - public final boolean isFirstOrder() { - return true; - } - - @Override - public Formula formula() { - return annotated.node(); - } - - @Override - public IntSet primaryVariables(Relation relation) { - return folTr.primaryVariables(relation); - } - - @Override - public int numPrimaryVariables() { - return folTr.numPrimaryVariables(); - } - - @Override - public SATSolver cnf() { - return folTr.cnf(); - } - - @Override - public HOLTranslation next(Formula formula, Bounds bounds) { - Translator.translateIncremental(formula, bounds, folTr); - return this; - } - - @Override - public HOLTranslation next() { - Translator.translateNext(folTr); - return this; - } - } - - public static class Some4All extends HOLTranslationOld { - - public final AnnotatedNode annotated; - public final Formula converted; - public final List conversions; - private HOLTranslation convTr; - - public Some4All(AnnotatedNode annotated, Formula converted, List conversions, Bounds bounds, Options options) { - super(bounds, options); - assert conversions.size() == 1 : "not implemented for multiple parallel higher-order quantifiers"; - this.annotated = annotated; - this.converted = converted; - this.conversions = conversions; - this.convTr = Translator.translateHOL(converted, bounds, options); - for (Conversion conv : conversions) { - assert conv.origQF.quantifier() == Quantifier.ALL : "Non-universal quantifier converted for Some4All"; - } - } - - @Override - public HOLTranslation next() { - convTr = convTr.next(); - return this; - } - - @Override - public HOLTranslation next(Formula f, Bounds b) { - convTr = convTr.next(f, b); - return this; - } - - // Translation methods ----------- - - @Override - public IntSet primaryVariables(Relation relation) { - return convTr.primaryVariables(relation); - } - - @Override - public int numPrimaryVariables() { - return convTr.numPrimaryVariables(); - } - - @Override - public SATSolver cnf() { - return new Solver(); - } - - @Override - public Instance interpret() { - return convTr.interpret(); - } - - @Override - public Formula formula() { - return convTr.formula(); - } - - // Replacer ---------------------- - - class Replacer extends AbstractReplacer { - - protected Replacer(Set cached) { - super(cached); - } - } - - // SATSolver methods ------------- - - class Solver implements SATSolver { - - @Override - public int numberOfVariables() { - return convTr.cnf().numberOfVariables(); - } - - @Override - public int numberOfClauses() { - return convTr.cnf().numberOfClauses(); - } - - @Override - public void addVariables(int numVars) { - convTr.cnf().addVariables(numVars); - } - - @Override - public boolean addClause(int[] lits) { - return convTr.cnf().addClause(lits); - } - - @Override - public boolean valueOf(int variable) { - return convTr.cnf().valueOf(variable); - } - - @Override - public void free() { - convTr.cnf().free(); - } - - public boolean solveNext() { - // finding the next candidate - while (convTr.cnf().solve()) { - Instance inst = convTr.interpret(); - rep.holCandidateFound(Some4All.this, inst); - - // TODO: rewrite check by replacing all skolems with - // concrete values from sol (maybe not necessary?) - QuantifiedFormula qf = conversions.get(0).origQF; - Formula checkFormula = qf.not(); - - // verifying candidate - Bounds pi = bounds.clone(); - for (Relation r : pi.relations()) { - pi.boundExactly(r, inst.tuples(r)); - } - rep.holVerifyingCandidate(Some4All.this, inst, checkFormula, pi); - Translation checkTr = Translator.translate(checkFormula, pi, options); - if (!checkTr.cnf().solve()) { - rep.holCandidateVerified(Some4All.this, inst); - return true; - } else { - Instance cex = checkTr.interpret(); - - Collection holSkolems = inst.skolems(); - holSkolems.removeAll(bounds.skolems()); - assert holSkolems.size() == 1; - Relation sk = holSkolems.iterator().next(); - TupleSet clqTuples = cex.tuples(sk.name()); - - final Variable v = qf.decls().get(0).variable(); - final Expression cexExpr = pi.ts2expr(clqTuples); - Formula cexInst = qf.formula().accept(new AbstractReplacer(annotated.sharedNodes()) { - - @Override - public Expression visit(Variable variable) { - if (variable == v) - return cexExpr; - return super.visit(variable); - } - }); - Formula inc = cexInst; - rep.holCandidateNotVerified(Some4All.this, inst, cex); - rep.holFindingNextCandidate(Some4All.this, inc); - convTr = convTr.next(inc); - } - } - return false; - } - - @Override - public boolean solve() throws SATAbortedException { - rep.holLoopStart(Some4All.this, convTr.formula(), convTr.bounds()); - return solveNext(); - } - } - } - - protected HOLTranslationOld(Bounds bounds, Options options) { - super(bounds, options, 0); - } - - @Override - public boolean isFirstOrder() { - return false; - } - - @Override - public Translation getCurrentFOLTranslation() { - return null; - } - - @Override - public int numCandidates() { - return 1; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslator.java deleted file mode 100644 index 170da8382..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/HOLTranslator.java +++ /dev/null @@ -1,323 +0,0 @@ -package kodkod.engine.hol; - -import static kodkod.util.nodes.AnnotatedNode.annotate; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.operator.Quantifier; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.FullNegationPropagator; -import kodkod.engine.fol2sat.Skolemizer; -import kodkod.engine.hol.Proc.FOL; -import kodkod.engine.hol.Proc.Fixpoint; -import kodkod.engine.hol.Proc.OR; -import kodkod.engine.hol.Proc.Some4All; -import kodkod.instance.Bounds; -import kodkod.util.nodes.AnnotatedNode; - -class Conversion { - - final QuantifiedFormula origQF; - final QuantifiedFormula newQF; - - Conversion(QuantifiedFormula origQF, QuantifiedFormula newQF) { - this.origQF = origQF; - this.newQF = newQF; - } -} - -/** - * IMPORTANT: May only be applied to formulas in NNF - */ -public class HOLTranslator implements ReturnVisitor { - - private final Bounds bounds; - private final Options options; - private final AnnotatedNode annotated; - - HOLTranslator(Bounds bounds, Options options, AnnotatedNode annotated) { - this.bounds = bounds; - this.options = options; - this.annotated = annotated; - if (!annotated.hasHOLannotations()) - annotated.annotateHOL(); - } - - @Override - public Decls visit(Decls decls) { - return decls; - } - - @Override - public Decls visit(Decl decl) { - return decl; - } - - @Override - public Expression visit(Relation relation) { - return relation; - } - - @Override - public Expression visit(Variable variable) { - return variable; - } - - @Override - public Expression visit(ConstantExpression constExpr) { - return constExpr; - } - - @Override - public Expression visit(UnaryExpression unaryExpr) { - return unaryExpr; - } - - @Override - public Expression visit(BinaryExpression binExpr) { - return binExpr; - } - - @Override - public Expression visit(NaryExpression expr) { - return expr; - } - - @Override - public Expression visit(IfExpression ifExpr) { - return ifExpr; - } - - @Override - public Expression visit(ProjectExpression project) { - return project; - } - - @Override - public Expression visit(IntToExprCast castExpr) { - return castExpr; - } - - @Override - public IntExpression visit(IntConstant intConst) { - return intConst; - } - - @Override - public IntExpression visit(IfIntExpression intExpr) { - return intExpr; - } - - @Override - public IntExpression visit(ExprToIntCast intExpr) { - return intExpr; - } - - @Override - public IntExpression visit(NaryIntExpression intExpr) { - return intExpr; - } - - @Override - public IntExpression visit(BinaryIntExpression intExpr) { - return intExpr; - } - - @Override - public IntExpression visit(UnaryIntExpression intExpr) { - return intExpr; - } - - @Override - public IntExpression visit(SumExpression intExpr) { - return intExpr; - } - - @Override - public Expression visit(Comprehension comprehension) { - return comprehension; - } - - @Override - public Proc visit(IntComparisonFormula intComp) { - return new Proc.FOL(bounds, intComp); - } - - @Override - public Proc visit(ConstantFormula constant) { - return new Proc.FOL(bounds, constant); - } - - @Override - public Proc visit(ComparisonFormula cf) { - return new Proc.FOL(bounds, cf); - } - - @Override - public Proc visit(MultiplicityFormula multFormula) { - return new Proc.FOL(bounds, multFormula); - } - - @Override - public Proc visit(RelationPredicate predicate) { - return new Proc.FOL(bounds, predicate); - } - - @Override - public Proc visit(NotFormula not) { - assertNNF(not); - return new Proc.FOL(bounds, not); - } - - @Override - public Proc visit(BinaryFormula binFormula) { - if (annotated.isFOLNode(binFormula)) - return new Proc.FOL(bounds, binFormula); - Proc left, right; - if (binFormula.op() == FormulaOperator.OR) { - left = toProc(binFormula.left()); - right = toProc(binFormula.right()); - } else { - left = binFormula.left().accept(this); - right = binFormula.right().accept(this); - } - return left.compose(binFormula.op(), right); - } - - @Override - public Proc visit(NaryFormula formula) { - if (annotated.isFOLNode(formula)) - return new Proc.FOL(bounds, formula); - Proc ans = null; - for (Formula f : formula) { - Proc p = formula.op() == FormulaOperator.OR ? toProc(f) : f.accept(this); - ans = ans == null ? p : ans.compose(formula.op(), p); - } - return ans; - } - - @Override - public Proc visit(FixFormula fixFormula) { - Proc fProc = toProc(fixFormula.formula()); - Proc cProc = toProc(fixFormula.condition()); - return new Proc.Fixpoint(bounds, fixFormula, fProc, cProc); - } - - @Override - public Proc visit(QuantifiedFormula qf) { - assertNotSkolemizable(qf); - Formula qfFlipped = qf.body().quantify(qf.quantifier().opposite, qf.decls(), qf.domain()); - Proc body = toProc(qfFlipped); - boolean firstOrder = true; - for (Decl decl : qf.decls()) - if (decl.multiplicity() != Multiplicity.ONE) { - firstOrder = false; - break; - } - - if (firstOrder && body instanceof FOL && noNewHOLSkolems(((FOL) body).bounds.skolems(), bounds.skolems())) - return new Proc.FOL(bounds, qf); - else - return new Proc.Some4All(bounds, qf, body); - } - - private boolean noNewHOLSkolems(Collection newSkolems, Collection oldSkolems) { - Set diff = new HashSet(newSkolems); - diff.removeAll(oldSkolems); - for (Relation sk : diff) { - Decl d = sk.getSkolemVarDecl(); - if (d != null && d.multiplicity() != Multiplicity.ONE) - return false; - } - return true; - } - - private Proc toProc(Formula formula) { - return HOLTranslator.toProc(AnnotatedNode.annotate(formula, annotated.sources()), bounds, options); - } - - private void assertNotSkolemizable(QuantifiedFormula qf) { - if (qf.quantifier() == Quantifier.SOME) { - String msg = "It appears that the existential quantifier in '" + qf + "' is skolemizable, but it hasn't been"; - throw new IllegalStateException(msg); - } - } - - private void assertNNF(NotFormula not) { - Formula f = not.formula(); - if (f instanceof BinaryFormula || f instanceof NaryFormula || f instanceof QuantifiedFormula) - throw new IllegalStateException("Expected formula to be in NNF; got: " + not); - } - - public static Proc toProc(Formula formula, Bounds bounds, Options options) { - return toProc(annotate(formula), bounds, options); - } - - public static Proc toProc(final AnnotatedNode annotated, Bounds bounds, Options options) { - final Bounds newBounds = bounds.clone(); - AnnotatedNode nnf = FullNegationPropagator.toNNF(annotated, options.reporter()); - AnnotatedNode skl = Skolemizer.skolemize(nnf, newBounds, options); - return skl.node().accept(new HOLTranslator(newBounds, options, skl)); - } - - public static HOLTranslation proc2transl(Proc proc, Options options) { - return proc2transl(proc, options, 0); - } - - public static HOLTranslation proc2transl(Proc proc, Options options, int depth) { - if (proc instanceof Proc.FOL) - return new HOLTranslationNew.FOL((FOL) proc, options, depth); - if (proc instanceof Proc.Some4All) - return new HOLTranslationNew.Some4All((Some4All) proc, options, depth); - if (proc instanceof Proc.OR) - return new HOLTranslationNew.OR((OR) proc, options, depth); - if (proc instanceof Proc.Fixpoint) - return new HOLTranslationNew.Fixpoint((Fixpoint) proc, options, depth); - throw new RuntimeException("translation not implemented for " + proc.getClass().getName()); - } - - /** - * Don't call this for translating the top-level formula; call - * Translator.translateHOL instead - */ - static HOLTranslation translateHOL(Formula formula, Bounds bounds, Options options) { - return proc2transl(toProc(annotate(formula), bounds, options), options); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/NotTranslatableHOLException.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/NotTranslatableHOLException.java deleted file mode 100644 index ffe1abc13..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/NotTranslatableHOLException.java +++ /dev/null @@ -1,13 +0,0 @@ -package kodkod.engine.hol; - -public class NotTranslatableHOLException extends RuntimeException { - - private static final long serialVersionUID = -5630370128383715784L; - - public NotTranslatableHOLException() {} - - public NotTranslatableHOLException(String message) { - super(message); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/Proc.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/Proc.java deleted file mode 100644 index 9b7f823da..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/Proc.java +++ /dev/null @@ -1,656 +0,0 @@ -package kodkod.engine.hol; - -import java.lang.reflect.Array; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.operator.FormulaOperator; -import kodkod.engine.config.Options; -import kodkod.instance.Bounds; -import kodkod.util.collections.Pair; - -public abstract class Proc { - - public static class NotComposableException extends RuntimeException { - - private static final long serialVersionUID = -5979093923236801175L; - public final Proc left, right; - public final FormulaOperator op; - - public NotComposableException(FormulaOperator op, Proc left, Proc right) { - this.op = op; - this.left = left; - this.right = right; - } - } - - static abstract class Func { - - public abstract R run(); - } - - static abstract class Func1 { - - public abstract R run(A a); - } - - static abstract class Func2 { - - public abstract R run(A a, B b); - } - - @SuppressWarnings("unchecked" ) - static R[] map(A[] arr, R[] ans, Func1 func) { - ans = (R[]) Array.newInstance(ans.getClass().getComponentType(), arr.length); - for (int i = 0; i < arr.length; i++) - ans[i] = func.run(arr[i]); - return ans; - } - - static R fold(A[] arr, R acc, Func2 func) { - R ans = acc; - for (int i = 0; i < arr.length; i++) - ans = func.run(acc, arr[i]); - return ans; - } - - static int foldPlus(A[] arr, Func1 func) { - return foldPlus(arr, 0, func); - } - - static int foldPlus(A[] arr, int acc, Func1 func) { - for (int i = 0; i < arr.length; i++) - acc += func.run(arr[i]); - return acc; - } - - /** - * ======================================================================== - * Class Proc.FOL - * ======================================================================== - */ - public static final class FOL extends Proc { - - public final Formula formula; - - public FOL(final Bounds bounds, final Formula formula) { - super(bounds); - assert bounds != null; - this.formula = formula; - } - - @Override - public String print(String indent) { - return indent + "FOL(" + formula + ")"; - } - - @Override - public Formula formula() { - return formula; - } - - @Override - public Pair firstOrderProblem() { - return new Pair(formula, bounds); - } - - @Override - public boolean isFirstOrder() { - return true; - } - - @Override - public Proc compose(FormulaOperator op, Proc right) { - switch (op) { - case AND : - if (right instanceof FOL) { - return new FOL(superset(right), formula.and(((FOL) right).formula)); - } - if (right instanceof OR) { - return new OR(composeAll(op, this, ((OR) right).disjuncts)); - } - if (right instanceof AND) { - return ((AND) right).composeFormula(bounds, formula, op); - } - throw new NotComposableException(op, this, right); - case OR : - // if (right instanceof FOL && isSameBounds(right)) { return - // new FOL(bounds, formula.or(((FOL)right).formula)); } - // if (right instanceof FOL) { return new - // FOL(superset(right), formula.or(((FOL)right).formula)); } - if (right instanceof OR) { - return new OR(composeAll(op, this, ((OR) right).disjuncts)); - } - return new OR(this, right); - default : - throw new IllegalStateException("Expected formula in NNF; got operator: " + op); - } - } - } - - /** - * ======================================================================== - * Class Proc.HOL - * ======================================================================== - */ - public abstract static class HOL extends Proc { - - protected HOL(Bounds bounds) { - super(bounds); - } - } - - /** - * ======================================================================== - * Class Proc.ORSplit - * ======================================================================== - */ - public static class OR extends HOL { - - public final Proc[] disjuncts; - - public OR(Proc... splits) { - super(union(map(splits, new Bounds[0], new Func1() { - - @Override - public Bounds run(Proc a) { - return a.bounds(); - } - }))); - this.disjuncts = splits; - return; - // NOTE: not safe to merge FOLs, because stuff might have been - // skolemized. - // The caller can perform optimizations to create FOL instead of OR - // when safe. - // Proc mergedFOLs = null; - // List rest = new ArrayList(splits.length); - // for (Proc p : splits) { - // if (p instanceof FOL && mergedFOLs == null) - // mergedFOLs = p; - // else if (p instanceof FOL && mergedFOLs.isSameBounds(p)) - // mergedFOLs.compose(FormulaOperator.OR, p); - // else - // rest.add(p); - // } - // if (mergedFOLs == null) - // this.disjuncts = rest.toArray(new Proc[0]); - // else - // this.disjuncts = concat(new Proc[] { mergedFOLs }, - // rest.toArray(new Proc[0])); - } - - @Override - public boolean isFirstOrder() { - return false; - } - - @Override - public Formula formula() { - return Formula.or(map(disjuncts, new Formula[0], new Func1() { - - @Override - public Formula run(Proc p) { - return p.formula(); - } - })); - } - - @Override - public Pair firstOrderProblem() { - Formula[] formulas = new Formula[disjuncts.length]; - Bounds[] boundss = new Bounds[disjuncts.length]; - for (int i = 0; i < disjuncts.length; i++) { - Pair p = disjuncts[i].firstOrderProblem(); - formulas[i] = p.a; - boundss[i] = p.b; - } - return new Pair(Formula.or(formulas), union(boundss)); - } - - @Override - public String print(String indent) { - String ans = indent + "OR(\n"; - for (Proc split : disjuncts) - ans += split.print(indent + " ") + ", \n"; - ans += indent + ")"; - return ans; - } - - @Override - public Proc compose(FormulaOperator op, Proc right) { - switch (op) { - case AND : - if (right instanceof FOL) - return new OR(composeAll(op, disjuncts, right)); - if (right instanceof OR) - return new OR(composeAll(op, disjuncts, ((OR) right).disjuncts)); - if (right instanceof AND) - return new OR(composeAll(op, disjuncts, right)); // new - // OR(concat(disjuncts, - // new - // Proc[]{right})); - // ;// - throw new NotComposableException(op, this, right); - case OR : - if (right instanceof FOL) - return new OR(concat(disjuncts, new Proc[] { - right - })); - if (right instanceof OR) - return new OR(concat(disjuncts, ((OR) right).disjuncts)); - if (right instanceof AND) - return new OR(concat(disjuncts, new Proc[] { - right - })); - throw new NotComposableException(op, this, right); - default : - throw new IllegalStateException("Expected formula in NNF; got operator: " + op); - } - } - } - - /** - * ======================================================================== - * Class Proc.AndHOL - * ======================================================================== - */ - public static abstract class AND extends HOL { - - public static class QuantProc { - - public final Formula original; - public final Formula flipped; - public final Proc proc; - public final Proc cond; - - public QuantProc(Formula formula, Formula flippedFormula, Proc body) { - this(formula, flippedFormula, body, null); - } - - public QuantProc(Formula formula, Formula flippedFormula, Proc body, Proc cond) { - this.original = formula; - this.flipped = flippedFormula; - this.proc = body; - this.cond = cond; - } - } - - public final Formula conjuncts; - public final QuantProc[] quantProcs; - - public AND(Bounds bounds, Formula conj, QuantProc... qp) { - super(bounds); - this.conjuncts = conj; - this.quantProcs = qp; - } - - @Override - public boolean isFirstOrder() { - return false; - } - - @Override - public Formula formula() { - return fullFormula(); - } - - @Override - public Pair firstOrderProblem() { - Formula[] formulas = new Formula[quantProcs.length]; - Bounds[] boundss = new Bounds[quantProcs.length]; - for (int i = 0; i < quantProcs.length; i++) { - Pair p = quantProcs[i].proc.firstOrderProblem(); - formulas[i] = p.a; - boundss[i] = p.b; - } - return new Pair(Formula.and(formulas), union(boundss)); - } - - public Formula[] qpFormulas() { - return cache("qpf", new Func() { - - @Override - public Formula[] run() { - return map(quantProcs, new Formula[0], new Func1() { - - @Override - public Formula run(QuantProc a) { - return a.original; - } - }); - } - }); - } - - public Formula[] qpFlippedFormulas() { - return cache("qpff", new Func() { - - @Override - public Formula[] run() { - return map(quantProcs, new Formula[0], new Func1() { - - @Override - public Formula run(QuantProc a) { - return a.flipped; - } - }); - } - }); - } - - public Proc fullBodyProc() { - return cache("fbp", new Func() { - - @Override - public Proc run() { - return foldCompose(FormulaOperator.AND, map(quantProcs, new Proc[0], new Func1() { - - @Override - public Proc run(QuantProc a) { - return a.proc; - } - })); - } - }); - } - - public Proc fullFlippedProc() { - return cache("ffp", new Func() { - - @Override - public Proc run() { - Proc fbp = fullBodyProc(); - return new FOL(bounds, conjuncts).compose(FormulaOperator.AND, fbp); - } - }); - } - - public Formula fullFormula() { - return conjuncts.and(Formula.and(qpFormulas())); - } - - public Formula fullFlippedFormula() { - return conjuncts.and(Formula.and(qpFlippedFormulas())); - } - - public T composeFormula(Bounds leftBounds, Formula left, FormulaOperator op) { - assert op == FormulaOperator.AND : "can only compose with AND"; - return make(superset(leftBounds), left.and(conjuncts), quantProcs); - } - - public T composeFormula(Bounds rightBounds, FormulaOperator op, Formula right) { - assert op == FormulaOperator.AND : "can only compose with AND"; - return make(superset(rightBounds), conjuncts.and(right), quantProcs); - } - - protected abstract T make(Bounds b, Formula conj, QuantProc... qProcs); - - @Override - public Proc compose(FormulaOperator op, Proc right) { - switch (op) { - case AND : - if (right instanceof FOL) { - return composeFormula(right.bounds, op, ((FOL) right).formula); - } - if (right instanceof OR) { - return new OR(composeAll(op, this, ((OR) right).disjuncts)); - } - if (right instanceof AND) { - return make(superset(right), conjuncts.and(((AND) right).conjuncts), concat(quantProcs, ((AND) right).quantProcs)); - } - throw new NotComposableException(op, this, right); - case OR : - return new OR(this, right); - default : - throw new IllegalStateException("Expected formula in NNF; got operator: " + op); - } - } - - @Override - public String print(String indent) { - String ans = indent + getClass().getSimpleName() + "(\n"; - ans += indent + " " + conjuncts + ", \n"; - for (QuantProc qp : quantProcs) - ans += qp.proc.print(indent + " ") + ",\n"; - ans += indent + ")"; - return ans; - } - } - - /** - * ======================================================================== - * Class Proc.Fixpoint - * ======================================================================== - */ - public static class Fixpoint extends AND { - - public Fixpoint(Bounds bounds, FixFormula qf, Proc formProc, Proc condProc) { - this(bounds, Formula.TRUE, new QuantProc(qf, qf.formula(), formProc, condProc)); - } - - public Fixpoint(Bounds bounds, Formula conjuncts, QuantProc... qProcs) { - super(bounds, conjuncts, qProcs); - } - - @SuppressWarnings("unchecked" ) - @Override - protected Fixpoint make(Bounds b, Formula conj, QuantProc... qp) { - return new Fixpoint(b, conj, qp); - } - - public Formula[] qpConditionFormulas() { - return cache("qpcf", new Func() { - - @Override - public Formula[] run() { - return map(quantProcs, new Formula[0], new Func1() { - - @Override - public Formula run(QuantProc a) { - return ((FixFormula) a.original).condition(); - } - }); - } - }); - } - - public Formula fullConditionFormula() { - return Formula.and(qpConditionFormulas()); - } - } - - /** - * ======================================================================== - * Class Proc.Some4All - * ======================================================================== - */ - public static class Some4All extends AND { - - public Some4All(Bounds bounds, QuantifiedFormula qf, Proc body) { - this(bounds, Formula.TRUE, new QuantProc(qf, qf.body().quantify(qf.quantifier().opposite, qf.decls(), qf.domain()), body)); - } - - public Some4All(Bounds bounds, Formula conjuncts, QuantProc... qProcs) { - super(bounds, conjuncts, qProcs); - } - - @SuppressWarnings("unchecked" ) - @Override - protected Some4All make(Bounds b, Formula conj, QuantProc... qp) { - return new Some4All(b, conj, qp); - } - } - - // ======================================================================== - - protected final Bounds bounds; - private final Map cache = new HashMap(); - - protected Proc(Bounds bounds) { - this.bounds = bounds; - } - - // --------------------------------------------------------------------------------------------- - // TODO: is it ok not to care about ints? - // is it true that by construction all of these bounds will have the same - // ints? - protected boolean isSameBounds(Proc other) { - if (bounds == other.bounds) - return true; - return bounds.relations().containsAll(other.bounds.relations()); - } - - protected Bounds sameBounds(Proc other) { - assert isSameBounds(other) : "different bounds"; - return bounds; - } - - protected Bounds pickGreater(Proc other) { - if (bounds == other.bounds) - return bounds; - int n1 = bounds.relations().size(); - int n2 = other.bounds.relations().size(); - if (n1 == n2) - return sameBounds(other); - Bounds l, g; - if (n1 < n2) { - l = bounds; - g = other.bounds; - } else { - l = other.bounds; - g = bounds; - } - assert g.relations().containsAll(l.relations()) : "no superset for bounds"; - return g; - } - - protected Bounds superset(Proc other) { - return superset(other.bounds); - } - - protected Bounds superset(Bounds other) { - return Proc.union(this.bounds, other); - } - - // --------------------------------------------------------------------------------------------- - - @SuppressWarnings("unchecked" ) - protected V cache(String key, Func func) { - return (V) cache(cache, key, (Func) func); - } - - protected V cache(Map cache, K key, Func func) { - V ans = cache.get(key); - if (ans == null) { - ans = func.run(); - cache.put(key, ans); - } - return ans; - } - - public Bounds bounds() { - return bounds.unmodifiableView(); - } - - public String print() { - return print(""); - } - - public final HOLTranslation translate(Options options, int depth) { - return HOLTranslator.proc2transl(this, options, depth); - } - - public abstract boolean isFirstOrder(); - - public abstract Formula formula(); - - public abstract Pair firstOrderProblem(); - - public abstract Proc compose(FormulaOperator op, Proc right); - - public abstract String print(String indent); - - @Override - public String toString() { - return print(); - } - - public static Proc[] composeAll(FormulaOperator op, Proc lhs, Proc[] rhss) { - return composeAll(op, new Proc[] { - lhs - }, rhss); - } - - public static Proc[] composeAll(FormulaOperator op, Proc[] lhss, Proc rhs) { - return composeAll(op, lhss, new Proc[] { - rhs - }); - } - - public static Proc[] composeAll(FormulaOperator op, Proc[] lhss, Proc[] rhss) { - Proc[] ans = new Proc[lhss.length * rhss.length]; - for (int i = 0; i < lhss.length; i++) - for (int j = 0; j < rhss.length; j++) - ans[i * rhss.length + j] = lhss[i].compose(op, rhss[j]); - return ans; - } - - public static Proc foldCompose(FormulaOperator op, Proc[] procs) { - Proc ans = null; - for (int i = 0; i < procs.length; i++) - ans = ans == null ? procs[i] : ans.compose(op, procs[i]); - return ans; - } - - protected AND.QuantProc[] concat(AND.QuantProc[] a, AND.QuantProc[] b) { - return concat(a, b, new AND.QuantProc[a.length + b.length]); - } - - protected Proc[] concat(Proc[] a, Proc[] b) { - return concat(a, b, new Proc[a.length + b.length]); - } - - protected T[] concat(T[] a, T[] b, T[] ans) { - for (int i = 0; i < a.length; i++) - ans[i] = a[i]; - for (int i = 0; i < b.length; i++) - ans[a.length + i] = b[i]; - return ans; - } - - public static Bounds union(Bounds b1, Bounds b2) { - if (b1 == null) - return b2; - if (b2 == null) - return b1; - if (b1 == b2) - return b1; - if (b1.relations().containsAll(b2.relations())) - return b1; - if (b2.relations().containsAll(b1.relations())) - return b2; - Bounds ans = b1.clone(); - Set diff = new HashSet(b2.relations()); - // diff.removeAll(bounds.relations()); - for (Relation r : diff) - ans.bound(r, b2.lowerBound(r), b2.upperBound(r)); - return ans; - } - - public static Bounds union(Bounds[] bnds) { - if (bnds == null || bnds.length == 0) - return null; - Bounds ans = bnds[0]; - for (int i = 1; i < bnds.length; i++) - ans = union(ans, bnds[i]); - return ans; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/hol/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/package.html deleted file mode 100644 index a4ae68597..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/package.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - -Provides classes for analyzing and evaluating Kodkod ASTs with -respect to finite bounds or instances. - -

Package Specification

- -

Contains classes for analyzing and evaluating Kodkod ASTs with -respect to finite bounds or instances. A {@linkplain kodkod.engine.Solver Solver} -provides methods for finding finite models and minimal unsatisfiable cores of Kodkod formulas with respect -to given {@linkplain kodkod.instance.Bounds Bounds} and {@linkplain kodkod.engine.config.Options Options}. -An {@linkplain kodkod.engine.IncrementalSolver IncrementalSolver} provides a way to solve a sequence of -related formulas and bounds incrementally, with respect to the same -{@linkplain kodkod.engine.config.Options Options options}. -An {@linkplain kodkod.engine.Evaluator Evaluator} enables the evaluation of formulas, expressions, and -integer expressions with respect to a particular {@linkplain kodkod.instance.Instance Instance} and -{@linkplain kodkod.engine.config.Options Options}. - -

- -

Related Documentation

- -@see kodkod.instance.Bounds -@see kodkod.instance.Instance -@see kodkod.ast.Expression -@see kodkod.ast.IntExpression -@see kodkod.ast.Formula -@see kodkod.engine.Solver -@see kodkod.engine.IncrementalSolver -@see kodkod.engine.Evaluator - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Clause.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Clause.java deleted file mode 100644 index 591103f9c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Clause.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.util.Iterator; - -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.Ints; - -/** - * A propositional clause. - * - * @specfield literals: set int - * @specfield antecedents: Clause[] - * @invariant 0 !in literals - * @invariant no lit: literals | -lit in literals - * @invariant some antecedents => #antecedents > 1 - * @invariant some antecedents => literals = { lit: antecedents[int].literals | - * no i: [0..#antecedents-1) | lit in antecedents[i].literals && -lit - * in antecedents[i+1].literals } - * @author Emina Torlak - */ -public abstract class Clause { - - /** - * Constructs a new clause. - */ - protected Clause() {} - - /** - * Returns the size of this clause, measured in the number of literals. - * - * @return #this.literals - */ - public abstract int size(); - - /** - * Returns an iterator over the literals in this clause, in the ascending order - * of absolute values. - * - * @return an iterator over this.literals - */ - public abstract IntIterator literals(); - - /** - * Returns the largest variable identifier occurring in this.literals. - * - * @return max(abs(this.literals)) - */ - public abstract int maxVariable(); - - /** - * Copies this.literals into the specified array, provided that it is large - * enough, and returns it. If the array is not large enough, a new array is - * allocated, populated with this.literals, and returned. - * - * @return the given array, filled with this.literals, if the it is large - * enough; otherwise a new array containing this.literals - * @throws NullPointerException array = null - */ - public abstract int[] toArray(int[] array); - - /** - * Returns a new array of length this.size(), initialized with this.literals. - * - * @return a new array of length this.size(), initialized with this.literals. - */ - public int[] toArray() { - return toArray(new int[size()]); - } - - /** - * Returns the number of antecedents of this clause. - * - * @return #this.antecedents - */ - public abstract int numberOfAntecedents(); - - /** - * Returns an iterator that traverses this.antecedents in proper sequence. - *

- * Note:The clause objects returned by the iterator are not required to - * be immutable. In particular, the state of a clause object returned by - * next() (as well as the state of any object obtained through that - * clause's {@linkplain Clause#antecedents()} methods) is guaranteed to remain - * the same only until the subsequent call to next(). - *

- * - * @return an iterator that traverses this.antecedents in proper sequence. - */ - public abstract Iterator antecedents(); - - /** - * // * Returns the antecedent at the given index. // * @requires 0 <= index < - * this.numberOfAntecedents() // * @return this.antecedents[index] // * @throws - * IndexOutOfBoundsException index < 0 || index >= this.numberOfAntecedents() // - */ - // public abstract Clause antecedent(int index); - - /** - * Returns true if o is a Clause whose literals and antecedents are - * equal to those of this clause. - * - * @return o in Clause && o.literals.equals(this.literals) && - * o.antecedents.equals(this.antecedents) - */ - @Override - public boolean equals(Object o) { - if (o == this) - return true; - if (o instanceof Clause) { - final Clause c = (Clause) o; - if (size() == c.size()) { - final IntIterator itr1 = literals(), itr2 = literals(); - while (itr1.hasNext()) { - if (itr1.next() != itr2.next()) - return false; - } - } - final int ante = numberOfAntecedents(); - if (ante > 0 && ante == c.numberOfAntecedents()) { - final Iterator itr1 = antecedents(), itr2 = c.antecedents(); - while (itr1.hasNext()) { - if (!itr1.next().equals(itr2.next())) - return false; - } - } - return ante == 0; - } - return false; - } - - /** - * Returns the hashcode for this clause. The hashcode for a clause is equivalent - * to Ints.superFastHash(x) where x is an array such that its first this.size() - * elements are the literals of this clause (as returned by this.literals()) and - * its remaining this.numberOfAntecedents() elements are the hashCodes of - * this.antecedents (as returned by this.antecedents()). - * - * @return hashcode for this clause - */ - @Override - public int hashCode() { - int hash = size() + numberOfAntecedents(); - for (IntIterator iter = literals(); iter.hasNext();) { - hash = Ints.superFastHashIncremental(iter.next(), hash); - } - for (Iterator iter = antecedents(); iter.hasNext();) { - hash = Ints.superFastHashIncremental(iter.next().hashCode(), hash); - } - return Ints.superFastHashAvalanche(hash); - } - - /** - * Returns a string representation of this clause. - * - * @return a string representation of this clause. - */ - @Override - public String toString() { - final StringBuilder ret = new StringBuilder(); - if (numberOfAntecedents() == 0) { - ret.append("AXIOM"); - } else { - ret.append("RESOLVENT"); - } - ret.append(". Literals: {"); - for (IntIterator iter = literals(); iter.hasNext();) { - ret.append(" "); - ret.append(iter.next()); - } - ret.append(" }"); - return ret.toString(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/CryptoMiniSat.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/CryptoMiniSat.java deleted file mode 100644 index bfe4deab7..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/CryptoMiniSat.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Java wrapper for the CryptoMiniSat solver by Mate Soos. - * - * @author Emina Torlak - */ -final class CryptoMiniSat extends NativeSolver { - - /** - * Constructs a new MiniSAT wrapper. - */ - public CryptoMiniSat() { - super(make()); - // TODO Auto-generated constructor stub - } - - static { - loadLibrary(CryptoMiniSat.class); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "CryptoMiniSat"; - } - - /** - * Returns a pointer to an instance of MiniSAT. - * - * @return a pointer to an instance of minisat. - */ - private static native long make(); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#free(long) - */ - @Override - native void free(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addVariables(long, int) - */ - @Override - native void addVariables(long peer, int numVariables); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addClause(long, int[]) - */ - @Override - native boolean addClause(long peer, int[] lits); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#solve(long) - */ - @Override - native boolean solve(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#valueOf(long, int) - */ - @Override - native boolean valueOf(long peer, int literal); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ExternalSolver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ExternalSolver.java deleted file mode 100644 index dfea3da78..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ExternalSolver.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.List; - -/** - * An implementation of a wrapper for an external SAT solver, executed in a - * separate process. - * - * @author Emina Torlak - */ -final class ExternalSolver implements SATSolver { - - private final StringBuilder buffer; - private final int capacity = 8192; - private final boolean deleteTemp; - private final String executable, inTemp; - private final String[] options; - private final RandomAccessFile cnf; - private final BitSet solution; - private volatile Boolean sat; - private volatile int vars, clauses; - - /** - * Constructs an ExternalSolver that will execute the specified binary with the - * given options on the {@code inTemp} file. The {@code inTemp} file will be - * initialized to contain all clauses added to this solver via the - * {@link #addClause(int[])} method. The solver is assumed to write its output - * to standard out. The {@code deleteTemp} flag indicates whether the temporary - * files should be deleted when they are no longer needed by this solver. - */ - ExternalSolver(String executable, String inTemp, boolean deleteTemp, String... options) { - RandomAccessFile file = null; - try { - file = new RandomAccessFile(inTemp, "rw"); - file.setLength(0); - } catch (FileNotFoundException e) { - throw new SATAbortedException(e); - } catch (IOException e) { - close(file); - throw new SATAbortedException(e); - } - this.deleteTemp = deleteTemp; - this.cnf = file; - // get enough space into the buffer for the cnf header, which will be - // written last - this.buffer = new StringBuilder(); - for (int i = headerLength(); i > 0; i--) { - buffer.append(" "); - } - buffer.append("\n"); - this.sat = null; - this.solution = new BitSet(); - this.vars = 0; - this.clauses = 0; - this.executable = executable; - this.inTemp = inTemp; - // remove empty strings from the options array - final List nonEmpty = new ArrayList(options.length); - for (String opt : options) { - if (!opt.isEmpty()) - nonEmpty.add(opt); - } - this.options = nonEmpty.toArray(new String[nonEmpty.size()]); - } - - /** - * Silently closes the given resource if it is non-null. - */ - private static void close(Closeable closeable) { - try { - if (closeable != null) - closeable.close(); - } catch (IOException e) {} // ignore - } - - /** - * Returns the length, in characters, of the longest possible header for a cnf - * file: p cnf Integer.MAX_VALUE Integer.MAX_VALUE - * - * @return the length, in characters, of the longest possible header for a cnf - * file: p cnf Integer.MAX_VALUE Integer.MAX_VALUE - */ - private static final int headerLength() { - return String.valueOf(Integer.MAX_VALUE).length() * 2 + 8; - } - - /** - * Flushes the contents of the string buffer to the cnf file. - */ - private final void flush() { - try { - cnf.writeBytes(buffer.toString()); - } catch (IOException e) { - close(cnf); - throw new SATAbortedException(e); - } finally { - buffer.setLength(0); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#addClause(int[]) - */ - @Override - public boolean addClause(int[] lits) { - clauses++; - if (buffer.length() > capacity) - flush(); - for (int lit : lits) { - buffer.append(lit); - buffer.append(" "); - } - buffer.append("0\n"); - return true; - } - - /** - * @see kodkod.engine.satlab.SATSolver#addVariables(int) - */ - @Override - public void addVariables(int numVars) { - if (numVars < 0) - throw new IllegalArgumentException("vars < 0: " + numVars); - vars += numVars; - } - - /** - * @see kodkod.engine.satlab.SATSolver#free() - */ - @Override - public synchronized void free() { - close(cnf); - if (deleteTemp) { - (new File(inTemp)).delete(); - } - } - - /** - * Releases the resources used by this external solver. - */ - @Override - protected final void finalize() throws Throwable { - super.finalize(); - free(); - } - - /** - * @see kodkod.engine.satlab.SATSolver#numberOfClauses() - */ - @Override - public int numberOfClauses() { - return clauses; - } - - /** - * @see kodkod.engine.satlab.SATSolver#numberOfVariables() - */ - @Override - public int numberOfVariables() { - return vars; - } - - /** - * @ensures |lit| <= this.vars && lit != 0 => this.solution'.set(|lit|, lit>0) - * @throws SATAbortedException lit=0 || |lit|>this.vars - */ - private final void updateSolution(int lit) { - int abs = StrictMath.abs(lit); - if (abs <= vars && abs > 0) - solution.set(abs - 1, lit > 0); - else - throw new SATAbortedException("Invalid variable value: |" + lit + "| !in [1.." + vars + "]"); - } - - /** - * @see kodkod.engine.satlab.SATSolver#solve() - */ - @Override - @SuppressWarnings("resource" ) // suppressing spurious warning about "out" - // not being closed (it is, in the finally - // block) - public boolean solve() throws SATAbortedException { - if (sat == null) { - flush(); - Process p = null; - BufferedReader out = null; - try { - cnf.seek(0); - cnf.writeBytes("p cnf " + vars + " " + clauses); - cnf.close(); - - final String[] command = new String[options.length + 2]; - command[0] = executable; - System.arraycopy(options, 0, command, 1, options.length); - command[command.length - 1] = inTemp; - p = Runtime.getRuntime().exec(command); - new Thread(drain(p.getErrorStream())).start(); - out = outputReader(p); - String line = null; - while ((line = out.readLine()) != null) { - String[] tokens = line.split("\\s"); - int tlength = tokens.length; - if (tlength > 0) { - if (tokens[0].compareToIgnoreCase("s") == 0) { - if (tlength == 2) { - if (tokens[1].compareToIgnoreCase("SATISFIABLE") == 0) { - sat = Boolean.TRUE; - continue; - } else if (tokens[1].compareToIgnoreCase("UNSATISFIABLE") == 0) { - sat = Boolean.FALSE; - continue; - } - } - throw new SATAbortedException("Invalid " + executable + " output. Line: " + line); - } else if (tokens[0].compareToIgnoreCase("v") == 0) { - int last = tlength - 1; - for (int i = 1; i < last; i++) { - updateSolution(Integer.parseInt(tokens[i])); - } - int lit = Integer.parseInt(tokens[last]); - if (lit != 0) - updateSolution(lit); - else if (sat != null) - break; - } // not a solution line or a variable line, so ignore - // it. - } - } - if (sat == null) { - throw new SATAbortedException("Invalid " + executable + " output: no line specifying the outcome."); - } - } catch (IOException e) { - throw new SATAbortedException(e); - } catch (NumberFormatException e) { - throw new SATAbortedException("Invalid " + executable + " output: encountered a non-integer variable token.", e); - } finally { - close(cnf); - close(out); - } - } - return sat; - } - - /** - * Returns a runnable that drains the specified input stream. - * - * @return a runnable that drains the specified input stream. - */ - private static Runnable drain(final InputStream input) { - return new Runnable() { - - @Override - public void run() { - try { - final byte[] buffer = new byte[8192]; - while (true) { - int n = input.read(buffer); - if (n < 0) - break; - } - } catch (IOException ex) {} finally { - close(input); - } - } - }; - } - - /** - * Returns a reader for reading the output of the given process. - * - * @return a reader for reading the output of the given process. - * @throws IOException - */ - private BufferedReader outputReader(Process p) throws IOException { - try { - return new BufferedReader(new InputStreamReader(p.getInputStream(), "ISO-8859-1")); - } catch (IOException e) { - close(p.getInputStream()); - throw e; - } - } - - /** - * @see kodkod.engine.satlab.SATSolver#valueOf(int) - */ - @Override - public boolean valueOf(int variable) { - if (!Boolean.TRUE.equals(sat)) - throw new IllegalStateException(); - if (variable < 1 || variable > vars) - throw new IllegalArgumentException(variable + " !in [1.." + vars + "]"); - return solution.get(variable - 1); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return executable + " " + options; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Glucose.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Glucose.java deleted file mode 100644 index a2af29649..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Glucose.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2012, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Java wrapper for the Glucose solver by G. Audemard and L. Simon. - * - * @author Emina Torlak - */ -final class Glucose extends NativeSolver { - - /** - * Constructs a new Glucose wrapper. - */ - Glucose() { - super(make()); - } - - static { - loadLibrary(Glucose.class); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Glucose"; - } - - /** - * Returns a pointer to an instance of the glucose solver. - * - * @return a pointer to an instance of the glucose solver. - */ - private static native long make(); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#free(long) - */ - @Override - native void free(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addVariables(long, int) - */ - @Override - native void addVariables(long peer, int numVariables); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addClause(long, int[]) - */ - @Override - native boolean addClause(long peer, int[] lits); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#solve(long) - */ - @Override - native boolean solve(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#valueOf(long, int) - */ - @Override - native boolean valueOf(long peer, int literal); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Glucose41.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Glucose41.java deleted file mode 100644 index c097686a1..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Glucose41.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2012, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Java wrapper for the Glucose solver (v4.1) by G. Audemard and L. Simon. - * - * @author Emina Torlak - */ -final class Glucose41 extends NativeSolver { - - /** - * Constructs a new Glucose wrapper. - */ - Glucose41() { - super(make()); - } - - static { - loadLibrary(Glucose41.class); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Glucose41"; - } - - /** - * Returns a pointer to an instance of the glucose solver. - * - * @return a pointer to an instance of the glucose solver. - */ - private static native long make(); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#free(long) - */ - @Override - native void free(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addVariables(long, int) - */ - @Override - native void addVariables(long peer, int numVariables); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addClause(long, int[]) - */ - @Override - native boolean addClause(long peer, int[] lits); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#solve(long) - */ - @Override - native boolean solve(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#valueOf(long, int) - */ - @Override - native boolean valueOf(long peer, int literal); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/LazyTrace.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/LazyTrace.java deleted file mode 100644 index 5f886f6df..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/LazyTrace.java +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import kodkod.util.collections.Containers; -import kodkod.util.ints.IntBitSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * An array-backed implementation of the {@linkplain ResolutionTrace} interface. - * Resolvent literals are computed on-demand, and only the resolvents reachable - * from the conflict clause are stored. - * - * @author Emina Torlak - */ -final class LazyTrace implements ResolutionTrace { - - /* - * The trace array encodes the resolution trace as follows. The first - * axioms entries in the trace array contain the literals of the - * clauses added to the prover, in the order in which they were added. The - * remaining entries encode the resolvents as follows. Let i >= axioms - * represent the ith resolvent. If resolved.contains(i-axioms), then trace[i][0] - * contains the number of the resolvent's antecedents; trace[i][1..trace[i][0]] - * contains the indices of the resolvent's antecedents in the trace; and - * trace[i][trace[i][0]+1..trace[i].length-1] contains the literals of the ith - * resolvent. Otherwise, the literals for the given resolvent have not yet been - * computed so trace[i][0..trace[i].length-1] contains the indices of the - * resolvent's antecedents. All computed and axiom literals are sorted in the - * increasing order of absolute values. All antecedents of a given resolvent - * precede it in the trace, and the conflict clause should be the last trace - * element. - */ - private final int[][] trace; - private final int axioms; - private final IntSet core, resolved; - - /** - * Constructs a resolution trace view for the given raw trace. The first - * axioms entries in the trace array should contain the literals of the - * clauses added to the prover, in the order in which they were added. The - * literals should be sorted in the increasing order of absolute values. The - * remaining entries should encode the resolvents as follows. Let i be the index - * of a resolvent in the raw trace. Then, for all 0 <= j < trace[i].length, - * trace[i][j] is the index of the resolvent's jth antecedents in the trace - * array. All antecedents of a given resolvent should precede it in the trace, - * and the conflict clause should be the last trace element. - *

- * Note: the given array's contents must not be modified while in use by - * this resolution trace object. - *

- */ - LazyTrace(int[][] trace, int axioms) { - this.axioms = axioms; - - // find all the clauses that are reachable from the conflict - final IntSet reachable = reachable(trace, axioms); - - // get the core clauses - this.core = core(reachable, axioms); - - // trim the trace so that it contains all axioms but only those - // resolvents that are reachable from the conflict - this.trace = compress(trace, axioms, reachable, core); - - // we haven't computed any resolvent literals yet ... - this.resolved = new IntBitSet(this.trace.length - axioms); - } - - /** - * Constructs a resolution trace from the given subtrace and partial trace. This - * constructor assumes that partial is the result of solving the - * subtrace of the original trace that is given by the specified set of - * indices. The first indices.size() of the partial trace are assumed to - * represent the clauses given by original.trace[indices], in the increasing - * order of indices; the remaining entries should encode the resolvents computed - * from original.trace[indices], as specified by - * {@linkplain #LazyTrace(int[][], int)}. The given subtrace of the original - * trace must be self-contained, i.e. - * original.reachable(indices).equals(indices). - *

- * Note: the given array's contents must not be modified while in use by - * this resolution trace object. - *

- */ - LazyTrace(LazyTrace original, IntSet indices, int[][] partial) { - this.axioms = reconstruct(original, indices, partial); - - // find all the clauses that are reachable from the conflict - final IntSet reachable = reachable(partial, axioms); - - // get the core clauses - this.core = core(reachable, axioms); - - // trim the trace so that it contains all axioms but only those - // resolvents that are reachable from the conflict - this.trace = compress(partial, axioms, reachable, core); - - // we haven't computed any resolvent literals yet ... - this.resolved = new IntBitSet(this.trace.length - axioms); - } - - /** - * Fills the first indices.size() empty positions of the partial trace with the - * corresponding clauses from the original trace and returns the number of - * axioms in the reconstructed trace. - * - * @requires original, indices, and partial are as specified by - * {@linkplain #LazyTrace(LazyTrace, IntSet, int[][])} constructor - * @ensures modifies partial so that it conforms to the {@linkplain #trace - * LazyTrace.trace} spec using the provided original trace and indices. - * @return number of axioms in the modified partial trace - */ - private static int reconstruct(LazyTrace original, IntSet indices, int[][] partial) { - int axiomCount = indices.size(); - // fill the partial[0..indices.size()-1] with the corresponding clauses - // from original.trace[indices] - final int[][] originalTrace = original.trace; - final int[] position = new int[indices.max() + 1]; - - IntIterator itr = indices.iterator(); - for (int i = 0, length = indices.size(); i < length; i++) { - int index = itr.next(); - position[index] = i; - if (original.axiom(index)) { // just set the ith pointer to original - // literals - partial[i] = originalTrace[index]; - } else { // copy the resolvent and adjust copy's antecedent indices - int antes = originalTrace[index][0]; - int[] resolvent = new int[antes]; - for (int j = 0; j < antes; j++) { - resolvent[j] = position[originalTrace[index][j + 1]]; - } - partial[i] = resolvent; - axiomCount--; - } - } - - return axiomCount; - } - - /** - * Returns the indices of all clauses in the given trace that are reachable from - * the conflict clause through the resolvents in trace[roots..trace.length-1]. - * This method assumes that that the last trace[roots..trace.length-1] clauses - * encode resolvents as specified by the {@linkplain #LazyTrace(int[][], int)} - * constructor. - * - * @return indices of all clauses in the given trace that are reachable from the - * conflict clause through the resolvents in - * trace[roots..trace.length-1] - */ - private static IntSet reachable(int[][] trace, int roots) { - final IntSet reachable = new IntBitSet(trace.length); - reachable.add(trace.length - 1); - for (int i = trace.length - 1; i >= roots; i--) { - if (reachable.contains(i)) { - int[] resolvent = trace[i]; - for (int j = 0; j < resolvent.length; j++) { - reachable.add(resolvent[j]); - } - } - } - return reachable; - } - - /** - * Returns a set that contains the elements from the given reachable between 0, - * inclusive, and axioms, exclusive. - * - * @return a set that contains the elements from the given reachable between 0, - * inclusive, and axioms, exclusive. - */ - private static IntSet core(IntSet reachable, int axioms) { - final IntSet core = new IntBitSet(axioms); - for (IntIterator itr = reachable.iterator(0, axioms - 1); itr.hasNext();) { - core.add(itr.next()); - } - return Ints.unmodifiableIntSet(core); - } - - /** - * Compresses the given src trace into a destination trace that contains the - * same axioms as the source but only the resolvents that are reachable from the - * conflict clause. - * - * @requires src and axioms are as specified by the - * {@linkplain #LazyTrace(int[][], int)} constructor - * @requires reachable.elts = reachable(src, axioms).elts - * @requires core.elts = core(reachable, axioms).elts - * @ensures invalidates the contents of src; src should not be used after this - * method returns - * @return a new trace that contains the same axioms as the source but only the - * resolvents that are reachable from the conflict clause. - */ - private static int[][] compress(int[][] src, int axioms, IntSet reachable, IntSet core) { - final int[][] dest = new int[reachable.size() - core.size() + axioms][]; - System.arraycopy(src, 0, dest, 0, axioms); - - final int[] pos = new int[src.length - axioms]; - final IntIterator srcIdxs = reachable.iterator(axioms, src.length); - for (int i = axioms; srcIdxs.hasNext(); i++) { - int srcIdx = srcIdxs.next(); - pos[srcIdx - axioms] = i; - // move the resolvent and adjust its antecedent indices - int[] resolvent = src[srcIdx]; - dest[i] = resolvent; - for (int j = 0, lastAnte = resolvent.length; j < lastAnte; j++) { - int ante = resolvent[j]; - resolvent[j] = ante < axioms ? ante : pos[ante - axioms]; - } - } - return dest; - } - - /** - * Returns an array of integers representing the result of resolving the clauses - * c1 and c2, sorted in the increasing order of absolute values. The parameters - * axiom1 and axiom2 specify whether c1 and c2 encode axioms or resolvents. In - * particular, if axiom1 (resp. axiom2) is true, then all integers in c1 (resp. - * c2) are assumed to be literals, sorted in the increasing order of absolute - * values. If axiom1 (resp. axiom2) is false, then the integers starting at - * c1[0]+1 (resp. c2[0]+1) are assumed to be literals, sorted in the increasing - * order of absolute values. - * - * @requires let off1 = axiom1 ? 0 : c1[0] + 1, off2 = axiom2 ? 0 : c2[0]+1 | - * (all i: [off1..c1.length), j: [off1..c1.length) | i < j => - * abs(c1[i]) < abs(c1[j])) and (all i: [off2..c2.length), j: - * [off2..c2.length) | i < j => abs(c2[i]) < abs(c2[j])) and (one i: - * [off1..c1.length), j: [off2..c2.length) | c1[i] = -c2[j]) - * @return an array of integers representing the result of resolving the clauses - * c1 and c2, sorted in the increasing order of absolute values - */ - private static int[] resolve(int[] c1, boolean axiom1, int[] c2, boolean axiom2) { - final int len1 = c1.length, len2 = c2.length; - int i = axiom1 ? 0 : c1[0] + 1; - int j = axiom2 ? 0 : c2[0] + 1; - int k = 0; - - final int[] tmp = new int[(len1 - i + len2 - j) - 2]; - - while (i < len1 && j < len2) { - int lit1 = c1[i], lit2 = c2[j]; - int var1 = StrictMath.abs(lit1), var2 = StrictMath.abs(lit2); - if (var1 == var2) { - if (lit1 == lit2) { - tmp[k++] = lit1; - } - i++; - j++; - } else if (var1 < var2) { - tmp[k++] = lit1; - i++; - } else { // var1 > var2 - tmp[k++] = lit2; - j++; - } - } - if (i < len1) { - final int rem = len1 - i; - System.arraycopy(c1, i, tmp, k, rem); - k += rem; - } - if (j < len2) { - final int rem = len2 - j; - System.arraycopy(c2, j, tmp, k, rem); - k += rem; - } - if (k == tmp.length) { - return tmp; - } else { - final int[] ret = new int[k]; - System.arraycopy(tmp, 0, ret, 0, k); - return ret; - } - } - - /** - * Computes the resolvent at the given index, sets this.trace index to the - * computed resolvent and returns it. - * - * @ensures computes the resolvent at the given index and sets trace[index] to - * the computed array. - * @return this.trace'[index] - */ - private int[] resolve(int index) { - if (index < axioms || resolved(index)) - return trace[index]; - int[] ante = trace[index]; - int[] lits = resolve(resolve(ante[0]), ante[0] < axioms, resolve(ante[1]), ante[1] < axioms); - for (int j = 2; j < ante.length; j++) { - lits = resolve(lits, true, resolve(ante[j]), ante[j] < axioms); - } - int[] resolvent = new int[ante.length + lits.length + 1]; - resolvent[0] = ante.length; - System.arraycopy(ante, 0, resolvent, 1, ante.length); - System.arraycopy(lits, 0, resolvent, ante.length + 1, lits.length); - trace[index] = resolvent; - resolved.add(index - axioms); - return resolvent; - } - - /** - * @return true if resolvent literals have been computed for the resolvent at - * the given index - */ - private boolean resolved(int index) { - return resolved.contains(index - axioms); - } - - /** - * Returns true if the clause at the given index is an axiom. - * - * @return index < this.axioms - */ - private boolean axiom(int index) { - return index < axioms; - } - - /** - * Returns the offset in this.trace[index] array where literal data is stored, - * if any. - * - * @return axiom(index) ? 0 : resolved(index) ? this.trace[index][0] + 1 : -1 - */ - private int litOffset(int index) { - return axiom(index) ? 0 : resolved(index) ? trace[index][0] + 1 : -1; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#size() - */ - @Override - public int size() { - return trace.length; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#core() - */ - @Override - public IntSet core() { - return core; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#axioms() - */ - @Override - public IntSet axioms() { - return Ints.rangeSet(Ints.range(0, axioms - 1)); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#resolvents() - */ - @Override - public IntSet resolvents() { - if (trace.length > axioms) - return Ints.rangeSet(Ints.range(axioms, trace.length - 1)); - else - return Ints.EMPTY_SET; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#get(int) - */ - @Override - public Clause get(final int index) { - if (index >= 0 && index < trace.length) { - if (axiom(index)) { // return a self-contained clause - return new Clause() { - - final int[] literals = trace[index]; - final int hashCode = Ints.superFastHash(literals); - - @Override - public Iterator antecedents() { - return Containers.emptyIterator(); - } - - @Override - public IntIterator literals() { - return new IntArrayIterator(literals, 0, literals.length); - } - - @Override - public int maxVariable() { - return StrictMath.abs(literals[literals.length - 1]); - } - - @Override - public int numberOfAntecedents() { - return 0; - } - - @Override - public int size() { - return literals.length; - } - - @Override - public int[] toArray(int[] array) { - if (array.length < literals.length) { - array = new int[literals.length]; - } - System.arraycopy(literals, 0, array, 0, literals.length); - return array; - } - - @Override - public int hashCode() { - return hashCode; - } - }; - } else { - return new ClauseView(index); - } - } - throw new IndexOutOfBoundsException("invalid index: " + index); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#iterator() - */ - @Override - public Iterator iterator() { - return new ClauseIterator(new IntIterator() { - - int index = 0; - - @Override - public boolean hasNext() { - return index >= 0 && index < trace.length; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - return index++; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }); - } - - /** - * Returns true if indices.min() >= 0 && indices.max() < this.size() - * - * @requires !indices.isEmpty() - * @return indices.min() >= 0 && indices.max() < this.size() - */ - private boolean valid(IntSet indices) { - return indices.min() >= 0 && indices.max() < trace.length; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#iterator(kodkod.util.ints.IntSet) - */ - @Override - public Iterator iterator(IntSet indices) { - if (indices.isEmpty() || valid(indices)) { - return new ClauseIterator(indices.iterator()); - } - throw new IndexOutOfBoundsException("invalid indices: " + indices); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#reverseIterator(kodkod.util.ints.IntSet) - */ - @Override - public Iterator reverseIterator(IntSet indices) { - if (indices.isEmpty() || valid(indices)) { - return new ClauseIterator(indices.iterator(Integer.MAX_VALUE, Integer.MIN_VALUE)); - } - throw new IndexOutOfBoundsException("invalid indices: " + indices); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#implicants(kodkod.util.ints.IntSet) - */ - @Override - public IntSet reachable(IntSet indices) { - if (indices.isEmpty()) - return Ints.EMPTY_SET; - else if (valid(indices)) { - final IntSet ret = new IntBitSet(trace.length); - ret.addAll(indices); - for (int i = indices.max(); i >= axioms; i--) { - if (ret.contains(i)) { - int[] resolvent = trace[i]; - if (resolved(i)) { - for (int j = 1, antes = resolvent[0]; j <= antes; j++) { - ret.add(resolvent[j]); - } - } else { - for (int j = 0; j < resolvent.length; j++) { - ret.add(resolvent[j]); - } - } - } - } - return ret; - } else - throw new IndexOutOfBoundsException("invalid indices: " + indices); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#backwardReachable(kodkod.util.ints.IntSet) - */ - @Override - public IntSet backwardReachable(IntSet indices) { - if (indices.isEmpty()) - return Ints.EMPTY_SET; - else if (valid(indices)) { - final IntSet ret = new IntBitSet(trace.length); - ret.addAll(indices); - for (int i = axioms, length = trace.length; i < length; i++) { - int[] resolvent = trace[i]; - if (resolved(i)) { - for (int j = 1, antes = resolvent[0]; j <= antes; j++) { - if (ret.contains(resolvent[j])) { - ret.add(i); - break; - } - } - } else { - for (int j = 0; j < resolvent.length; j++) { - if (ret.contains(resolvent[j])) { - ret.add(i); - break; - } - } - } - } - return ret; - } else - throw new IndexOutOfBoundsException("invalid indices: " + indices); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#learnable(kodkod.util.ints.IntSet) - */ - @Override - public IntSet learnable(IntSet indices) { - if (indices.isEmpty()) - return Ints.EMPTY_SET; - else if (valid(indices)) { - final IntSet ret = new IntBitSet(trace.length); - ret.addAll(indices); - TOP: for (int i = axioms, length = trace.length; i < length; i++) { - int[] resolvent = trace[i]; - if (resolved(i)) { - for (int j = 1, antes = resolvent[0]; j <= antes; j++) { - if (!ret.contains(resolvent[j])) { - continue TOP; - } - } - } else { - for (int j = 0; j < resolvent.length; j++) { - if (!ret.contains(resolvent[j])) { - continue TOP; - } - } - } - ret.add(i); - } - return ret; - } else - throw new IndexOutOfBoundsException("invalid indices: " + indices); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ResolutionTrace#directlyLearnable(kodkod.util.ints.IntSet) - */ - @Override - public IntSet directlyLearnable(IntSet indices) { - if (indices.isEmpty()) - return Ints.EMPTY_SET; - else if (valid(indices)) { - final IntSet ret = new IntBitSet(trace.length); - ret.addAll(indices); - TOP: for (int i = axioms, length = trace.length; i < length; i++) { - int[] resolvent = trace[i]; - if (resolved(i)) { - for (int j = 1, antes = resolvent[0]; j <= antes; j++) { - if (!indices.contains(resolvent[j])) { - continue TOP; - } - } - } else { - for (int j = 0; j < resolvent.length; j++) { - if (!indices.contains(resolvent[j])) { - continue TOP; - } - } - } - ret.add(i); - } - return ret; - } - - else - throw new IndexOutOfBoundsException("invalid indices: " + indices); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder ret = new StringBuilder(); - for (int i = 0; i < axioms; i++) { - ret.append("AXIOM. Literals: "); - int[] clause = trace[i]; - for (int j = 0, c = clause.length; j < c; j++) { - ret.append(clause[j]); - ret.append(" "); - } - ret.append("\n"); - } - for (int i = axioms, max = trace.length; i < max; i++) { - ret.append("RESOLVENT. Antecedents: "); - int[] clause = trace[i]; - if (resolved(i)) { - for (int j = 1, c = clause[0]; j <= c; j++) { - ret.append(clause[j]); - ret.append(" "); - } - } else { - for (int j = 0; j < clause.length; j++) { - ret.append(clause[j]); - ret.append(" "); - } - } - ret.append("\n"); - } - return ret.toString(); - } - - /** - * A mutable implementation of the Clause interface. - * - * @author Emina Torlak - */ - private class ClauseView extends Clause { - - private int[] clause; - private int litOffset, index; - - /** - * Constructs a clause view for the ith clause. - * - * @requires 0 <= index < trace.length - */ - ClauseView(int index) { - this.index = index; - this.clause = trace[index]; - this.litOffset = litOffset(index); - } - - /** - * Constructs a clause view for the 0th clause. - */ - ClauseView() { - this(0); - } - - /** - * Sets the state of this clause view to represent the ith clause in the trace - * and returns this. - * - * @ensures sets the state of this clause view to represent the ith clause in - * the trace - * @return this - */ - ClauseView set(int index) { - this.index = index; - this.clause = trace[index]; - this.litOffset = litOffset(index); - return this; - } - - void ensureLiterals() { - if (litOffset < 0) { - resolve(index); - this.clause = trace[index]; - this.litOffset = litOffset(index); - } - } - - @Override - public int maxVariable() { - ensureLiterals(); - return StrictMath.abs(clause[clause.length - 1]); - } - - @Override - public int numberOfAntecedents() { - return litOffset < 0 ? clause.length : StrictMath.max(0, litOffset - 1); - } - - @Override - public int size() { - ensureLiterals(); - return clause.length - litOffset; - } - - @Override - public Iterator antecedents() { - return new ClauseIterator(new IntArrayIterator(clause, 1, litOffset)); - } - - @Override - public IntIterator literals() { - ensureLiterals(); - return new IntArrayIterator(clause, litOffset, clause.length); - } - - @Override - public int[] toArray(int[] array) { - final int size = size(); - if (array.length < size) { - array = new int[size]; - } - System.arraycopy(clause, litOffset, array, 0, size); - return array; - } - } - - /** - * A clause iterator wrapper for an int iterator. - * - * @author Emina Torlak - */ - private final class ClauseIterator extends ClauseView implements Iterator { - - private final IntIterator itr; - - /** - * Constructs a clause iterator that will iterate over the clauses in this.trace - * located at the indices given by itr. The given iterator must return valid - * indices. - */ - ClauseIterator(IntIterator itr) { - this.itr = itr; - } - - @Override - public boolean hasNext() { - return itr.hasNext(); - } - - @Override - public Clause next() { - return set(itr.next()); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - - /** - * An int iterator that iterates over the portion of an integer array in the - * increasing order of indices. - * - * @author Emina Torlak - */ - private static final class IntArrayIterator implements IntIterator { - - private final int[] array; - private int from; - private final int to; - - /** - * Constructs an int iterator that iterates over the given array, returning the - * elements between from, inclusive, and to, exclusive. - * - * @requires 0 <= from < array.length < Integer.MAX_VALUE - */ - IntArrayIterator(int[] array, int from, int to) { - this.array = array; - this.from = from; - this.to = to; - } - - @Override - public boolean hasNext() { - return from >= 0 && from < to; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - return array[from++]; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Lingeling.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Lingeling.java deleted file mode 100644 index 4a994aa7f..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/Lingeling.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Java wrapper for the Lingeling solver by Armin Biere. - * - * @author Emina Torlak - */ -final class Lingeling extends NativeSolver { - - /** - * Constructs a new Lingeling wrapper. - */ - public Lingeling() { - super(make()); - } - - static { - loadLibrary(Lingeling.class); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "lingeling"; - } - - /** - * Returns a pointer to an instance of Lingeling. - * - * @return a pointer to an instance of minisat. - */ - private static native long make(); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#free(long) - */ - @Override - native void free(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addVariables(long, int) - */ - @Override - native void addVariables(long peer, int numVariables); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addClause(long, int[]) - */ - @Override - native boolean addClause(long peer, int[] lits); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#solve(long) - */ - @Override - native boolean solve(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#valueOf(long, int) - */ - @Override - native boolean valueOf(long peer, int literal); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/MiniSat.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/MiniSat.java deleted file mode 100644 index 214d56dd5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/MiniSat.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Java wrapper for the MiniSat solver by Niklas Eén and Niklas - * Sörensson. - * - * @author Emina Torlak - */ -final class MiniSat extends NativeSolver { - - /** - * Constructs a new MiniSAT wrapper. - */ - public MiniSat() { - super(make()); - } - - static { - loadLibrary(MiniSat.class); - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "MiniSat"; - } - - /** - * Returns a pointer to an instance of MiniSAT. - * - * @return a pointer to an instance of minisat. - */ - private static native long make(); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#free(long) - */ - @Override - native void free(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addVariables(long, int) - */ - @Override - native void addVariables(long peer, int numVariables); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addClause(long, int[]) - */ - @Override - native boolean addClause(long peer, int[] lits); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#solve(long) - */ - @Override - native boolean solve(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#valueOf(long, int) - */ - @Override - native boolean valueOf(long peer, int literal); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/MiniSatProver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/MiniSatProver.java deleted file mode 100644 index 6ba9c3b21..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/MiniSatProver.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.util.Iterator; - -import kodkod.util.ints.IntBitSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; - -/** - * Java wrapper for the MiniSat solver with proof logging. MiniSat is developed - * by Niklas Eén and Niklas Sörensson. - * - * @author Emina Torlak - */ -final class MiniSatProver extends NativeSolver implements SATProver { - - private LazyTrace proof; - - /** - * Constructs a new MiniSat prover wrapper. - */ - MiniSatProver() { - super(make()); - proof = null; - } - - static { - loadLibrary(MiniSatProver.class); - } - - /** - * Returns a subset of the given trivial trace that consists only of axioms. A - * trace is trivial iff its last clause is an empty clause. This means that the - * empty axiom was added to the solver via {@linkplain #addClause(int[])}, so no - * resolution was necessary to reach the conflict. The empty axiom is always the - * last clause in the trace. - * - * @requires trace[trace.length].length = 0 - * @return a subset of the given trivial trace that consists only of axioms - */ - private int[][] formatTrivial(int[][] trace) { - final int length = trace.length; - final int empty = length - 1; - final IntSet axioms = new IntBitSet(length); - axioms.add(empty); - final int numVars = numberOfVariables(); - for (int i = 0; i < empty; i++) { - int[] clause = trace[i]; - if (clause[0] <= numVars) { - axioms.add(i); - } - } - if (axioms.size() == length) { - return trace; - } - final int[][] axiomClauses = new int[axioms.size()][]; - final IntIterator itr = axioms.iterator(); - for (int i = 0; itr.hasNext(); i++) { - axiomClauses[i] = trace[itr.next()]; - } - return axiomClauses; - } - - /** - * Modifies the given raw trace so that it conforms to the specification of - * {@linkplain LazyTrace#LazyTrace(int[][], int)}, if the array contains no null - * entries, and to the specfication of - * {@linkplain LazyTrace#LazyTrace(LazyTrace, IntSet, int[][])} otherwise. - * - * @ensures modifies the trace so that it conforms to the specification of one - * of the LazyTrace constructors. - * @return trace - */ - private int[][] format(int[][] trace) { - final int length = trace.length; - final IntSet resolvents = new IntBitSet(length); - final int offset = numberOfVariables() + 1; - for (int i = 0; i < length; i++) { - int[] clause = trace[i]; - if (clause != null && clause[0] >= offset) { - clause[0] -= offset; - resolvents.add(i); - } - } - - final int axioms = length - resolvents.size(); - if (resolvents.min() < axioms) { - final int[] position = new int[length]; - for (int i = 0, axiomIndex = 0, resolventIndex = axioms; i < length; i++) { - if (resolvents.contains(i)) { - position[i] = resolventIndex++; - int[] resolvent = trace[i]; - for (int j = 0, resLength = resolvent.length; j < resLength; j++) { - resolvent[j] = position[resolvent[j]]; - } - } else { - position[i] = axiomIndex++; - } - } - - for (IntIterator itr = resolvents.iterator(length, 0); itr.hasNext();) { - int i = itr.next(); - int pos = position[i]; - if (i == pos) - continue; // correctly positioned, do nothing - int[] resolvent = trace[i]; - System.arraycopy(trace, i + 1, trace, i, pos - i); - trace[pos] = resolvent; - } - } - assert axioms == numberOfClauses(); - return trace; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATProver#proof() - */ - @Override - public ResolutionTrace proof() { - if (!Boolean.FALSE.equals(status())) - throw new IllegalStateException(); - if (proof == null) { - final int[][] trace = trace(peer(), true); - free(); - // if the empty axiom was added to the solver, that axiom will be - // the last clause in the trace, and it will form its own minimal - // unsat core. - // System.out.println(Arrays.deepToString(trace)); - if (trace[trace.length - 1].length == 0) { - proof = new LazyTrace(formatTrivial(trace), numberOfClauses()); - } else { - proof = new LazyTrace(format(trace), numberOfClauses()); - } - } - return proof; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATProver#reduce(kodkod.engine.satlab.ReductionStrategy) - */ - @Override - public void reduce(ReductionStrategy strategy) { - proof(); - if (proof.resolvents().isEmpty()) { - return; // nothing to minimize; we had an empty axiom added to the - // solver's database - } - - for (IntSet next = strategy.next(proof); !next.isEmpty(); next = strategy.next(proof)) { - long prover = make(); - addVariables(prover, numberOfVariables()); - - for (Iterator itr = proof.iterator(next); itr.hasNext();) { - Clause c = itr.next(); - if (!addClause(prover, c.toArray())) { - throw new AssertionError("could not add non-redundant clause: " + c); - } - } - - if (!solve(prover)) { - adjustClauseCount(next.size()); - int[][] trace = trace(prover, false); - free(prover); - proof = new LazyTrace(proof, next, format(trace)); - } else { - free(prover); - } - } - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "MiniSatProver"; - } - - /** - * Returns a pointer to an instance of MiniSAT. - * - * @return a pointer to an instance of minisat. - */ - private static native long make(); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#free(long) - */ - @Override - native void free(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addVariables(long, int) - */ - @Override - native void addVariables(long peer, int numVariables); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#addClause(long, int[]) - */ - @Override - native boolean addClause(long peer, int[] lits); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#solve(long) - */ - @Override - native boolean solve(long peer); - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.NativeSolver#valueOf(long, int) - */ - @Override - native boolean valueOf(long peer, int literal); - - /** - * Returns an array of arrays that encodes the most recently generated - * resolution trace. The resolution trace is encoded as follows. Let R be the - * returned array. For all 0 <= i < trace.length such that R[i][0] > - * this.numberOfVariables(), the array R[i] encodes a resolvent clause. In - * particular, (R[i][0] - this.numberOfVariables() - 1) < i is the index of the - * 0th antecedent of R[i] in R; for each 0 < j < R[i].length, R[i][j] < i and - * R[i][j] is the index of the jth antecedent of R[i] in R. For all 0 <= i < - * trace.length-1 such that R[i][0] <= this.numberOfVariables(), R[i] contains - * the literals of the ith axiom, sorted in the increasing order of absolute - * values, if recordAxioms is true; otherwise R[i] is null. - * - * @return an array of arrays that encodes the most recently generated - * resolution trace - */ - native int[][] trace(long peer, boolean recordAxioms); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/NativeSolver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/NativeSolver.java deleted file mode 100644 index f02ed490d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/NativeSolver.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.io.File; - -import org.alloytools.nativecode.util.NativeCode; - -/** - * A skeleton implementation of a wrapper for a sat solver accessed through JNI. - * - * @author Emina Torlak - */ -abstract class NativeSolver implements SATSolver { - - /** - * The memory address of the native instance wrapped by this wrapper. - */ - private long peer; - private Boolean sat; - private int clauses, vars; - - /** - * Constructs a new wrapper for the given instance of the native solver. - */ - NativeSolver(long peer) { - this.peer = peer; - this.clauses = this.vars = 0; - this.sat = null; - // System.out.println("created " + peer); - } - - /** - * Loads the JNI library for the given class. It first attempts to load the - * library named library.getSimpleName().toLowerCase(). If that fails, it - * attempts to load library.getSimpleName().toLowerCase()+suffix where suffix - * ranges over the path-separator delimited list obtained by calling - * System.getProperty("kodkod." + library.getSimpleName().toLowerCase()). - */ - static void loadLibrary(Class< ? extends NativeSolver> library) { - final String name = library.getSimpleName().toLowerCase(); - try { - System.loadLibrary(name); - } catch (UnsatisfiedLinkError e) { - final String versions = System.getProperty("kodkod." + name); - if (versions != null) { - for (String suffix : versions.split(File.pathSeparator)) { - try { - System.loadLibrary(name + suffix); - return; - } catch (UnsatisfiedLinkError e1) {} - } - } - - if (NativeCode.loadlibrary(null, name)) - return; - - throw new UnsatisfiedLinkError("Could not load the library " + System.mapLibraryName(name) + " or any of its variants:" + e.getMessage()); - } - - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#numberOfVariables() - */ - @Override - public final int numberOfVariables() { - return vars; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#numberOfClauses() - */ - @Override - public final int numberOfClauses() { - return clauses; - } - - /** - * Adjusts the internal clause count so that the next call to - * {@linkplain #numberOfClauses()} will return the given value. - * - * @requires clauseCount >= 0 - * @ensures adjusts the internal clause so that the next call to - * {@linkplain #numberOfClauses()} will return the given value. - */ - final void adjustClauseCount(int clauseCount) { - assert clauseCount >= 0; - clauses = clauseCount; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#addVariables(int) - * @see #addVariables(long, int) - */ - @Override - public final void addVariables(int numVars) { - if (numVars < 0) - throw new IllegalArgumentException("vars < 0: " + numVars); - else if (numVars > 0) { - vars += numVars; - addVariables(peer, numVars); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#addClause(int[]) - * @see #addClause(long, int[]) - */ - @Override - public final boolean addClause(int[] lits) { - if (addClause(peer, lits)) { - // for(int i : lits) { - // System.out.print(i + " "); - // } - // System.out.println(0); - clauses++; - return true; - } - return false; - } - - /** - * Returns a pointer to the C++ peer class (the native instance wrapped by this - * object). - * - * @return a pointer to the C++ peer class (the native instance wrapped by this - * object). - */ - final long peer() { - return peer; - } - - /** - * Returns the current sat of the solver. - * - * @return null if the sat is unknown, TRUE if the last call to solve() yielded - * SAT, and FALSE if the last call to solve() yielded UNSAT. - */ - final Boolean status() { - return sat; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#solve() - * @see #solve(long) - */ - @Override - public final boolean solve() { - if (sat == Boolean.FALSE) - return sat; - else - return (sat = Boolean.valueOf(solve(peer))); - } - - /** - * Throws an IllegalArgumentException if variable !in this.variables. Otherwise - * does nothing. - * - * @throws IllegalArgumentException variable !in this.variables - */ - final void validateVariable(int variable) { - if (variable < 1 || variable > vars) - throw new IllegalArgumentException(variable + " !in [1.." + vars + "]"); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#valueOf(int) - */ - @Override - public final boolean valueOf(int variable) { - if (sat != Boolean.TRUE) - throw new IllegalStateException(); - validateVariable(variable); - return valueOf(peer, variable); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#free() - */ - @Override - public synchronized final void free() { - if (peer != 0) { - // System.out.println("freeing " + peer + " " + getClass()); - free(peer); - sat = Boolean.FALSE; - peer = 0; - } // already freed - } - - /** - * Releases the resources used by this native solver. - */ - @Override - protected final void finalize() throws Throwable { - super.finalize(); - free(); - } - - /** - * Releases the resources associated with the native solver at the given memory - * address. This method must be called when the object holding the given - * reference goes out of scope to avoid memory leaks. - * - * @ensures releases the resources associated with the given native peer - */ - abstract void free(long peer); - - /** - * Adds the specified number of variables to the given native peer. - * - * @ensures increases the vocabulary of the given native peer by the specified - * number of variables - */ - abstract void addVariables(long peer, int numVariables); - - /** - * Ensures that the given native peer logically contains the specified clause - * and returns true if the solver's clause database changed as a result of the - * call. - * - * @requires all i: [0..lits.length) | abs(lits[i]) in this.variables - * @requires all disj i,j: [0..lits.length) | abs(lits[i]) != abs(lits[j]) - * @ensures ensures that the given native peer logically contains the specified - * clause - * @return true if the peer's clause database changed as a result of the call; a - * negative integer if not. - */ - abstract boolean addClause(long peer, int[] lits); - - /** - * Calls the solve method on the given native peer. - * - * @return true if the clauses in the solver are SAT; otherwise returns false. - */ - abstract boolean solve(long peer); - - /** - * Returns the assignment for the given literal by the specified native peer - * - * @requires the last call to {@link #solve(long) solve(peer)} returned - * SATISFIABLE - * @return the assignment for the given literal - */ - abstract boolean valueOf(long peer, int literal); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ReductionStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ReductionStrategy.java deleted file mode 100644 index 81743fd77..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ReductionStrategy.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import kodkod.util.ints.IntSet; - -/** - * Strategy for reducing the unsatisfiable core of a {@link SATProver}. - * - * @specfield traces: ResolutionTrace[] - * @specfield nexts: IntSet[] - * @invariant #traces = #nexts - * @invariant no disj i,j: [0..#nexts) | traces[i] = traces[j] && nexts[i] = - * nexts[j] - * @see SATProver#reduce(ReductionStrategy) - * @author Emina Torlak - */ -public interface ReductionStrategy { - - /** - * Returns the next subtrace of the specified trace to be analyzed, given as a - * set of indices into the trace. If there are no more subtraces to be analyzed - * (i.e. the given trace is minimal according to the minimality measure used by - * this strategy), returns the empty set. - * - * @requires - * - *
-     * let t = this.traces[#this.traces-1], n = this.nexts[#this.nexts-1] |
-     *  unsat(t.elts[n].literals) =>
-     *   (all i: n.ints | let j = #{k: n.ints | k < i} | t.elts[i].equals(trace.elts[j]))
-     *  else
-     *   trace = t
-     *           
- * - * @ensures - * - *
-     *
-     *  let next = { i: int | 0 <= i < trace.size()-1 } |
-     *   trace.elts[next].antecedents in trace.elts[next] and
-     *   (some i: [0..#trace) | i !in next and no trace[i].antecedents) and
-     *   this.nexts' = this.nexts + #this.nexts->next and
-     *   this.traces' = this.traces + #this.traces->trace
-     *          
- * - * @return this.nexts'[#this.nexts-1] - */ - public IntSet next(ResolutionTrace trace); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ResolutionTrace.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ResolutionTrace.java deleted file mode 100644 index ce93502cd..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/ResolutionTrace.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.util.Iterator; - -import kodkod.util.ints.IntSet; - -/** - *

- * A proof of unsatisfiability generated by a {@linkplain SATProver}. Formally, - * a resolution trace is a sequence of inferences made by a prover that ends in - * a conflict (empty clause). An element in a resolution trace is called a - * clause. There are two kinds of clauses in the trace: axioms and resolvents. - * Axioms are the clauses given to the prover via the - * {@linkplain SATSolver#addClause(int[])} method, and resolvents are the - * clauses derived by the prover from axioms or previously learned resolvents - * through resolution. - *

- *

- * Clauses in a resolution trace are ordered as follows. The first |A| - * elements in the trace correspond to the axioms given to the prover (i.e. - * prover.clauses). An axiom a1 precedes an axiom a2 in the trace - * if and only if a1 was added to the prover before a2. (An axiom - * is "added" to the prover, and appears in the trace, if and only if the - * corresponding call to {@linkplain SATSolver#addClause(int[])}) returned - * true.) The remaining elements in the trace are the resolvents. A - * resolvent r succeeds all of the resolvents needed for its derivation - * (i.e. all resolvents reachable from r via the - * {@linkplain Clause#antecedents()} relation). The last element in the trace is - * the conflict resolvent. The axioms that are reachable from the conflict form - * the unsatisfiable core of the trace. - *

- * - * @specfield prover: SATProver - * @specfield elts: Clause[] - * @specfield conflict: elts[#elts-1] - * @invariant #elts = #(prover.clauses + prover.resolvents) - * @invariant elts[[0..#prover.clauses)].literals = prover.clauses - * @invariant elts[[#prover.clauses..#elts)].literals = prover.resolvents - * @invariant all i: [0..#prover.clauses) | no elts[i].antecedents - * @invariant all i: [#prover.clauses..#elts) | all ante: - * elts[i].antecedents[int] | elts.ante < i - * @invariant no conflict.literals - * @author Emina Torlak - */ -public interface ResolutionTrace extends Iterable { - - /** - * Returns the length of this trace. - * - * @return #this.elts - */ - public int size(); - - /** - * Returns an iterator over the elements in this trace in proper sequence. - *

- * Note:The clause objects returned by the iterator are not required to - * be immutable. In particular, the state of a clause object returned by - * next() (as well as the state of any object obtained through that - * clause's {@linkplain Clause#antecedents()} method) is guaranteed to remain - * the same only until the subsequent call to the next() method of the - * iterator instance. - *

- * - * @return an iterator over the elements in this trace in proper sequence. - */ - @Override - public abstract Iterator iterator(); - - /** - * Returns an iterator over the elements at the given indices in this trace, in - * proper sequence. - *

- * Note:The clause objects returned by the iterator are not required to - * be immutable. In particular, the state of a clause object returned by - * next() (as well as the state of any object obtained through that - * clause's {@linkplain Clause#antecedents()} method) is guaranteed to remain - * the same only until the subsequent call to the next() method of the - * iterator instance. - *

- * - * @requires indices.min() >= 0 && indices.max() < this.size() - * @return an iterator over the elements at the given indices in this trace, in - * proper sequence. - * @throws IndexOutOfBoundsException indices.min() < 0 || indices.max() >= - * this.size() - */ - public abstract Iterator iterator(IntSet indices); - - /** - * Returns an iterator over the elements at the given indices in this trace, in - * the reverse order of indices. - *

- * Note:The clause objects returned by the iterator are not required to - * be immutable. In particular, the state of a clause object returned by - * next() (as well as the state of any object obtained through that - * clause's {@linkplain Clause#antecedents()} method) is guaranteed to remain - * the same only until the subsequent call to the next() method of the - * iterator instance. - *

- * - * @requires indices.min() >= 0 && indices.max() < this.size() - * @return an iterator over the elements at the given indices in this trace, in - * the reverse order of indices. - * @throws IndexOutOfBoundsException indices.min() < 0 || indices.max() >= - * this.size() - */ - public abstract Iterator reverseIterator(IntSet indices); - - /** - * Returns the indices of the axioms that form the unsatisfiable core of this - * trace. - * - * @return { i: int | no this.elts[i].antecedents and this.elts[i] in - * this.conflict.^antecedents } - */ - public abstract IntSet core(); - - /** - * Returns the indices of the axioms in this trace. - * - * @return { i: int | this.elts[i] in this.prover.clauses } - */ - public abstract IntSet axioms(); - - /** - * Returns the indices of the resolvents in this trace. - * - * @return { i: int | this.elts[i] in this.prover.resolvents } - */ - public abstract IntSet resolvents(); - - /** - * Returns the indices of all clauses reachable from the clauses at the given - * indices by following the antecedent relation zero or more times. - * - * @requires indices.min() >= 0 && indices.max() < this.size() - * @return { i: int | this.elts[i] in this.elts[indices].*antecedents } - * @throws IllegalArgumentException indices.min() < 0 || indices.max() >= - * this.size() - */ - public abstract IntSet reachable(IntSet indices); - - /** - * Returns the indices of all clauses reachable from the clauses at the given - * indices by following the transpose of the antecedent relation zero or more - * times. - * - * @requires indices.min() >= 0 && indices.max() < this.size() - * @return { i: int | this.elts[i] in this.elts[indices].*~antecedents } - * @throws IllegalArgumentException indices.min() < 0 || indices.max() >= - * this.size() - */ - public abstract IntSet backwardReachable(IntSet indices); - - /** - * Returns the indices of all clauses in this trace that can be learned solely - * from the clauses with the given indices. - * - * @requires indices.min() >= 0 && indices.max() < this.size() - * @return { i: int | this.elts[i].*antecedents = - * this.elts[indices].*antecedents + this.elts[i].*antecedents & - * this.elts[indices].*~antecedents } - * @throws IllegalArgumentException indices.min() < 0 || indices.max() >= - * this.size() - */ - public abstract IntSet learnable(IntSet indices); - - /** - * Returns the indices of all clauses in this trace that can be learned solely - * and directly from the clauses with the given indices. - * - * @requires indices.min() >= 0 && indices.max() < this.size() - * @return { i: int | this.elts[i].antecedents in this.elts[indices] } - * @throws IllegalArgumentException indices.min() < 0 || indices.max() >= - * this.size() - */ - public abstract IntSet directlyLearnable(IntSet indices); - - /** - * Returns the clause at the given index. Note that this method is not required - * to always return the same Clause object; it is only required to return Clause - * objects that are equal according to their equals methods. The Clause - * objects returned by this method are guaranteed to be immutable. - * - * @requires 0 <= index < this.size() - * @return this.elts[index] - * @throws IndexOutOfBoundsException 0 < index || index >= this.size() - */ - public abstract Clause get(int index); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SAT4J.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SAT4J.java deleted file mode 100644 index 20ee0bd24..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SAT4J.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.util.NoSuchElementException; - -import org.sat4j.specs.ContradictionException; -import org.sat4j.specs.ISolver; -import org.sat4j.specs.IVecInt; -import org.sat4j.specs.IteratorInt; - -/** - * A wrapper class that provides access to the basic funcionality of the MiniSAT - * solvers (org.sat4j.specs.ISolver) from CRIL. - * - * @author Emina Torlak - */ -final class SAT4J implements SATSolver { - - private ISolver solver; - private final ReadOnlyIVecInt wrapper; - private Boolean sat; - private int vars, clauses; - - /** - * Constructs a wrapper for the given instance of ISolver. - * - * @throws NullPointerException solver = null - */ - SAT4J(ISolver solver) { - if (solver == null) - throw new NullPointerException("solver"); - this.solver = solver; - this.wrapper = new ReadOnlyIVecInt(); - this.sat = null; - this.vars = this.clauses = 0; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#numberOfVariables() - */ - @Override - public int numberOfVariables() { - return vars; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#numberOfClauses() - */ - @Override - public int numberOfClauses() { - return clauses; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#addVariables(int) - */ - @Override - public void addVariables(int numVars) { - if (numVars < 0) - throw new IllegalArgumentException("numVars < 0: " + numVars); - else if (numVars > 0) { - vars += numVars; - solver.newVar(vars); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#addClause(int[]) - */ - @Override - public boolean addClause(int[] lits) { - try { - if (!Boolean.FALSE.equals(sat)) { - clauses++; - solver.addClause(wrapper.wrap(lits)); - // for(int lit : lits) { - // System.out.print(lit + " "); - // } - // System.out.println(0); - return true; - } - - } catch (ContradictionException e) { - sat = Boolean.FALSE; - } - return false; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#solve() - */ - @Override - public boolean solve() { - try { - if (solver == null) - return false; - if (!Boolean.FALSE.equals(sat)) - sat = Boolean.valueOf(solver.isSatisfiable()); - return sat; - } catch (org.sat4j.specs.TimeoutException e) { - throw new RuntimeException("timed out"); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#valueOf(int) - */ - @Override - public final boolean valueOf(int variable) { - if (!Boolean.TRUE.equals(sat)) - throw new IllegalStateException(); - if (variable < 1 || variable > vars) - throw new IllegalArgumentException(variable + " !in [1.." + vars + "]"); - return solver.model(variable); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.SATSolver#free() - */ - @Override - public synchronized final void free() { - sat = Boolean.FALSE; - solver = null; - } - - /** - * A wrapper for an int array that provides read-only access to the array via - * the IVecInt interface. - * - * @author Emina Torlak - */ - private static final class ReadOnlyIVecInt implements IVecInt { - - private static final long serialVersionUID = -7689441271777278043L; - private int[] vec; - - /** - * Sets this.vec to the given vector and returns this. - */ - IVecInt wrap(int[] vec) { - this.vec = vec; - return this; - } - - @Override - public int size() { - return vec.length; - } - - @Override - public boolean isEmpty() { - return size() == 0; - } - - @Override - public int unsafeGet(int arg0) { - return vec[arg0]; - } - - @Override - public int last() { - return vec[vec.length - 1]; - } - - @Override - public int[] toArray() { - return vec; - } - - @Override - public int get(int arg0) { - if (arg0 < 0 || arg0 >= vec.length) - throw new IndexOutOfBoundsException("arg0: " + arg0); - return vec[arg0]; - } - - @Override - public boolean contains(int arg0) { - final int[] workArray = vec; // faster access - for (int i : workArray) { - if (i == arg0) - return true; - } - return false; - } - - @Override - public void copyTo(IVecInt arg0) { - int argLength = arg0.size(); - final int[] workArray = vec; // faster access - arg0.ensure(argLength + workArray.length); - for (int i : workArray) { - arg0.set(argLength++, i); - } - } - - @Override - public void copyTo(int[] arg0) { - assert arg0.length >= vec.length; - System.arraycopy(vec, 0, arg0, 0, vec.length); - } - - @Override - public IteratorInt iterator() { - return new IteratorInt() { - - int cursor = 0; - - @Override - public boolean hasNext() { - return cursor < vec.length; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - return vec[cursor++]; - } - }; - } - - @Override - public int containsAt(int e) { - final int[] workArray = vec; // faster access - for (int n = workArray.length, i = 0; i < n; i++) - if (workArray[i] == e) - return i; - return -1; - } - - @Override - public int containsAt(int e, int from) { - final int[] workArray = vec; // faster access - if (from < workArray.length) - for (int n = workArray.length, i = from + 1; i < n; i++) - if (workArray[i] == e) - return i; - return -1; - } - - @Override - public int indexOf(int e) { - final int[] workArray = vec; // faster access - for (int i = 0, n = workArray.length; i < n; i++) { - if (workArray[i] == e) - return i; - } - return -1; - } - - // unsupported - @Override - public void shrink(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void shrinkTo(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public IVecInt pop() { - throw new UnsupportedOperationException(); - } - - @Override - public void growTo(int arg0, int arg1) { - throw new UnsupportedOperationException(); - } - - @Override - public void ensure(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public IVecInt push(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void unsafePush(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(); - } - - @Override - public void moveTo(IVecInt arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void moveTo2(IVecInt arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void moveTo(int[] arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void moveTo(int arg0, int arg1) { - throw new UnsupportedOperationException(); - } - - @Override - public void moveTo(int i, int[] arg1) { - throw new UnsupportedOperationException(); - } - - @Override - public void insertFirst(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void remove(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public int delete(int arg0) { - throw new UnsupportedOperationException(); - } - - @Override - public void set(int arg0, int arg1) { - throw new UnsupportedOperationException(); - } - - @Override - public void sort() { - throw new UnsupportedOperationException(); - } - - @Override - public void sortUnique() { - throw new UnsupportedOperationException(); - } - - @Override - public IVecInt[] subset(int arg0) { - throw new UnsupportedOperationException(); - } - } - - public static void main(String[] args) { - final SAT4J z = (SAT4J) SATFactory.DefaultSAT4J.instance(); - // z.addVariables(3); - // int[] clause = {1,2,3}; - // z.addClause(clause); - // int[] clause1 = {-3}; - // z.addClause(clause1); - // System.out.println(z.solver.nVars()); - // z.addVariables(4); - // System.out.println(z.solver.nVars()); - // clause1[0] = 7; - // z.addClause(clause1); - z.addVariables(1); - int[] clause1 = { - 1 - }; - z.addClause(clause1); - clause1[0] = -1; - z.addClause(clause1); - - System.out.println(z.solve()); - // System.out.println(z.variablesThatAre(true, 1, 1)); - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATAbortedException.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATAbortedException.java deleted file mode 100644 index 98edde17c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATAbortedException.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * A runtime exception thrown when a sat solver terminates abnormally, usually - * because it was cancelled. - * - * @author Emina Torlak - */ -public final class SATAbortedException extends RuntimeException { - - private static final long serialVersionUID = 5162235133382021308L; - - /** - * Constructs an aborted exception with no message. - */ - SATAbortedException() {} - - /** - * Constructs an aborted exception with the given message. - */ - SATAbortedException(String message) { - super(message); - } - - /** - * Constructs an aborted exception with the given cause. - */ - SATAbortedException(Throwable cause) { - super(cause); - } - - /** - * Constructs an aborted exception with the given message and cause. - */ - SATAbortedException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATFactory.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATFactory.java deleted file mode 100644 index 2fac56c87..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATFactory.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.sat4j.minisat.SolverFactory; - -/** - * A factory for generating SATSolver instances of a given type. Built-in - * support is provided for SAT4J solvers, - * the zchaff solver - * from Princeton, and the MiniSat - * solver by Niklas Eén and Niklas Sörensson. - * - * @author Emina Torlak - */ -public abstract class SATFactory { - - /** - * Constructs a new instance of SATFactory. - */ - protected SATFactory() {} - - /** - * Returns true iff the given factory generates solvers that are available for - * use on this system. - * - * @return true iff the given factory generates solvers that are available for - * use on this system. - */ - public static final boolean available(SATFactory factory) { - SATSolver solver = null; - try { - solver = factory.instance(); - solver.addVariables(1); - solver.addClause(new int[] { - 1 - }); - return solver.solve(); - } catch (RuntimeException e) { - return false; - } catch (UnsatisfiedLinkError t) { - return false; - } finally { - if (solver != null) { - solver.free(); - } - } - } - - /** - * The factory that produces instances of the default sat4j solver. - * - * @see org.sat4j.core.ASolverFactory#defaultSolver() - */ - public static final SATFactory DefaultSAT4J = new SATFactory() { - - @Override - public SATSolver instance() { - return new SAT4J(SolverFactory.instance().defaultSolver()); - } - - @Override - public String toString() { - return "DefaultSAT4J"; - } - }; - - /** - * The factory that produces instances of the "light" sat4j solver. The light - * solver is suitable for solving many small instances of SAT problems. - * - * @see org.sat4j.core.ASolverFactory#lightSolver() - */ - public static final SATFactory LightSAT4J = new SATFactory() { - - @Override - public SATSolver instance() { - return new SAT4J(SolverFactory.instance().lightSolver()); - } - - @Override - public String toString() { - return "LightSAT4J"; - } - }; - - /** - * The factory that produces instances of Niklas Eén and Niklas - * Sörensson's MiniSat solver. - */ - public static final SATFactory MiniSat = new SATFactory() { - - @Override - public SATSolver instance() { - return new MiniSat(); - } - - @Override - public String toString() { - return "MiniSat"; - } - }; - - /** - * The factory the produces {@link SATProver proof logging} instances of the - * MiniSat solver. Note that core extraction can incur a significant time - * overhead during solving, so if you do not need this functionality, use the - * {@link #MiniSat} factory instead. - */ - public static final SATFactory MiniSatProver = new SATFactory() { - - @Override - public SATSolver instance() { - return new MiniSatProver(); - } - - @Override - public boolean prover() { - return true; - } - - @Override - public String toString() { - return "MiniSatProver"; - } - }; - - /** - * The factory that produces instances of G. Audemard and L. Simon's Glucose - * solver. - */ - public static final SATFactory Glucose = new SATFactory() { - - @Override - public SATSolver instance() { - return new Glucose(); - } - - @Override - public String toString() { - return "Glucose"; - } - }; - - /** - * The factory that produces instances of G. Audemard and L. Simon's Glucose - * solver. - */ - public static final SATFactory Glucose41 = new SATFactory() { - - @Override - public SATSolver instance() { - return new Glucose41(); - } - - @Override - public String toString() { - return "Glucose41"; - } - }; - - /** - * The factory that produces instances of the CryptoMiniSat solver by Mate Soos. - */ - public static final SATFactory CryptoMiniSat = new SATFactory() { - - @Override - public SATSolver instance() { - return new CryptoMiniSat(); - } - - @Override - public String toString() { - return "CryptoMiniSat"; - } - }; - - /** - * The factory that produces instances of Armin Biere's Lingeling solver. - */ - public static final SATFactory Lingeling = new SATFactory() { - - @Override - public SATSolver instance() { - return new Lingeling(); - } - - @Override - public boolean incremental() { - return false; - } - - @Override - public String toString() { - return "Lingeling"; - } - }; - - /** - * Returns a SATFactory that produces SATSolver wrappers for Armin Biere's - * Plingeling solver. This is a parallel solver that is invoked as an external - * program rather than via the Java Native Interface. As a result, it cannot be - * used incrementally. Its external factory manages the creation and deletion of - * temporary files automatically. A statically compiled version of plingeling is - * assumed to be available in a java.library.path directory. The effect of this - * method is the same as calling {@link #plingeling(Integer, Boolean) - * plingeling(null, null)}. - * - * @return SATFactory that produces SATSolver wrappers for the Plingeling solver - */ - public static final SATFactory plingeling() { - return plingeling(null, null); - } - - /** - * Returns a SATFactory that produces SATSolver wrappers for Armin Biere's - * Plingeling solver. This is a parallel solver that is invoked as an external - * program rather than via the Java Native Interface. As a result, it cannot be - * used incrementally. Its external factory manages the creation and deletion of - * temporary files automatically. A statically compiled version of plingeling is - * assumed to be available in a java.library.path directory. - *

- * Plingling takes as input two optional parameters: {@code threads}, specifying - * how many worker threads to use, and {@code portfolio}, specifying whether the - * threads should run in portfolio mode (no sharing of clauses) or sharing mode. - * If {@code threads} is null, the solver uses one worker per core. If - * {@code portfolio} is null, it is set to true by default. - *

- * - * @requires threads != null => numberOfThreads > 0 - * @return SATFactory that produces SATSolver wrappers for the Plingeling solver - */ - public static final SATFactory plingeling(Integer threads, Boolean portfolio) { - - final List opts = new ArrayList(3); - if (threads != null) { - if (threads < 1) - throw new IllegalArgumentException("Number of threads must be at least 1: numberOfThreads=" + threads); - opts.add("-t"); - opts.add(threads.toString()); - } - if (portfolio != null && portfolio) - opts.add("-p"); - - final String executable = findStaticLibrary("plingeling"); - return externalFactory(executable == null ? "plingeling" : executable, null, opts.toArray(new String[opts.size()])); - - } - - /** - * Searches the {@code java.library.path} for an executable with the given name. - * Returns a fully qualified path to the first found executable. Otherwise - * returns null. - * - * @return a fully qualified path to an executable with the given name, or null - * if no executable is found. - */ - private static String findStaticLibrary(String name) { - final String[] dirs = System.getProperty("java.library.path").split(System.getProperty("path.separator")); - - for (int i = dirs.length - 1; i >= 0; i--) { - final File file = new File(dirs[i] + File.separator + name); - if (file.canExecute()) - return file.getAbsolutePath(); - } - - return null; - } - - /** - * Returns a SATFactory that produces instances of the specified SAT4J solver. - * For the list of available SAT4J solvers see - * {@link org.sat4j.core.ASolverFactory#solverNames() - * org.sat4j.core.ASolverFactory#solverNames()}. - * - * @requires solverName is a valid solver name - * @return a SATFactory that returns the instances of the specified SAT4J solver - * @see org.sat4j.core.ASolverFactory#solverNames() - */ - public static final SATFactory sat4jFactory(final String solverName) { - return new SATFactory() { - - @Override - public SATSolver instance() { - return new SAT4J(SolverFactory.instance().createSolverByName(solverName)); - } - - @Override - public String toString() { - return solverName; - } - }; - } - - /** - * Returns a SATFactory that produces SATSolver wrappers for the external SAT - * solver specified by the executable parameter. The solver's input and output - * formats must conform to the - * SAT competition - * standards. The solver will be called with the specified options, and it - * is expected to write properly formatted output to standard out. If the - * {@code cnf} string is non-null, it will be used as the file name for - * generated CNF files by all solver instances that the factory generates. If - * {@code cnf} null, each solver instance will use an automatically generated - * temporary file, which will be deleted when the solver instance is - * garbage-collected. The {@code cnf} file, if provided, is not automatically - * deleted; it is the caller's responsibility to delete it when no longer - * needed. External solvers are never incremental. - * - * @return SATFactory that produces SATSolver wrappers for the specified - * external SAT solver - */ - public static final SATFactory externalFactory(final String executable, final String cnf, final String... options) { - return new SATFactory() { - - @Override - public SATSolver instance() { - if (cnf != null) { - return new ExternalSolver(executable, cnf, false, options); - } else { - try { - return new ExternalSolver(executable, File.createTempFile("kodkod", String.valueOf(executable.hashCode())).getAbsolutePath(), true, options); - } catch (IOException e) { - throw new SATAbortedException("Could not create a temporary file.", e); - } - } - } - - @Override - public boolean incremental() { - return false; - } - - @Override - public String toString() { - return (new File(executable)).getName(); - } - }; - } - - /** - * Returns an instance of a SATSolver produced by this factory. - * - * @return a SATSolver instance - */ - public abstract SATSolver instance(); - - /** - * Returns true if the solvers returned by this.instance() are {@link SATProver - * SATProvers}. Otherwise returns false. - * - * @return true if the solvers returned by this.instance() are {@link SATProver - * SATProvers}. Otherwise returns false. - */ - public boolean prover() { - return false; - } - - /** - * Returns true if the solvers returned by this.instance() are incremental; i.e. - * if clauses/variables can be added to the solver between multiple calls to - * solve(). - * - * @return true if the solvers returned by this.instance() are incremental - */ - public boolean incremental() { - return true; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATProver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATProver.java deleted file mode 100644 index 341582165..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATProver.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Provides an interface to a SAT solver that can generate proofs of - * unsatisfiability. - * - * @specfield variables: set [1..) - * @specfield clauses: set Clause - * @specfield resolvents: set Clause - * @invariant all i: [2..) | i in variables => i-1 in variables - * @invariant all c: clauses + resolvents | all lit: c.lits | lit in variables - * || -lit in variables - * @invariant all c: clauses + resolvents | all disj i,j: c.lits | abs(i) != - * abs(j) - * @author Emina Torlak - */ -public interface SATProver extends SATSolver { - - /** - * Returns a resolution-based proof of unsatisfiability of this.clauses. - * - * @requires {@link SATSolver#solve()} has been called, and it returned false - * @return { t: ResolutionTrace | t.prover = this } - * @throws IllegalStateException {@link SATSolver#solve()} has not been called, - * or the last call to {@link SATSolver#solve()} returned true - */ - public ResolutionTrace proof(); - - /** - * Uses the given reduction strategy to remove irrelevant clauses from the set - * of unsatisfiable clauses stored in this prover. A clause c is irrelevant iff - * this.clauses - c is unsatisfiable. The removal algorithm works as follows: - * - *
-     * for (IntSet next = strategy.next(this.proof()); !next.isEmpty(); next = strategy.next(this.proof())) {
-     *  let oldClauses = this.clauses, oldResolvents = this.resolvents
-     *  clear this.clauses
-     *  clear this.resolvents
-     *  for(Clause c : this.proof().elts[next]) {
-     *    if (no c.antecedents)
-     *      add c to this.clauses
-     *    else
-     *      add c to this.resolvents
-     *  }
-     *  if (this.solve()) {
-     *   this.clauses = oldClauses
-     *   this.resolvents = oldResolvents
-     *  }
-     * }
-     * 
- * - * @requires {@link SATSolver#solve()} has been called, and it returned false - * @ensures modifies this.clauses and this.resolvents according to the algorithm - * described above - * @throws IllegalStateException {@link SATSolver#solve()} has not been called, - * or the last call to {@link SATSolver#solve()} returned true - * @see ReductionStrategy - */ - public void reduce(ReductionStrategy strategy); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATSolver.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATSolver.java deleted file mode 100644 index da84050cc..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/SATSolver.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.satlab; - -/** - * Provides an interface to a SAT solver. - * - * @specfield variables: set [1..) - * @specfield clauses: set Clause - * @invariant all i: [2..) | i in variables => i-1 in variables - * @invariant all c: clauses | all lit: c.literals | lit in variables || -lit in - * variables - * @invariant all c: clauses | all disj i,j: c.literals | abs(i) != abs(j) - * @author Emina Torlak - */ -public interface SATSolver { - - /** - * Returns the size of this solver's vocabulary. - * - * @return #this.variables - */ - public abstract int numberOfVariables(); - - /** - * Returns the number of clauses in this solver. - * - * @return #this.clauses - */ - public abstract int numberOfClauses(); - - /** - * Adds the specified number of new variables to the solver's vocabulary. The - * behavior of this method is undefined if it is called after this.solve() has - * returned false. - * - * @requires numVars >= 0 - * @ensures this.variables' = [1..#this.variables + numVars] - * @throws IllegalArgumentException numVars < 0 - */ - public abstract void addVariables(int numVars); - - /** - * Ensures that this solver logically contains the given clause, and returns - * true if this.clauses changed as a result of the call. No reference to the - * specified array is kept, so it can be reused. The contents of the array - * may, however, be modified. It is the client's responsibility to ensure - * that no literals in the given array are repeated, or that both a literal and - * its negation are present. The behavior of this method is undefined if it is - * called after this.solve() has returned false. - * - * @requires all i: [0..lits.length) | abs(lits[i]) in this.variables - * @requires all disj i,j: [0..lits.length) | abs(lits[i]) != abs(lits[j]) - * @ensures [[this.clauses']] = ([[this.clauses]] and [[lits]]) - * @return #this.clauses' > #this.clauses - * @throws NullPointerException lits = null - */ - public abstract boolean addClause(int[] lits); - - /** - * Returns true if there is a satisfying assignment for this.clauses. Otherwise - * returns false. If this.clauses are satisfiable, the satisfying assignment for - * a given variable can be obtained by calling {@link #valueOf(int)}. If the - * satisfiability of this.clauses cannot be determined within the given number - * of seconds, a TimeoutException is thrown. - * - * @return true if this.clauses are satisfiable; otherwise false. - * @throws SATAbortedException - the call to solve was cancelled or could not - * terminate normally. - */ - public abstract boolean solve() throws SATAbortedException; - - /** - * Returns the boolean value assigned to the given variable by the last - * successful call to {@link #solve()}. - * - * @requires {@link #solve() } has been called and the outcome of the last call - * was true. - * @return the boolean value assigned to the given variable by the last - * successful call to {@link #solve()}. - * @throws IllegalArgumentException variable !in this.variables - * @throws IllegalStateException {@link #solve() } has not been called or the - * outcome of the last call was not true. - */ - public abstract boolean valueOf(int variable); - - /** - * Frees the memory used by this solver. Once free() is called, all subsequent - * calls to methods other than free() may fail. - * - * @ensures frees the memory used by this solver - */ - public abstract void free(); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/package.html deleted file mode 100644 index 887a913e1..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/package.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - -Provides access to various Java and C++ SAT solvers through a -common SAT Solver interface. - -

Package Specification

- -

Provides access to various Java and C++ SAT solvers through the -{@linkplain kodkod.engine.satlab.SATSolver} and -{@linkplain kodkod.engine.satlab.SATProver} interfaces. The -{@linkplain kodkod.engine.satlab.SATFactory} class contains a selection of -static instances that can be used to generate specific SAT solvers.

- -

Related Documentation

- -@see kodkod.engine.satlab.SATFactory -@see kodkod.engine.satlab.SATSolver -@see kodkod.engine.satlab.SATProver - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/satlab/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/AdaptiveRCEStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/AdaptiveRCEStrategy.java deleted file mode 100644 index 800476b55..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/AdaptiveRCEStrategy.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntCollection; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * Adaptive Recycling Core Extraction is a strategy for generating unsat cores - * that are minimal at the logic level. Specifically, let C be a core that is - * minimal according to this strategy, and let F(C) be the top-level logic - * constraints corresponding to C. Then, this strategy guarantees that there is - * no clause c in C such that F(C - c) is a strict subset of F(C). Furthermore, - * it also guarantees that for all f in F(C), F(C) - f is satisfiable. This is a - * stronger guarantee than that of {@linkplain HybridStrategy}. In general, - * using this strategy is more expensive, timewise, than using - * {@linkplain HybridStrategy}. - *

- * Unlike RCE, ARCE is parameterized with 3 values that control the amount of - * recycling. The first is the noRecycleRatio, which completely - * disables recycling if it is greater than the ratio of the size of the core - * passed to {@linkplain #next(ResolutionTrace)} and the number of axioms in the - * trace. The default value is .03; if the core makes up only 3 percent of the - * axioms, no recycling will happen. The remaining two parameters are the - * recycleLimit and the hardnessCutOff. If the hardness of the - * proof passed to {@linkplain #next(ResolutionTrace)} is greater than - * hardnessCutOff, then the number of relevant axioms, |A_r|, plus the - * number of recycled resolvents is no greater than |A_r|*recycleLimit. - * Otherwise, all valid resolvents are recycled (i.e. added to the relevant - * axioms). Proof hardness is the ratio of the trace size to the number of - * axioms in the trace. Default value for hardnessCutOff is 2.0, and - * default value for recycleLimit is 1.2. - *

- * This implementation of ARCE will work properly only on CNFs generated by the - * kodkod {@linkplain Translator}. - *

- * - * @specfield noRecycleRatio: double - * @specfield hardnessCutOff: double - * @specfield recycleLimit: double - * @invariant noRecycleRatio in [0..1] - * @invariant recycleLimit >= 1 - * @invariant hardnessCutOff >= 1 - * @author Emina Torlak - * @see HybridStrategy - */ -public final class AdaptiveRCEStrategy implements ReductionStrategy { - - private final IntCollection varsToTry; - private final double noRecycleRatio, recycleLimit, hardnessCutOff; - private static final boolean DBG = true; - - /** - * Constructs an ARCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - * - * @ensures this.hardnessCutOff' = 2 and this.recycleLimit' = 1.2 and - * this.noRecycleRatio' = .03 - */ - public AdaptiveRCEStrategy(final TranslationLog log) { - this(log, .03, 2.0, 1.2); - } - - /** - * Constructs an ARCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - * - * @ensures this.hardnessCutOff' = hardnessCutOff and this.recycleLimit' = - * recycleLimit and this.noRecycleRatio' = noRecycleRatio - */ - public AdaptiveRCEStrategy(final TranslationLog log, double noRecycleRatio, double hardnessCutOff, double recycleLimit) { - varsToTry = StrategyUtils.rootVars(log); - if (noRecycleRatio < 0 || noRecycleRatio > 1) - throw new IllegalArgumentException("noRecycleRatio must be in [0..1]: " + noRecycleRatio); - if (hardnessCutOff < 1) - throw new IllegalArgumentException("hardnessCutOff must be >=1: " + hardnessCutOff); - if (recycleLimit < 1) - throw new IllegalArgumentException("recycleLimit must be >=1: " + recycleLimit); - this.noRecycleRatio = noRecycleRatio; - this.hardnessCutOff = hardnessCutOff; - this.recycleLimit = recycleLimit; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(ResolutionTrace trace) { - if (varsToTry.isEmpty()) - return Ints.EMPTY_SET; // tried everything - - final IntSet relevantVars = StrategyUtils.coreTailUnits(trace); - - for (IntIterator varItr = varsToTry.iterator(); varItr.hasNext();) { - final int var = varItr.next(); - varItr.remove(); - if (relevantVars.remove(var)) { // remove maxVar from the set of - // relevant variables - if (relevantVars.isEmpty()) - break; // there was only one root formula left - // get all axioms and resolvents corresponding to the clauses - // that - // form the translations of formulas identified by relevant vars - final IntSet relevantClauses = clausesFor(trace, relevantVars); - assert !relevantClauses.isEmpty() && !relevantClauses.contains(trace.size() - 1); - - if (DBG) - System.out.println("relevant clauses: " + relevantClauses.size() + ", removed " + var); - - return relevantClauses; - } - } - - varsToTry.clear(); - return Ints.EMPTY_SET; - } - - /** - * Returns the indices of all axioms and resolvents in the given trace that form - * the translations of the formulas identified by the given variables. This - * method assumes that the axioms in the given trace were generated by the - * Kodkod {@linkplain Translator}. - * - * @return let C = { c: trace.prover.clauses | c.maxVariable() in relevantVars - * }, T = { c1, c2: C | c2.maxVariable() in abs(c1.literals) }, A = C.*T - * | trace.backwardReachable(A) - trace.backwardReachable(trace.axioms() - * - A) - */ - private IntSet clausesFor(ResolutionTrace trace, IntSet relevantVars) { - final double hardness = (double) trace.size() / (double) trace.axioms().size(); - final double coreRatio = ((double) trace.core().size() / (double) trace.axioms().size()); - - if (DBG) - System.out.println("\ntrace size: " + trace.size() + ", axioms: " + trace.axioms().size() + ", core: " + trace.core().size() + ", resolvents: " + trace.resolvents().size()); - if (DBG) - System.out.println("hardness: " + hardness + ", coreRatio: " + coreRatio); - - final IntSet relevantAxioms = StrategyUtils.clausesFor(trace, relevantVars); - if (DBG) - System.out.println("relevant axioms: " + relevantAxioms.size()); - - if (coreRatio < noRecycleRatio) { - return relevantAxioms; - } else if (hardness < hardnessCutOff) { - return trace.learnable(relevantAxioms); - } else { - IntSet current = relevantAxioms, last; - final int maxRelevant = (int) Math.rint(relevantAxioms.size() * recycleLimit); - do { - last = current; - current = trace.directlyLearnable(current); - } - while (last.size() < current.size() && current.size() < maxRelevant); - - if (DBG) - System.out.println("last: " + last.size() + ", current: " + current.size() + ", maxRelevant: " + maxRelevant); - - return current.size() < maxRelevant ? current : last; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/CRRStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/CRRStrategy.java deleted file mode 100644 index cbdbd3a9c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/CRRStrategy.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import java.util.HashSet; -import java.util.Set; - -import kodkod.engine.satlab.Clause; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * A basic implementation of the Complete ResolutionTrace Refutation algorithm - * for for producing locally minimal cores. An unsatisfiable core is locally - * minimal iff removing any single clause from the core will make the resulting - * formula satisfiable. No heuristic is used to pick the clauses to be excluded - * from the core. - * - * @specfield traces: [0..)->ResolutionTrace - * @specfield nexts: [0..)->Set - * @invariant traces.ResolutionTrace = nexts.Set - * @invariant all i: [1..) | some traces[i] => some traces[i-1] - * @invariant all i: [0..#nexts) | nexts[i] in traces[i].conflict.^antecedents - * @invariant no disj i,j: [0..#nexts) | traces[i] = traces[j] && nexts[i] = - * nexts[j] - * @author Emina Torlak - * @see N. - * Dershowitz, Z. Hanna, and A. Nadel. A scalable algorithm for minimal - * unsatisfiable core extraction. In Proceedings of Ninth International - * Conference on Theory and Applications of Satisfiability Testing (SAT - * '06). 2006. - */ -public final class CRRStrategy implements ReductionStrategy { - - private Set excluded; - - /** - * Constructs a new instance of CRRStrategy. - * - * @ensures no this.traces' and no this.nexts' - **/ - public CRRStrategy() { - excluded = null; - } - - /** - * Returns the next subset of clauses in the given trace to be analyzed. - * - * @requires {@inheritDoc} - * @ensures {@inheritDoc} - * @return last(this.nexts') - */ - @Override - public final IntSet next(final ResolutionTrace trace) { - final IntSet core = trace.core(); - if (excluded == null) { // the first time this method is called - excluded = new HashSet((int) (StrictMath.round(core.size() * .75))); - } - - for (IntIterator iter = core.iterator(Integer.MAX_VALUE, Integer.MIN_VALUE); iter.hasNext();) { - int index = iter.next(); - if (excluded.add(trace.get(index))) { // haven't tried excluding - // this one - // get all clauses reachable from the conflict clause - IntSet next = trace.reachable(Ints.singleton(trace.size() - 1)); - // remove all clauses backward reachable from the excluded - // clause - next.removeAll(trace.backwardReachable(Ints.singleton(index))); - return next; - } - } - - return Ints.EMPTY_SET; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/DynamicRCEStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/DynamicRCEStrategy.java deleted file mode 100644 index 94a98b8cc..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/DynamicRCEStrategy.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import java.util.Arrays; -import java.util.Iterator; - -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.Clause; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntBitSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - * Dynamic Recycling Core Extraction is a strategy for generating unsat cores - * that are minimal at the logic level. Specifically, let C be a core that is - * minimal according to this strategy, and let F(C) be the top-level logic - * constraints corresponding to C. Then, this strategy guarantees that there is - * no clause c in C such that F(C - c) is a strict subset of F(C). Furthermore, - * it also guarantees that for all f in F(C), F(C) - f is satisfiable. This is a - * stronger guarantee than that of {@linkplain HybridStrategy}. In general, - * using this strategy is more expensive, timewise, than using - * {@linkplain HybridStrategy}. - *

- * Like Adaptive RCE, DRCE is parameterized with 3 values that control the - * amount of recycling. The first is the noRecycleRatio, which - * completely disables recycling if it is greater than the ratio of the size of - * the core passed to {@linkplain #next(ResolutionTrace)} and the number of - * axioms in the trace. The default value is .03; if the core makes up only 3 - * percent of the axioms, no recycling will happen. The remaining two parameters - * are the recycleLimit and the hardnessCutOff. If the - * hardness of the proof passed to {@linkplain #next(ResolutionTrace)} is - * greater than hardnessCutOff, then the number of relevant axioms, - * |A_r|, plus the number of recycled resolvents is no greater than - * |A_r|*recycleLimit. Otherwise, all valid resolvents are recycled - * (i.e. added to the relevant axioms). Proof hardness is the ratio of the trace - * size to the number of axioms in the trace. Default value for - * hardnessCutOff is 2.0, and default value for recycleLimit - * is 1.2. - *

- * Unlike ARCE, DRCE uses proof information to determine the order in which the - * constraints are tested for membership in a minimal core. ARCE, RCE, SCE and - * NCE all use the same (arbitrary but deterministic) ordering. - *

- *

- * This implementation of DRCE will work properly only on CNFs generated by the - * kodkod {@linkplain Translator}. - *

- * - * @specfield noRecycleRatio: double - * @specfield hardnessCutOff: double - * @specfield recycleLimit: double - * @invariant noRecycleRatio in [0..1] - * @invariant recycleLimit >= 1 - * @invariant hardnessCutOff >= 1 - * @author Emina Torlak - * @see HybridStrategy - */ -public final class DynamicRCEStrategy implements ReductionStrategy { - - private final double noRecycleRatio, recycleLimit, hardnessCutOff; - private static final boolean DBG = true; - private final SparseSequence hits; - - /** - * Constructs an ARCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - * - * @ensures this.hardnessCutOff' = 2 and this.recycleLimit' = 1.2 and - * this.noRecycleRatio' = .03 - */ - public DynamicRCEStrategy(final TranslationLog log) { - this(log, .03, 2.0, 1.2); - } - - /** - * Constructs an ARCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - * - * @ensures this.hardnessCutOff' = hardnessCutOff and this.recycleLimit' = - * recycleLimit and this.noRecycleRatio' = noRecycleRatio - */ - public DynamicRCEStrategy(final TranslationLog log, double noRecycleRatio, double hardnessCutOff, double recycleLimit) { - if (noRecycleRatio < 0 || noRecycleRatio > 1) - throw new IllegalArgumentException("noRecycleRatio must be in [0..1]: " + noRecycleRatio); - if (hardnessCutOff < 1) - throw new IllegalArgumentException("hardnessCutOff must be >=1: " + hardnessCutOff); - if (recycleLimit < 1) - throw new IllegalArgumentException("recycleLimit must be >=1: " + recycleLimit); - this.noRecycleRatio = noRecycleRatio; - this.hardnessCutOff = hardnessCutOff; - this.recycleLimit = recycleLimit; - this.hits = new TreeSequence(); - for (IntIterator itr = StrategyUtils.rootVars(log).iterator(); itr.hasNext();) { - hits.put(itr.next(), null); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(ResolutionTrace trace) { - if (hits.isEmpty()) - return Ints.EMPTY_SET; // tried everything - final IntSet relevantVars = StrategyUtils.coreTailUnits(trace); - - final long[] byRelevance = sortByRelevance(trace, relevantVars); - if (DBG) - printRelevant(byRelevance); - for (int i = byRelevance.length - 1; i >= 0; i--) { - final int var = (int) byRelevance[i]; - if (hits.remove(var) != null) { - // remove maxVar from the set of relevant variables - relevantVars.remove(var); - if (relevantVars.isEmpty()) - break; // there was only one root formula left - // get all axioms and resolvents corresponding to the clauses - // that - // form the translations of formulas identified by relevant vars - final IntSet relevantClauses = clausesFor(trace, relevantVars); - assert !relevantClauses.isEmpty() && !relevantClauses.contains(trace.size() - 1); - - if (DBG) - System.out.println("relevant clauses: " + relevantClauses.size() + ", removed " + var); - - return relevantClauses; - } - } - - hits.clear(); - return Ints.EMPTY_SET; - } - - private final void printRelevant(long[] byRelevance) { - System.out.print("\nsorted by relevance: "); - for (long r : byRelevance) { - System.out.print((int) (r >>> 32) + ":" + (int) r + " "); - } - System.out.println(); - } - - /** - * Returns an array R of longs such that for each i, j in [0..R.length) i < j - * implies that the formula identified by (int)R[i] in this.hits contributes - * fewer clauses to the core of the given trace than the formula identified by - * (int)R[j]. - * - * @return an array as described above - */ - private long[] sortByRelevance(ResolutionTrace trace, IntSet relevantVars) { - hits.indices().retainAll(relevantVars); - - if (hits.get(hits.indices().min()) == null) { // first call, initialize - // the hits - for (IntIterator varItr = relevantVars.iterator(); varItr.hasNext();) { - final int var = varItr.next(); - final IntSet varReachable = new IntBitSet(var + 1); - varReachable.add(var); - hits.put(var, varReachable); - } - for (Iterator clauseItr = trace.reverseIterator(trace.axioms()); clauseItr.hasNext();) { - final Clause clause = clauseItr.next(); - final int maxVar = clause.maxVariable(); - for (IntSet reachableVars : hits.values()) { - if (reachableVars.contains(maxVar)) { - for (IntIterator lits = clause.literals(); lits.hasNext();) { - reachableVars.add(StrictMath.abs(lits.next())); - } - } - } - } - } - - final long[] counts = new long[hits.size()]; - - for (Iterator clauseItr = trace.iterator(trace.core()); clauseItr.hasNext();) { - final Clause clause = clauseItr.next(); - final int maxVar = clause.maxVariable(); - int i = 0; - for (IntSet reachableVars : hits.values()) { - if (reachableVars.contains(maxVar)) { - counts[i]++; - } - i++; - } - } - - int i = 0; - for (IntIterator varItr = hits.indices().iterator(); varItr.hasNext();) { - final int var = varItr.next(); - counts[i] = (counts[i] << 32) | var; - i++; - } - - Arrays.sort(counts); - - return counts; - } - - /** - * Returns the indices of all axioms and resolvents in the given trace that form - * the translations of the formulas identified by the given variables. This - * method assumes that the axioms in the given trace were generated by the - * Kodkod {@linkplain Translator}. - * - * @return let C = { c: trace.prover.clauses | c.maxVariable() in relevantVars - * }, T = { c1, c2: C | c2.maxVariable() in abs(c1.literals) }, A = C.*T - * | trace.backwardReachable(A) - trace.backwardReachable(trace.axioms() - * - A) - */ - private IntSet clausesFor(ResolutionTrace trace, IntSet relevantVars) { - final double hardness = (double) trace.size() / (double) trace.axioms().size(); - final double coreRatio = ((double) trace.core().size() / (double) trace.axioms().size()); - - if (DBG) - System.out.println("trace size: " + trace.size() + ", axioms: " + trace.axioms().size() + ", core: " + trace.core().size() + ", resolvents: " + trace.resolvents().size()); - if (DBG) - System.out.println("hardness: " + hardness + ", coreRatio: " + coreRatio); - - final IntSet relevantAxioms = StrategyUtils.clausesFor(trace, relevantVars); - if (DBG) - System.out.println("relevant axioms: " + relevantAxioms.size()); - - if (coreRatio < noRecycleRatio) { - return relevantAxioms; - } else if (hardness < hardnessCutOff) { - return trace.learnable(relevantAxioms); - } else { - IntSet current = relevantAxioms, last; - final int maxRelevant = (int) Math.rint(relevantAxioms.size() * recycleLimit); - do { - last = current; - current = trace.directlyLearnable(current); - } - while (last.size() < current.size() && current.size() < maxRelevant); - - if (DBG) - System.out.println("last: " + last.size() + ", current: " + current.size() + ", maxRelevant: " + maxRelevant); - - return current.size() < maxRelevant ? current : last; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/ECFPStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/ECFPStrategy.java deleted file mode 100644 index cb1cc1ac1..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/ECFPStrategy.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * A non-optimal minimization strategy based on the Empty Clause Cone algorithm. - * - * @author Emina Torlak - * @see L. - * Zhang and S. Malik. Extracting small unsatisfiable cores from - * unsatisfiable Boolean formula. In Proceedings of Sixth International - * Conference on Theory and Applications of Satisfiability Testing (SAT - * '03). 2003. - */ -public final class ECFPStrategy implements ReductionStrategy { - - private int lastCore; - - /** - * Constructs a new instance of the empty clause cone strategy for minimizing - * unsatisfiable cores. - */ - public ECFPStrategy() { - lastCore = Integer.MAX_VALUE; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(final ResolutionTrace trace) { - final IntSet core = trace.core(); - if (lastCore > core.size()) { - lastCore = core.size(); - return core; - } else { - lastCore = Integer.MIN_VALUE; - return Ints.EMPTY_SET; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/HybridStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/HybridStrategy.java deleted file mode 100644 index 1ebd97623..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/HybridStrategy.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import java.util.Iterator; - -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.Clause; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntBitSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * A hybrid strategy for generating unsat cores that are minimal when mapped - * back onto the logic level. Specifically, let C be a core that is minimal - * according to this strategy, and let F(C) be the top-level logic constraints - * corresponding to C. Then, this strategy guarantees that there is no clause c - * in C such that F(C - c) is a strict subset of F(C). Note that this does not - * guarantee that F(C) itself is minimal. In other words, there could be an f in - * F(C) such that F(C) - f is unsatisfiable. To get a minimal logic core, use - * {@linkplain RCEStrategy}. - *

- * This strategy will work properly only on CNFs generated by the kodkod - * {@linkplain Translator}. - *

- * - * @author Emina Torlak - * @see RCEStrategy - */ -public final class HybridStrategy implements ReductionStrategy { - - private final IntSet topVars; - - /** - * Constructs a hybrid strategy that will use the given translation log to - * relate the cnf clauses back to the logic constraints from which they were - * generated. - */ - public HybridStrategy(TranslationLog log) { - topVars = StrategyUtils.rootVars(log); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(ResolutionTrace trace) { - if (topVars.isEmpty()) - return Ints.EMPTY_SET; // tried everything - final IntSet core = trace.core(); - - for (Iterator iter = trace.iterator(core); iter.hasNext();) { - Clause clause = iter.next(); - int maxVar = clause.maxVariable(); - if (topVars.remove(maxVar)) { - // get all core clauses with the given maximum variable - IntSet exclude = coreClausesWithMaxVar(trace, maxVar); - assert !exclude.isEmpty(); - // get all clauses reachable from the conflict clause - IntSet next = trace.reachable(Ints.singleton(trace.size() - 1)); - // remove all clauses backward reachable from the clauses with - // the given maxVar - next.removeAll(trace.backwardReachable(exclude)); - if (!next.isEmpty()) { - return next; - } - } - } - - topVars.clear(); - return Ints.EMPTY_SET; - } - - /** - * Returns the indices of the clauses in the unsatisfiable core of the given - * trace that have the specified maximum variable. - * - * @return { i: trace.core() | trace[i].maxVariable() = maxVariable } - */ - private static IntSet coreClausesWithMaxVar(ResolutionTrace trace, int maxVariable) { - final IntSet core = trace.core(); - final IntSet restricted = new IntBitSet(core.max() + 1); - final Iterator clauses = trace.iterator(core); - final IntIterator indices = core.iterator(); - while (clauses.hasNext()) { - Clause clause = clauses.next(); - int index = indices.next(); - if (clause.maxVariable() == maxVariable) - restricted.add(index); - } - return restricted; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/NCEStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/NCEStrategy.java deleted file mode 100644 index 1c4f4a857..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/NCEStrategy.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntCollection; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; -import kodkod.util.ints.Ints; - -/** - * Naive Core Extraction is a strategy for generating unsat cores that are - * minimal at the logic level. Specifically, let C be a core that is minimal - * according to this strategy, and let F(C) be the top-level logic constraints - * corresponding to C. Then, this strategy guarantees that there is no clause c - * in C such that F(C - c) is a strict subset of F(C). Furthermore, it also - * guarantees that for all f in F(C), F(C) - f is satisfiable. This is a - * stronger guarantee than that of {@linkplain HybridStrategy}. In general, - * using this strategy is more expensive, timewise, than using - * {@linkplain HybridStrategy}. - *

- * This implementation of NCE will work properly only on CNFs generated by the - * kodkod {@linkplain Translator}. - *

- * - * @author Emina Torlak - * @see HybridStrategy - */ -public final class NCEStrategy implements ReductionStrategy { - - private final IntCollection varsToTry; - private final IntSet coreVars; - - /** - * Constructs an NCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - */ - public NCEStrategy(final TranslationLog log) { - varsToTry = StrategyUtils.rootVars(log); - coreVars = new IntTreeSet();// new IntTreeSet(varsToTry); - coreVars.addAll(varsToTry); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(ResolutionTrace trace) { - if (varsToTry.isEmpty()) - return Ints.EMPTY_SET; - // if the last attempt at reduction was unsuccessful, - // add the unit clauses that we tried to discard back to coreVars - coreVars.addAll(StrategyUtils.coreTailUnits(trace)); - final int first = varsToTry.iterator().next();// varsToTry.min(); - varsToTry.remove(first); - coreVars.remove(first); - // get all axioms corresponding to the clauses that - // form the translations of formulas identified by coreVars - final IntSet relevantClauses = StrategyUtils.clausesFor(trace, coreVars); - assert !relevantClauses.isEmpty() && !relevantClauses.contains(trace.size() - 1); - return relevantClauses; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/RCEStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/RCEStrategy.java deleted file mode 100644 index 8c7368342..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/RCEStrategy.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntCollection; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * Recycling Core Extraction is a strategy for generating unsat cores that are - * minimal at the logic level. Specifically, let C be a core that is minimal - * according to this strategy, and let F(C) be the top-level logic constraints - * corresponding to C. Then, this strategy guarantees that there is no clause c - * in C such that F(C - c) is a strict subset of F(C). Furthermore, it also - * guarantees that for all f in F(C), F(C) - f is satisfiable. This is a - * stronger guarantee than that of {@linkplain HybridStrategy}. In general, - * using this strategy is more expensive, timewise, than using - * {@linkplain HybridStrategy}. - *

- * This implementation of RCE will work properly only on CNFs generated by the - * kodkod {@linkplain Translator}. - *

- * - * @author Emina Torlak - * @see HybridStrategy - */ -public class RCEStrategy implements ReductionStrategy { - - private final IntCollection varsToTry; - private final int dist; - - /** - * Constructs an RCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - * By default, all relevant resolvents are used in each iteration. - */ - public RCEStrategy(final TranslationLog log) { - this(log, Integer.MAX_VALUE); - } - - /** - * Constructs an RCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - * The relevant resolvents used in each iteration are reachable from the - * relevant axioms in at most dist steps. - * - * @requires dist >= 0 - */ - public RCEStrategy(final TranslationLog log, int dist) { - if (dist < 0) - throw new IllegalArgumentException("Resolution distance must be non-negative: " + dist); - varsToTry = StrategyUtils.rootVars(log); - this.dist = dist; - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(ResolutionTrace trace) { - if (varsToTry.isEmpty()) - return Ints.EMPTY_SET; // tried everything - final IntSet relevantVars = StrategyUtils.coreTailUnits(trace); - - for (IntIterator varItr = varsToTry.iterator(); varItr.hasNext();) { - final int var = varItr.next(); - varItr.remove(); - if (relevantVars.remove(var)) { // remove maxVar from the set of - // relevant variables - if (relevantVars.isEmpty()) - break; // there was only root formula left - // get all axioms and resolvents corresponding to the clauses - // that - // form the translations of formulas identified by relevant vars - final IntSet relevantClauses = clausesFor(trace, relevantVars); - assert !relevantClauses.isEmpty() && !relevantClauses.contains(trace.size() - 1); - return relevantClauses; - } - } - - varsToTry.clear(); - return Ints.EMPTY_SET; - } - - /** - * Returns the indices of all axioms and resolvents in the given trace that form - * the translations of the formulas identified by the given variables. This - * method assumes that the axioms in the given trace were generated by the - * Kodkod {@linkplain Translator}. - * - * @return let C = { c: trace.prover.clauses | c.maxVariable() in relevantVars - * }, T = { c1, c2: C | c2.maxVariable() in abs(c1.literals) }, A = C.*T - * | trace.backwardReachable(A) - trace.backwardReachable(trace.axioms() - * - A) - */ - private IntSet clausesFor(ResolutionTrace trace, IntSet relevantVars) { - - final IntSet relevantAxioms = StrategyUtils.clausesFor(trace, relevantVars); - - if (dist < trace.resolvents().size()) { - IntSet relevant = relevantAxioms; - for (int i = 0, lastSize = 0; lastSize < relevant.size() && i < dist; i++) { - lastSize = relevant.size(); - relevant = trace.directlyLearnable(relevant); - } - return relevant; - } else { - return trace.learnable(relevantAxioms); // return all resolvents - } - - // System.out.println("level 1 resolvents " + - // (relevant.size()-relevantAxioms.size()) + ", axioms " + - // relevantAxioms.size()); - - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/SCEStrategy.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/SCEStrategy.java deleted file mode 100644 index 8bb33948c..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/SCEStrategy.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.util.ints.IntCollection; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * Simple Core Extraction is a strategy for generating unsat cores that are - * minimal at the logic level. Specifically, let C be a core that is minimal - * according to this strategy, and let F(C) be the top-level logic constraints - * corresponding to C. Then, this strategy guarantees that there is no clause c - * in C such that F(C - c) is a strict subset of F(C). Furthermore, it also - * guarantees that for all f in F(C), F(C) - f is satisfiable. This is a - * stronger guarantee than that of {@linkplain HybridStrategy}. In general, - * using this strategy is more expensive, timewise, than using - * {@linkplain HybridStrategy}. - *

- * This implementation of SCE will work properly only on CNFs generated by the - * kodkod {@linkplain Translator}. - *

- * - * @author Emina Torlak - * @see HybridStrategy - */ -public final class SCEStrategy implements ReductionStrategy { - - private final IntCollection varsToTry; - - /** - * Constructs an SCE strategy that will use the given translation log to relate - * the cnf clauses back to the logic constraints from which they were generated. - */ - public SCEStrategy(final TranslationLog log) { - varsToTry = StrategyUtils.rootVars(log); - } - - /** - * {@inheritDoc} - * - * @see kodkod.engine.satlab.ReductionStrategy#next(kodkod.engine.satlab.ResolutionTrace) - */ - @Override - public IntSet next(ResolutionTrace trace) { - if (varsToTry.isEmpty()) - return Ints.EMPTY_SET; // tried everything - final IntSet relevantVars = StrategyUtils.coreTailUnits(trace); - - for (IntIterator varItr = varsToTry.iterator(); varItr.hasNext();) { - final int var = varItr.next(); - varItr.remove(); - if (relevantVars.remove(var)) { // remove maxVar from the set of - // relevant variables - if (relevantVars.isEmpty()) - break; // there was only root formula left - // get all axioms corresponding to the clauses that - // form the translations of formulas identified by relevant vars - final IntSet relevantClauses = StrategyUtils.clausesFor(trace, relevantVars); - assert !relevantClauses.isEmpty() && !relevantClauses.contains(trace.size() - 1); - return relevantClauses; - } - } - varsToTry.clear(); - return Ints.EMPTY_SET; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/StrategyUtils.java b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/StrategyUtils.java deleted file mode 100644 index 47e5a5ea0..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/StrategyUtils.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.engine.ucore; - -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Variable; -import kodkod.engine.fol2sat.RecordFilter; -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.fol2sat.TranslationRecord; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.satlab.Clause; -import kodkod.engine.satlab.ResolutionTrace; -import kodkod.instance.TupleSet; -import kodkod.util.ints.IntBitSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; -import kodkod.util.ints.Ints; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - * A collection of utility methods for implementing logic-level reduction - * strategies. - * - * @author Emina Torlak - */ -public final class StrategyUtils { - - private StrategyUtils() {} - - /** - * Returns the variables that correspond to the roots of log.formula. - * - * @return - * - *
-     *
-     * { v: int | some r: log.records |
-     *   r.node in log.roots() and
-     *   r.env.isEmpty() and
-     *   abs(r.literal) != Integer.MAX_VALUE and
-     *   v = abs(r.literal) and
-     *   no r': log.records | r'.node = r.node && log.replay.r' > log.replay.r }
-     *         
- */ - public static IntSet rootVars(TranslationLog log) { - final IntSet rootVars = new IntTreeSet(); - final Set roots = log.roots(); - final Map maxRootVar = new LinkedHashMap(roots.size()); - final RecordFilter filter = new RecordFilter() { - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return roots.contains(translated) && env.isEmpty(); - } - }; - for (Iterator itr = log.replay(filter); itr.hasNext();) { - TranslationRecord record = itr.next(); - int[] var = maxRootVar.get(record.translated()); - if (var == null) { - var = new int[1]; - maxRootVar.put(record.translated(), var); - } - var[0] = StrictMath.abs(record.literal()); - } - - for (int[] var : maxRootVar.values()) { - int topVar = var[0]; - if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE - rootVars.add(var[0]); - } - - // for(Map.Entry entry : maxRootVar.entrySet()) { - // final int topVar = entry.getValue()[0]; - // if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE - // rootVars.add(topVar); - // System.out.println(topVar + " ==>" + entry.getKey()); - // } - - return rootVars; - } - - /** - * Returns a map from variables to the corresponding roots of log.formula. - * - * @return - * - *
-     *
-     * { v: int, f: Formula | some r: log.records |
-     *   r.translated in log.roots() and
-     *   r.translated = f and
-     *   r.env.isEmpty() and
-     *   abs(r.literal) != Integer.MAX_VALUE and
-     *   v = abs(r.literal) and
-     *   no r': log.records | r'.node = r.node && log.replay.r' > log.replay.r }
-     *         
- */ - static SparseSequence roots(TranslationLog log) { - final SparseSequence rootVars = new TreeSequence(); - final Set roots = log.roots(); - final Map maxRootVar = new IdentityHashMap(roots.size()); - final RecordFilter filter = new RecordFilter() { - - @Override - public boolean accept(Node node, Formula translated, int literal, Map env) { - return roots.contains(translated) && env.isEmpty(); - } - }; - for (Iterator itr = log.replay(filter); itr.hasNext();) { - TranslationRecord record = itr.next(); - int[] var = maxRootVar.get(record.translated()); - if (var == null) { - var = new int[1]; - maxRootVar.put(record.translated(), var); - } - var[0] = StrictMath.abs(record.literal()); - } - - for (Map.Entry entry : maxRootVar.entrySet()) { - final int topVar = entry.getValue()[0]; - if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE - rootVars.put(topVar, entry.getKey()); - } - return rootVars; - } - - /** - * Returns the variables that correspond to the roots of log.formula, in the - * order in which they were specified in log.formula. - * - * @return variables that correspond to the roots of log.formula, in the order - * in which they were specified in log.formula. - */ - // static IntVector orderedRootVars(TranslationLog log) { - // final Set roots = log.roots(); - // final Map maxRootVar = new - // LinkedHashMap(roots.size()); - // final RecordFilter filter = new RecordFilter() { - // public boolean accept(Node node, int literal, Map - // env) { - // return roots.contains(node) && env.isEmpty(); - // } - // }; - // for(Iterator itr = log.replay(filter); itr.hasNext();) - // { - // TranslationRecord record = itr.next(); - // int[] var = maxRootVar.get(record.node()); - // if (var==null) { - // var = new int[1]; - // maxRootVar.put((Formula)record.node(), var); - // } - // var[0] = StrictMath.abs(record.literal()); - // } - // final IntSet uniqueRoots = new IntTreeSet(); - // final IntVector orderedRoots = new ArrayIntVector(roots.size()); - // for(int[] var : maxRootVar.values()) { - // int topVar = var[0]; - // if (topVar != Integer.MAX_VALUE) // formula simplified to TRUE - // if (uniqueRoots.add(var[0])) { - // orderedRoots.add(var[0]); - // }; - // } - // return orderedRoots; - // } - - /** - * Returns relevant core variables; that is, all variables that occur both in - * the positive and negative phase in trace.core. - * - * @return { v: [1..) | (some p, n: trace.core | v in trace.elts[p].literals and - * -v in trace.elts[n].literals) } - */ - public static IntSet coreVars(ResolutionTrace trace) { - - final IntSet posVars = new IntTreeSet(), negVars = new IntTreeSet(); - - for (Iterator iter = trace.iterator(trace.core()); iter.hasNext();) { - Clause clause = iter.next(); - for (IntIterator lits = clause.literals(); lits.hasNext();) { - int lit = lits.next(); - if (lit > 0) - posVars.add(lit); - else - negVars.add(-lit); - } - } - - posVars.retainAll(negVars); - - assert !posVars.isEmpty(); - final IntSet ret = new IntBitSet(posVars.max() + 1); - ret.addAll(posVars); - - return ret; - } - - /** - * Returns the set of all variables in the core of the given trace that form - * unit clauses. - * - * @return { v: [1..) | some c: trace.core | c.size() = 1 and c.maxVariable() = - * v } - */ - public static IntSet coreUnits(ResolutionTrace trace) { - final IntSet units = new IntTreeSet(); - - for (Iterator itr = trace.reverseIterator(trace.core()); itr.hasNext();) { - Clause c = itr.next(); - if (c.size() == 1) { - units.add(c.maxVariable()); - } - } - - if (units.isEmpty()) - return Ints.EMPTY_SET; - - return Ints.asSet(units.toArray()); - } - - /** - * Returns the consecutive variables at the tail of the core of the given trace - * that form unit clauses. - * - * @return the consecutive variables at the tail of the core of the given trace - * that form unit clauses - */ - static IntSet coreTailUnits(ResolutionTrace trace) { - final IntSet units = new IntTreeSet(); - - for (Iterator itr = trace.reverseIterator(trace.core()); itr.hasNext();) { - Clause c = itr.next(); - if (c.size() == 1) { - units.add(c.maxVariable()); - } else { - break; - } - } - - return units; - } - - /** - * Returns the indices of all axioms in the given trace that form the - * translations of the formulas identified by the given variables. This method - * assumes that the axioms in the given trace were generated by the Kodkod - * {@linkplain Translator}. - * - * @return let C = { c: trace.prover.clauses | c.maxVariable() in relevantVars - * }, T = { c1, c2: C | c2.maxVariable() in abs(c1.literals) } | C.*T - */ - static IntSet clausesFor(ResolutionTrace trace, IntSet relevantVars) { - // System.out.println("relevant: " + relevantVars); - final IntSet axioms = trace.axioms(); - - final IntSet reachableVars = new IntBitSet(relevantVars.max() + 1); - reachableVars.addAll(relevantVars); - - final IntSet relevantAxioms = new IntBitSet(axioms.size()); - - final Iterator itr = trace.reverseIterator(axioms); - for (int i = axioms.max(); i >= 0; i--) { - Clause clause = itr.next(); - int maxVar = clause.maxVariable(); - if (reachableVars.contains(maxVar)) { - for (IntIterator lits = clause.literals(); lits.hasNext();) { - reachableVars.add(StrictMath.abs(lits.next())); - } - relevantAxioms.add(i); - } - } - - return relevantAxioms; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/package.html deleted file mode 100644 index b8bc00ea1..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/package.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - -Contains strategies for minimizing unsatisfiable cores generated by SAT provers. - -

Package Specification

- -

Contains implementations of various {@linkplain kodkod.engine.satlab.ReductionStrategy strategies} -for minimizing unsatisfiable cores generated by {@linkplain kodkod.engine.satlab.SATProver SAT provers}.

- -

Related Documentation

- -@see kodkod.engine.satlab.ReductionStrategy -@see kodkod.engine.satlab.SATProver - - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/engine/ucore/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Bounds.java b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Bounds.java deleted file mode 100644 index 133af31c8..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Bounds.java +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.instance; - -import static java.util.Collections.unmodifiableMap; -import static kodkod.util.ints.Ints.unmodifiableSequence; - -import java.util.AbstractSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.IntConstant; -import kodkod.ast.Relation; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - *

- * A Bounds object maps a {@link kodkod.ast.Relation relation} r to two - * {@link kodkod.instance.TupleSet sets of tuples}, rL and rU, - * which represent the lower and upper bounds on the - * {@link kodkod.instance.Tuple set of tuples} to which an - * {@link kodkod.instance.Instance instance} based on these bounds may map - * r. The set rL represents all the tuples that a given relation - * must contain. The set rU represents all the tuples that a - * relation may contain. All bounding sets range over the same - * {@link kodkod.instance.Universe universe}. - *

- *

- * A Bounds object also maps integers to singleton tupleset that represent them. - * A tupleset may represent more than one integer, but an integer is represented - * by at most one tupleset. - *

- * - * @specfield universe: Universe - * @specfield relations: set Relation - * @specfield intBound: int -> lone TupleSet - * @specfield lowerBound: relations -> one TupleSet - * @specfield upperBound: relations -> one TupleSet - * @invariant all i: intBound.TupleSet | intBound[i].size() = 1 && - * intBound[i].arity() = 1 - * @invariant lowerBound[relations].universe = upperBound[relations].universe = - * universe - * @invariant all r: relations | lowerBound[r].arity = upperBound[r].arity = - * r.arity - * @invariant all r: relations | lowerBound[r].tuples in upperBound[r].tuples - * @author Emina Torlak - **/ -public final class Bounds implements Cloneable { - - private final TupleFactory factory; - private final Map lowers, uppers; - private final SparseSequence intbounds; - private final Set relations; - private final Map atom2rel; - - /** - * Constructs a Bounds object with the given factory and mappings. - */ - private Bounds(TupleFactory factory, Map lower, Map upper, SparseSequence intbounds) { - this.factory = factory; - this.lowers = lower; - this.uppers = upper; - this.intbounds = intbounds; - this.relations = relations(lowers, uppers); - this.atom2rel = new HashMap(); - for (Entry e : uppers.entrySet()) { - addAtomRel(e.getKey(), e.getValue()); - } - } - - /** - * Constructs new Bounds over the given universe. - * - * @ensures this.universe' = universe && no this.relations' && no this.intBound' - * @throws NullPointerException universe = null - */ - public Bounds(Universe universe) { - this.factory = universe.factory(); - this.lowers = new LinkedHashMap(); - this.uppers = new LinkedHashMap(); - this.intbounds = new TreeSequence(); - this.relations = relations(lowers, uppers); - this.atom2rel = new HashMap(); - } - - /** - * Returns a set view of the relations mapped by the given lower/upper bounds. - * - * @requires lowers.keySet().equals(uppers.keySet()) - * @return a set view of the relations mapped by the given lower/upper bounds - */ - private static Set relations(final Map lowers, final Map uppers) { - return new AbstractSet() { - - @Override - public Iterator iterator() { - return new Iterator() { - - final Iterator itr = uppers.keySet().iterator(); - Relation last = null; - - @Override - public boolean hasNext() { - return itr.hasNext(); - } - - @Override - public Relation next() { - return last = itr.next(); - } - - @Override - public void remove() { - itr.remove(); - lowers.remove(last); - } - }; - } - - @Override - public int size() { - return uppers.size(); - } - - @Override - public boolean contains(Object key) { - return uppers.containsKey(key); - } - - @Override - public boolean remove(Object key) { - return (uppers.remove(key) != null) && (lowers.remove(key) != null); - } - - @Override - public boolean removeAll(Collection< ? > c) { - return uppers.keySet().removeAll(c) && lowers.keySet().removeAll(c); - } - - @Override - public boolean retainAll(Collection< ? > c) { - return uppers.keySet().retainAll(c) && lowers.keySet().retainAll(c); - } - }; - } - - /** - * Returns this.universe. - * - * @return this.universe - */ - public Universe universe() { - return factory.universe(); - } - - /** - * Returns the set of all relations bound by this Bounds. The returned set does - * not support the add operation. It supports removal iff this is not an - * unmodifiable Bounds. - * - * @return this.relations - */ - public Set relations() { - return relations; - } - - public Collection skolems() { - ArrayList ans = new ArrayList(relations.size()); - for (Relation r : relations) - if (r.isSkolem()) - ans.add(r); - return ans; - } - - public Collection varRels() { - ArrayList ans = new ArrayList(relations.size()); - TupleSet ub, lb; - for (Relation r : relations) { - ub = uppers.get(r); - lb = lowers.get(r); - if (ub.size() > lb.size()) - ans.add(r); - } - return ans; - } - - /** - * Returns the set of all integers bound by this Bounds. The returned set does - * not support the add operation. It supports removal iff this is not an - * unmodifiable Bounds. - * - * @return this.intBounds.TupleSet - */ - public IntSet ints() { - return intbounds.indices(); - } - - /** - * Returns the set of tuples that r must contain (the lower bound on r's - * contents). If r is not mapped by this, null is returned. - * - * @return r in this.relations => lowerBound[r], null - */ - public TupleSet lowerBound(Relation r) { - return lowers.get(r); - } - - /** - * Returns a map view of this.lowerBound. The returned map is not modifiable. - * - * @return a map view of this.lowerBound - */ - public Map lowerBounds() { - return unmodifiableMap(lowers); - } - - /** - * Returns the set of tuples that r may contain (the upper bound on r's - * contents). If r is not mapped by this, null is returned. - * - * @return r in this.relations => upperBound[r], null - */ - public TupleSet upperBound(Relation r) { - return uppers.get(r); - } - - /** - * Returns a map view of this.upperBound. The returned map is not modifiable. - * - * @return a map view of this.upperBound - */ - public Map upperBounds() { - return unmodifiableMap(uppers); - } - - /** - * Returns the set of tuples representing the given integer. If i is not mapped - * by this, null is returned. - * - * @return this.intBound[i] - */ - public TupleSet exactBound(int i) { - return intbounds.get(i); - } - - /** - * Returns a sparse sequence view of this.intBound. The returned sequence is not - * modifiable. - * - * @return a sparse sequence view of this.intBound - */ - public SparseSequence intBounds() { - return unmodifiableSequence(intbounds); - } - - /** - * @throws IllegalArgumentException arity != bound.arity - * @throws IllegalArgumentException bound.universe != this.universe - */ - private void checkBound(int arity, TupleSet bound) { - if (arity != bound.arity()) - throw new IllegalArgumentException("bound.arity != r.arity"); - if (!bound.universe().equals(factory.universe())) - throw new IllegalArgumentException("bound.universe != this.universe"); - } - - /** - * Sets both the lower and upper bounds of the given relation to the given set - * of tuples. - * - * @requires tuples.arity = r.arity && tuples.universe = this.universe - * @ensures this.relations' = this.relations + r this.lowerBound' = - * this.lowerBound' ++ r->tuples && this.upperBound' = this.lowerBound' - * ++ r->tuples - * @throws NullPointerException r = null || tuples = null - * @throws IllegalArgumentException tuples.arity != r.arity || tuples.universe - * != this.universe - */ - public void boundExactly(Relation r, TupleSet tuples) { - checkBound(r.arity(), tuples); - final TupleSet unmodifiableTuplesCopy = tuples.clone().unmodifiableView(); - putBound(lowers, r, unmodifiableTuplesCopy); - putBound(uppers, r, unmodifiableTuplesCopy); - } - - /** - * Sets the lower and upper bounds for the given relation. - * - * @requires lower.tuples in upper.tuples && lower.arity = upper.arity = r.arity - * && lower.universe = upper.universe = this.universe - * @ensures this.relations' = this.relations + r && this.lowerBound' = - * this.lowerBound ++ r->lower && this.upperBound' = this.upperBound ++ - * r->upper - * @throws NullPointerException r = null || lower = null || upper = null - * @throws IllegalArgumentException lower.arity != r.arity || upper.arity != - * r.arity - * @throws IllegalArgumentException lower.universe != this.universe || - * upper.universe != this.universe - * @throws IllegalArgumentException lower.tuples !in upper.tuples - */ - public void bound(Relation r, TupleSet lower, TupleSet upper) { - if (!upper.containsAll(lower)) - throw new IllegalArgumentException("lower.tuples !in upper.tuples"); - if (upper.size() == lower.size()) { - // upper.containsAll(lower) && upper.size()==lower.size() => - // upper.equals(lower) - boundExactly(r, lower); - } else { - checkBound(r.arity(), lower); - checkBound(r.arity(), upper); - putBound(lowers, r, lower.clone().unmodifiableView()); - putBound(uppers, r, upper.clone().unmodifiableView()); - } - } - - /** - * Makes the specified tupleset the upper bound on the contents of the given - * relation. The lower bound automatically becomen an empty tupleset with the - * same arity as the relation. - * - * @requires upper.arity = r.arity && upper.universe = this.universe - * @ensures this.relations' = this.relations + r this.lowerBound' = - * this.lowerBound ++ r->{s: TupleSet | s.universe = this.universe && - * s.arity = r.arity && no s.tuples} && this.upperBound' = - * this.upperBound ++ r->upper - * @throws NullPointerException r = null || upper = null - * @throws IllegalArgumentException upper.arity != r.arity || upper.universe != - * this.universe - */ - public void bound(Relation r, TupleSet upper) { - checkBound(r.arity(), upper); - putBound(lowers, r, factory.noneOf(r.arity()).unmodifiableView()); - putBound(uppers, r, upper.clone().unmodifiableView()); - } - - /** - * Makes the specified tupleset an exact bound on the relational value that - * corresponds to the given integer. - * - * @requires ibound.arity = 1 && i.bound.size() = 1 - * @ensures this.intBound' = this.intBound' ++ i -> ibound - * @throws NullPointerException ibound = null - * @throws IllegalArgumentException ibound.arity != 1 || ibound.size() != 1 - * @throws IllegalArgumentException ibound.universe != this.universe - */ - public void boundExactly(int i, TupleSet ibound) { - checkBound(1, ibound); - if (ibound.size() != 1) - throw new IllegalArgumentException("ibound.size != 1: " + ibound); - intbounds.put(i, ibound.clone().unmodifiableView()); - } - - /** - * Creates atom relations for all atoms present in this Bounds for which - * corresponding atom relations don't already exist. - */ - public void ensureAtomRelations() { - for (Object atom : universe()) { - if (getAtomExpr(atom, atom2rel) == null) { - Relation ar = Relation.atom(atom.toString()); - boundExactly(ar, factory.setOf(atom)); - } - } - } - - public Expression ts2expr(TupleSet tset) { - if (tset == null) - return Expression.NONE; - Expression tsetExpr = null; - for (Tuple t : tset) { - Expression tupleExpr = null; - for (int i = 0; i < t.arity(); i++) { - Expression atomRel = ensureAtomExpr(t.atom(i)); - tupleExpr = tupleExpr == null ? atomRel : tupleExpr.product(atomRel); - } - tsetExpr = tsetExpr == null ? tupleExpr : tsetExpr.union(tupleExpr); - } - return (tsetExpr == null) ? Expression.NONE : tsetExpr; - } - - public static Expression getAtomExpr(Object atom, Map atom2rel) { - if (atom instanceof Integer) - return IntConstant.constant((Integer) atom).toExpression(); - if (atom instanceof String) { - try { - return IntConstant.constant(Integer.parseInt(atom.toString())).toExpression(); - } catch (NumberFormatException e) {} - } - Relation rel = atom2rel != null ? atom2rel.get(atom) : null; - return rel; - } - - /** - * Returns an unmodifiable view of this Bounds object. - * - * @return an unmodifiable view of his Bounds object. - */ - public Bounds unmodifiableView() { - return new Bounds(factory, unmodifiableMap(lowers), unmodifiableMap(uppers), unmodifiableSequence(intbounds)); - } - - /** - * Returns a deep (modifiable) copy of this Bounds object. - * - * @return a deep (modifiable) copy of this Bounds object. - */ - @Override - public Bounds clone() { - try { - return new Bounds(factory, new LinkedHashMap(lowers), new LinkedHashMap(uppers), intbounds.clone()); - } catch (CloneNotSupportedException cnse) { - throw new InternalError(); // should not be reached - } - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder str = new StringBuilder(); - str.append("relation bounds:"); - for (Map.Entry entry : lowers.entrySet()) { - TupleSet upper = uppers.get(entry.getKey()); - str.append("\n "); - str.append(entry.getKey()); - str.append(": (").append(entry.getValue().size()).append(", ").append(upper.size()).append(") :"); - str.append(": ["); - str.append(entry.getValue()); - if (!upper.equals(entry.getValue())) { - str.append(", "); - str.append(upper); - } - str.append("]"); - } - str.append("\nint bounds: "); - str.append("\n "); - str.append(intbounds); - return str.toString(); - } - - private void putBound(Map map, Relation r, TupleSet tset) { - map.put(r, tset); - if (r.isAtom() && System.identityHashCode(map) == System.identityHashCode(uppers)) - addAtomRel(r, tset); - } - - private void addAtomRel(Relation rel, TupleSet val) { - if (!rel.isAtom()) - return; - assert val.size() == 1 : String.format("atom relation '%s' evaluates to more than one tuple: %s", rel, val); - assert val.arity() == 1 : String.format("atom relation '%s' evaluates to a non-unary tuple set: %s", rel, val); - atom2rel.put(val.iterator().next().atom(0), rel); - } - - private Expression ensureAtomExpr(Object atom) { - Expression ans = getAtomExpr(atom, atom2rel); - if (ans == null) - throw new InternalError("No relation found for atom '" + atom + "'"); - return ans; - } - - public Relation findRelByName(String name) { - for (Relation r : relations()) - if (r.name().equals(name)) - return r; - return null; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Instance.java b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Instance.java deleted file mode 100644 index c313a5040..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Instance.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.instance; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Relation; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - * Represents a model (an instance) of a relational formula, which is a mapping - * from {@link kodkod.ast.Relation relations} and integers to - * {@link kodkod.instance.TupleSet sets of tuples} drawn from a given - * {@link kodkod.instance.Universe universe}. - * - * @specfield universe: Universe - * @specfield relations: set Relation - * @specfield tuples: (relations -> one TupleSet) + (int -> lone TupleSet) - * @invariant all r: tuples.TupleSet & Relation | r.arity = tuples[r].arity && - * tuples[r].universe = universe - * @invariant all i: tuples.TupleSet & int | ints[i].arity = 1 && ints[i].size() - * = 1 - * @author Emina Torlak - */ -public final class Instance implements Cloneable { - - private final Map tuples; - private final SparseSequence ints; - private final Universe universe; - - private Instance(Universe u, Map tuples, SparseSequence ints) { - if (u == null) - throw new NullPointerException("universe=null"); - this.universe = u; - this.tuples = tuples; - this.ints = ints; - } - - /** - * Constructs an empty instance over the given universe - * - * @ensures this.universe' = universe && no this.tuples' - * @throws NullPointerException universe = null - */ - public Instance(final Universe universe) { - this(universe, new LinkedHashMap(), new TreeSequence()); - } - - /** - * Returns the universe from which the tuples in this instance are drawn. - * - * @return this.universe - */ - public Universe universe() { - return universe; - } - - /** - * Returns true if this instance maps the given relation to a set of tuples; - * otherwise returns false. - * - * @return r in this.relations - */ - public boolean contains(Relation relation) { - return tuples.containsKey(relation); - } - - /** - * Returns true if this instance maps the given integer to a singleton tupleset; - * otherwise returns false. - * - * @return some this.tuples[i] - */ - public boolean contains(int i) { - return ints.containsIndex(i); - } - - /** - * Returns the relations mapped by this instance. The returned set does not - * support addition. It supports remval if this is not an unmodifiable instance. - * - * @return this.relations - */ - public Set relations() { - return tuples.keySet(); - } - - public Collection skolems() { - Set rels = relations(); - ArrayList ans = new ArrayList(rels.size()); - for (Relation r : rels) - if (r.isSkolem()) - ans.add(r); - return ans; - } - - /** - * Returns the integers mapped by this instance. The returned set does not - * support addition. It supports remval if this is not an unmodifiable instance. - * - * @return this.ints.TupleSet - */ - public IntSet ints() { - return ints.indices(); - } - - /** - * Maps the given relation to the given tuple set. - * - * @ensures this.tuples' = this.tuples ++ relation->s - * @throws NullPointerException relation = null || s = null - * @throws IllegalArgumentException relation.arity != s.arity - * @throws IllegalArgumentException s.universe != this.universe - * @throws UnsupportedOperationException this is an unmodifiable instance - */ - public void add(final Relation relation, TupleSet s) { - if (!s.universe().equals(universe)) - throw new IllegalArgumentException("s.universe!=this.universe"); - if (relation.arity() != s.arity()) - throw new IllegalArgumentException("relation.arity!=s.arity"); - TupleSet val = s.clone().unmodifiableView(); - tuples.put(relation, val); - } - - /** - * Maps the given integer to the given tuple set. - * - * @ensures this.tuples' = this.tuples ++ i->s - * @throws NullPointerException s = null - * @throws IllegalArgumentException s.arity != 1 || s.size() != 1 - * @throws IllegalArgumentException s.universe != this.universe - * @throws UnsupportedOperationException this is an unmodifiable instance - */ - public void add(int i, TupleSet s) { - if (!s.universe().equals(universe)) - throw new IllegalArgumentException("s.universe!=this.universe"); - if (s.arity() != 1) - throw new IllegalArgumentException("s.arity!=1: " + s); - if (s.size() != 1) - throw new IllegalArgumentException("s.size()!=1: " + s); - ints.put(i, s.clone().unmodifiableView()); - } - - /** - * Returns the set of tuples assigned to the given relation by this Instance. If - * the relation is not mapped by the model, null is returned. - * - * @return this.tuples[relation] - */ - public TupleSet tuples(Relation relation) { - return tuples.get(relation); - } - - public TupleSet tuples(String relationName) { - Relation rel = findRelationByName(relationName); - if (rel == null) - return null; - return tuples(rel); - } - - public Relation findRelationByName(String relationName) { - for (Relation rel : relations()) - if (rel.name().equals(relationName)) - return rel; - return null; - } - - /** - * Returns a map view of Relation<:this.tuples. The returned map is - * unmodifiable. - * - * @return a map view of Relation<:this.tuples. - */ - public Map relationTuples() { - return Collections.unmodifiableMap(tuples); - } - - /** - * Returns the set of tuples assigned to the given integer by this Instance. If - * the integer is not mapped by the model, null is returned. - * - * @return this.tuples[i] - */ - public TupleSet tuples(int i) { - return ints.get(i); - } - - /** - * Returns a sparse sequence view of int<:this.tuples. The returned sequence is - * unmodifiable. - * - * @return a sparse sequence view of int<:this.tuples. - */ - public SparseSequence intTuples() { - return Ints.unmodifiableSequence(ints); - } - - /** - * Returns an unmodifiable view of this instance. - * - * @return an unmodifiable view of this instance. - */ - public Instance unmodifiableView() { - return new Instance(universe, Collections.unmodifiableMap(tuples), Ints.unmodifiableSequence(ints)); - } - - /** - * Returns a deep copy of this Instance object. - * - * @return a deep copy of this Instance object. - */ - @Override - public Instance clone() { - try { - return new Instance(universe, new LinkedHashMap(tuples), ints.clone()); - } catch (CloneNotSupportedException cnse) { - throw new InternalError(); // should not be reached - } - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "relations: " + tuples.toString() + "\nints: " + ints; - } - - public String toPrettyString() { - StringBuilder sb = new StringBuilder(); - for (Relation r : relations()) { - TupleSet val = tuples(r); - sb.append(r.name()).append(" = [").append(val.size()).append("] ").append(val).append("\n"); - } - return sb.toString(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Tuple.java b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Tuple.java deleted file mode 100644 index fa680d895..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Tuple.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.instance; - -/** - * Represents a sequence of atoms drawn from a given - * {@link kodkod.instance.Universe universe}. Note that a Tuple of arity n whose - * atoms belong to a Universe u encodes an n-digit number in base u.size. The - * decimal representation of this number is taken to be the index of the tuple - * in an n-dimensional space over the Universe u. - * - * @specfield arity: int - * @specfield universe: Universe - * @specfield atoms: [0..arity)->one Object - * @invariant atoms[int] in universe.atoms[int] - * @author Emina Torlak - */ -public abstract class Tuple { - - /** - * Returns the universe from which the atoms in this tuple are drawn. - * - * @return this.universe - */ - public abstract Universe universe(); - - /** - * Returns the arity of this tuple. - * - * @return this.arity - */ - public abstract int arity(); - - /** - * A Tuple encodes a number with this.arity digits in radix this.universe.size; - * a Tuple's index is the decimal representation of this number. - * - * @return sum({i: [0..arity) | universe.index(atoms[i]) * universe.size^(arity - * - 1 - i)}) - */ - public abstract int index(); - - /** - * Returns the atom at the specified index - * - * @return this.atoms[i] - * @throws IndexOutOfBoundsException i < 0 || i >= this.arity - */ - public abstract Object atom(int i); - - /** - * Returns the index of the ith atom as given by this.universe. The effect of - * this method is the same as calling this.universe.index(this.atom(i)). - * - * @return this.universe.index(this.atoms[i]) - * @throws IndexOutOfBoundsException i < 0 || i >= this.arity - */ - public abstract int atomIndex(int i); - - /** - * Returns true if atom is in this tuple, otherwise returns false. - * - * @return atom in this.atoms[int] - * @throws IllegalArgumentException atom !in this.universe.atoms[int] - */ - public abstract boolean contains(Object atom); - - /** - * Returns the cross product of this and the specified tuple. - * - * @return {t : Tuple | t.atoms = this.atoms->tuple.atoms} - * @throws NullPointerException tuple = null - * @throws IllegalArgumentException tuple.universe != this.universe - */ - public abstract Tuple product(Tuple tuple); - - /** - * Returns true if o is a tuple with the same sequence of atoms as this, drawn - * from the same universe as this. Otherwise returns false. - * - * @return o in Tuple && o.universe = this.universe && o.atoms = this.atoms - */ - @Override - public boolean equals(Object o) { - if (this == o) - return true; - else if (o instanceof Tuple) { - final Tuple t = (Tuple) o; - return universe().equals(t.universe()) && arity() == t.arity() && index() == t.index(); - } else - return false; - } - - /** - * Returns a hash code based on the tuple's arity, index, and the hash code of - * its universe, so that the general contract of Object.hashCode is obeyed. - * - * @return the hashcode for this tuple - */ - @Override - public int hashCode() { - return (arity() * 19 + index()) ^ universe().hashCode(); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder ret = new StringBuilder("["); - ret.append(atom(0)); - for (int i = 1; i < arity(); i++) { - ret.append(", "); - ret.append(atom(i)); - } - ret.append("]"); - return ret.toString(); - - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/TupleFactory.java b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/TupleFactory.java deleted file mode 100644 index ce114dbf4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/TupleFactory.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.instance; - -import java.util.Collection; -import java.util.List; - -import kodkod.engine.CapacityExceededException; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * A factory class that facilitates creation of tuples and tuple sets drawn from - * a given universe. Only one factory per universe exists. - * - * @specfield universe: Universe - * @invariant no f: TupleFactory - this | f.universe = this.universe - * @author Emina Torlak - */ -public final class TupleFactory { - - private final Universe universe; - private final int base; - - /** - * Constructs a factory for the given universe. - * - * @requires no (TupleFactory<:universe).universe - * @ensures this.universe' = universe - * @throws NullPointerException universe = null - */ - TupleFactory(Universe universe) { - this.universe = universe; - this.base = universe.size(); - } - - /** - * Returns the universe to which this factory belongs. - * - * @return this.universe - */ - public Universe universe() { - return universe; - } - - /** - * Returns a tuple that contains the specified sequence of atoms, drawn from - * this.universe. - * - * @return {t: Tuple | t.universe = this.universe && t.atoms = atoms } - * @throws NullPointerException atoms = null - * @throws IllegalArgumentException atoms.length < 1 - * @throws IllegalArgumentException some a: atoms[int] | a !in - * this.universe.atoms[int] - */ - public Tuple tuple(Object... atoms) { - if (atoms.length < 1) - throw new IllegalArgumentException("atoms.length<1"); - return new IntTuple(atoms); - } - - /** - * Returns a tuple that contains the specified sequence of atoms, drawn from - * this.universe. - * - * @return {t: Tuple | t.universe = this.universe && t.atoms = atoms } - * @throws NullPointerException atoms = null - * @throws IllegalArgumentException atoms.size < 1 - * @throws IllegalArgumentException some a: atoms[int] | a !in - * this.universe.atoms[int] - */ - public Tuple tuple(List< ? > atoms) { - if (atoms.size() < 1) - throw new IllegalArgumentException("atoms.size()<1"); - return new IntTuple(atoms.toArray()); - } - - /** - * Returns a tuple with the specified arity whose index in an arity-dimensional - * space over this.universe is given by the index parameter. - * - * @return {t: Tuple | t.universe = this.universe && t.arity = arity && index = - * sum({i : [0..arity) | universe.index(t.atoms[i]) * - * universe.size^(arity - 1 - i))}) } - * @throws IllegalArgumentException arity < 1 || index < 0 || index >= - * universe.size^arity - */ - public Tuple tuple(final int arity, final int index) { - return new IntTuple(arity, index); - } - - /** - * Returns a set of all tuples of the given arity, drawn from this.universe. - * - * @return { s: TupleSet | s.universe = this.universe && s.arity = arity && - * s.tuples = {t: Tuple | t.universe = this.universe && t.arity = arity} - * } - * @throws IllegalArgumentException arity < 1 - */ - public TupleSet allOf(int arity) { - return new TupleSet(universe, arity, 0, ((int) Math.pow(base, arity)) - 1); - } - - /** - * Returns a set of tuples of arity 1, each of which wraps one of the given - * objects. The method requires that the specified object be atoms in - * this.universe. - * - * @return {s: TupleSet | s.universe = this.universe && s.arity = 1 && s.tuples - * = { t: Tuple | t.universe=this.universe && t.arity=1 && t.atoms[0] in - * atoms[int]}} - * @throws NullPointerException atoms = null - * @throws IllegalArgumentException some atoms[int] - this.universe.atoms[int] - */ - public TupleSet setOf(Object... atoms) { - final TupleSet ret = new TupleSet(universe, 1); - for (Object atom : atoms) { - ret.add(new IntTuple(atom)); - } - return ret; - } - - /** - * Returns a tuple set consisting of specified tuples. The method requires that - * all given tuples have the same arity and be drawn from this.universe. - * - * @return {s: TupleSet | s.universe = this.universe && s.arity = first.arity && - * s.tuples = first + rest[int] } - * @throws NullPointerException first = null || rest = null - * @throws IllegalArgumentException first.universe != this.universe - * @throws IllegalArgumentException some t: rest[int] | t.universe != - * this.universe || t.arity != first.arity - */ - public TupleSet setOf(Tuple first, Tuple... rest) { - if (!first.universe().equals(universe)) - throw new IllegalArgumentException("first.universe != this.universe"); - - final TupleSet ret = new TupleSet(universe, first.arity(), first.index(), first.index()); - for (Tuple tuple : rest) { - ret.add(tuple); - } - return ret; - } - - /** - * Returns a tuple set consisting of specified tuples. The method requires that - * all given tuples have the same arity and be drawn from this.universe. - * - * @return {s: TupleSet | s.universe = this.universe && s.arity = first.arity && - * s.tuples = tuples } - * @throws NullPointerException tuples = null - * @throws IllegalArgumentException tuples.isEmpty() - * @throws IllegalArgumentException tuples.universe != this.universe || - * #tuples.arity > 1 - */ - public TupleSet setOf(Collection tuples) { - if (tuples.isEmpty()) - throw new IllegalArgumentException("tuples.isEmpty()"); - final TupleSet ret = new TupleSet(universe, tuples.iterator().next().arity()); - for (Tuple t : tuples) { - ret.add(t); - } - return ret; - } - - /** - * Returns a set of the given arity that contains all tuples whose indeces are - * contained in the given int set. Throws an IllegalArgumentException if the set - * contains an index that is either negative or greater than - * this.universe.size()^arity - 1. The returned TupleSet is backed by a clone of - * tupleIndices. - * - * @requires tupleIndices is cloneable - * @return {s: TupleSet | s.universe = this.universe && s.arity = arity && - * s.tuples = {t: Tuple | t.index() in tupleIndices} } - * @throws NullPointerException tupleIndices = null - * @throws IllegalArgumentException tupleIndices is uncloneable - * @throws IllegalArgumentException arity < 1 - * @throws IllegalArgumentException tupleIndices.min() < 0 || tupleIndices.max() - * >= this.universe.size()^arity - */ - public TupleSet setOf(int arity, IntSet tupleIndices) { - try { - return new TupleSet(universe, arity, tupleIndices.clone()); - } catch (CloneNotSupportedException cne) { - throw new IllegalArgumentException("uncloneable int set"); - } - } - - /** - * Returns an initially empty tuple set of the given arity, based on - * this.universe. - * - * @return { s: TupleSet | s.universe = this.universe && s.arity = arity && no - * s.tuples } - * @throws IllegalArgumentException arity < 1 - */ - public TupleSet noneOf(int arity) { - return new TupleSet(universe, arity); - } - - /** - * Returns a tuple set that contains all tuples between from and - * to, inclusive. More formally, the returned set contains all - * tuples whose indices are in the range [from.index()..to.index()]. - * - * @return { s: TupleSet | s.universe = this.universe && s.arity = from.arity && - * s.tuples = {t: Tuple | t.universe = this.universe && t.arity = - * s.arity && from.index()<=t.index()<=to.index() }} - * @throws NullPointerException from = null || to = null - * @throws IllegalArgumentException from.arity != to.arity - * @throws IllegalArgumentException from.universe != this.universe || - * to.universe != this.universe - * @throws IllegalArgumentException from.index > to.index - */ - public TupleSet range(Tuple from, Tuple to) { - if (from.arity() != to.arity()) - throw new IllegalArgumentException("from.arity!=to.arity"); - if (!(from.universe().equals(universe) && to.universe().equals(universe))) - throw new IllegalArgumentException("from.universe != this.universe || to.universe != this.universe"); - return new TupleSet(universe, from.arity(), from.index(), to.index()); - } - - /** - * Returns a tuple set that contains all tuples in the specified area of the - * n-dimensional space, where n is the arity of the argument tuples. For - * example, suppose that this.universe consists of atoms {atom0, atom1, atom2, - * atom3}, where atom0 has index 0, atom1 has index 1, etc. Calling this method - * with tuples [atom0, atom2] and [atom1, atom3] as the first and second - * arguments would result in the set {[atom0, atom2], [atom0,atom3], - * [atom1,atom2], [atom1, atom3]}. That is, the returned set consists of all - * points in the rectangle whose upper left corner is the point [atom0, atom2] - * and whose lower right corner is at [atom1, atom3]. - * - * @return {s: TupleSet | s.arity = upperLeft.arity && s.universe = - * this.universe && s.tuples = {t: Tuple | all i: [0..s.arity) | - * this.universe.index(upperLeft.atoms[i]) <= - * this.universe.index(t.atoms[i]) <= - * this.universe.index(lowerRight.atoms[i]}} - * @throws NullPointerException upperLeft = null || lowerRight = null - * @throws IllegalArgumentException upperLeft.arity != lowerRight.arity - * @throws IllegalArgumentException lowerRight.universe != this.universe || - * upperLeft.universe != this.universe - * @throws IllegalArgumentException some i: [0..upperLeft.arity) | - * this.universe.index(upperLeft.atoms[i]) > - * this.universe.index(lowerRight.atoms[i]) - */ - public TupleSet area(Tuple upperLeft, Tuple lowerRight) { - if (!upperLeft.universe().equals(universe) || upperLeft.arity() != lowerRight.arity()) - throw new IllegalArgumentException(); - TupleSet ret = new TupleSet(universe, 1, upperLeft.atomIndex(0), lowerRight.atomIndex(0)); - for (int i = 1; i < upperLeft.arity(); i++) { - ret = ret.product(new TupleSet(universe, 1, upperLeft.atomIndex(i), lowerRight.atomIndex(i))); - } - return ret; - } - - /** - * Throws a CapacityExceededException if all tuples of the given arity drawn - * from this.universe cannot be represented as an integer. - * - * @throws CapacityExceededException if all tuples of the given arity drawn from - * this.universe cannot be represented as an integer. - */ - void checkCapacity(int arity) { - if (StrictMath.pow(base, arity) > Integer.MAX_VALUE) { - throw new CapacityExceededException("Arity too large (" + arity + ") for a universe of size " + universe.size(), Ints.nCopies(arity, base)); - } - } - - /** - * Projects the tuple with the specified index and arity onto the specified - * column. - * - * @requires tupleIndex >= 0 && tupleIndex < this.universe.size() ^ arity - * @return this.universe.index(this.tuple(arity, tupleIndex).atoms[i]) - */ - int project(int tupleIndex, int arity, int column) { - if (column < 0 || column >= arity) - throw new IndexOutOfBoundsException(column + ""); - return (tupleIndex / ((int) Math.pow(base, arity - 1 - column))) % base; - } - - /** - * An implementation of the Tuple interface that stores only the tuple's arity - * and index, rather than the full sequence of atoms. Parts of the sequence are - * computed on demand, e.g. when the get method is invoked. - * - * @specfield universe: TupleFactory.this.universe - * @specfield arity: int - * @specfield index: int - * @invariant arity >= 1 && 0 <= index < TupleFactory.this.base^arity - * @invariant index = sum({i: [0..arity) | - * TupleFactory.this.universe.index(atoms[i]) * - * TupleFactory.this.base^(arity - 1 - i)) - * @author Emina Torlak - */ - private final class IntTuple extends Tuple { - - private final int arity, index; - - /** - * Constructs a tuple with the specified arity and index, whose atoms are drawn - * from the factory's universe. - * - * @ensures this.arity' = arity && this.index' = index - * @throws IllegalArgumentException arity < 1 || index < 0 || index >= - * TupleFactory.this.base^arity - */ - IntTuple(final int arity, final int index) { - checkCapacity(arity); - if (arity < 1 || index < 0 || index >= Math.pow(base, arity)) { - throw new IllegalArgumentException("arity < 1 || index < 0 || index >= universe.size^arity"); - } - this.arity = arity; - this.index = index; - } - - /** - * Constructs a tuple that contains the specified sequence of atoms, drawn from - * the enclosing factory's universe. - * - * @requires atoms.length > 0 - * @ensures this.atoms' = atoms - * @throws NullPointerException atoms = null - * @throws IllegalArgumentException some a: atoms[int] | a !in - * universe.atoms[int] - */ - IntTuple(final Object... atoms) { - this.arity = atoms.length; - checkCapacity(arity); - int tempIndex = 0, multiplier = 1; - for (int i = arity - 1; i >= 0; i--) { - tempIndex += universe.index(atoms[i]) * multiplier; - multiplier *= base; - } - this.index = tempIndex; - assert this.index >= 0; - } - - /** - * Constructs a tuple with the specified arity, with the specified atom at each - * position. - * - * @ensures this.arity' = arity && this.atoms = [0..arity)->atom - * @throws NullPointerException atom = null - * @throws IllegalArgumentException arity < 1 || atom !in - * this.universe.atoms[int] - */ - @SuppressWarnings("unused" ) - IntTuple(final int arity, final Object atom) { - checkCapacity(arity); - if (arity < 1) - throw new IllegalArgumentException("arity < 1"); - this.arity = arity; - int tempIndex = 1; - for (int i = 0; i < arity; i++) { - tempIndex = tempIndex * base + 1; - } - this.index = universe.index(atom) * tempIndex; - assert this.index >= 0; - } - - /** {@inheritDoc} */ - @Override - public Universe universe() { - return universe; - } - - /** {@inheritDoc} */ - @Override - public int arity() { - return arity; - } - - /** {@inheritDoc} */ - @Override - public int index() { - return index; - } - - /** {@inheritDoc} */ - @Override - public Object atom(int i) { - return universe.atom(atomIndex(i)); - } - - /** {@inheritDoc} */ - @Override - public int atomIndex(int i) { - return project(index, arity, i); - // if (i < 0 || i >= arity) throw new IndexOutOfBoundsException("i < - // 0 || i >= this.arity"); - // return (index / ((int) Math.pow(base, arity-1-i))) % base; - } - - /** {@inheritDoc} */ - @Override - public boolean contains(Object atom) { - for (int remainder = index, atomIndex = universe.index(atom); remainder > 0; remainder = remainder / base) { - if (remainder % base == atomIndex) - return true; - } - return false; - } - - /** {@inheritDoc} */ - @Override - public Tuple product(Tuple tuple) { - if (!universe.equals(tuple.universe())) - throw new IllegalArgumentException("tuple.universe != this.universe"); - return new IntTuple(arity + tuple.arity(), index * ((int) Math.pow(base, tuple.arity())) + tuple.index()); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/TupleSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/TupleSet.java deleted file mode 100644 index bbced69a2..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/TupleSet.java +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.instance; - -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; - -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.Ints; - -/** - * Represents a set of {@link kodkod.instance.Tuple tuples} of a given arity, - * constructed over a given {@link kodkod.instance.Universe universe}. All - * polymorphic methods throw a ClassCastException when passed an element that is - * not a Tuple. All methods throw a NullPointerException when passed null. The - * iterator of a TupleSet returns tuples in the order of their - * {@link kodkod.instance.Tuple#index() indeces}. - * - * @specfield tuples: set Tuple - * @specfield universe: Universe - * @specfield arity: int - * @invariant tuples.arity = arity && tuples.universe = universe - * @author Emina Torlak - */ -public final class TupleSet extends AbstractSet implements Cloneable { - - private final Universe universe; - private final int arity; - private final IntSet tuples; - private IntSet indexView = null; - - /** - * Constructs an empty tuple set for storing tuples of the specified arity, over - * the given universe. - * - * @ensures this.universe' = universe && this.arity' = arity && no this.tuples' - * @throws NullPointerException universe = null - * @throws IllegalArgumentException arity < 1 - */ - TupleSet(Universe universe, int arity) { - if (arity < 1) - throw new IllegalArgumentException("arity < 1"); - universe.factory().checkCapacity(arity); - this.universe = universe; - this.arity = arity; - tuples = Ints.bestSet(capacity()); - } - - /** - * Constructs a tuple set of the given arity, over the specified universe, which - * initially contains all tuples whose indeces are between fromIndex and - * toIndex, inclusive. - * - * @ensures this.universe' = universe && this.arity' = arity && this.tuples' = - * {t: Tuple | t.universe=universe && t.arity=arity && - * fromIndex()<=t.index()<=toIndex() } - * @throws NullPointerException universe = null - * @throws IllegalArgumentException arity < 1 || - * @throws IndexOutOfBoundsException fromIndex !in [0..toIndex] || toIndex !in - * [0..universe.size()^arity - 1] - */ - TupleSet(Universe universe, int arity, int fromIndex, int toIndex) { - this(universe, arity); - checkRange(toIndex, 0, capacity() - 1); - checkRange(fromIndex, 0, toIndex); - for (int i = fromIndex; i <= toIndex; i++) { - tuples.add(i); - } - } - - /** - * Returns a set of the given arity that contains all tuples whose indeces are - * contained in the given int set. Throws an IllegalArgumentException if the set - * contains an index that is either negative or greater than - * this.universe.size()^arity - 1. An attempt to iterate over a tuple set backed - * by an invalid index set will result in a runtime exception. - * - * @return {s: TupleSet | s.universe = this.universe && s.arity = arity && - * s.tuples = {t: Tuple | t.index() in tupleIndeces} } - * @throws NullPointerException tupleIndeces = null - * @throws IllegalArgumentException arity < 1 - * @throws IllegalArgumentException tupleIndeces.min() < 0 || tupleIndeces.max() - * >= this.universe.size()^arity - */ - TupleSet(Universe universe, int arity, IntSet tupleIndeces) { - if (arity < 1) - throw new IllegalArgumentException("arity < 1"); - universe.factory().checkCapacity(arity); - this.universe = universe; - this.arity = arity; - if (!tupleIndeces.isEmpty()) { - if (tupleIndeces.min() < 0 || tupleIndeces.max() >= capacity()) - throw new IllegalArgumentException(tupleIndeces.min() + "<0 || " + tupleIndeces.max() + ">=" + universe.size() + "^" + arity); - } - tuples = tupleIndeces; - } - - /** - * Copy constructor. - * - * @ensures constructs a deep copy of the given tupleset - */ - private TupleSet(TupleSet original) { - this.universe = original.universe; - this.arity = original.arity; - try { - this.tuples = original.tuples.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code - } - this.indexView = null; - } - - /** - * Throws an IndexOutOfBoundsException if index is not in [min..max] - */ - private final void checkRange(int index, int min, int max) { - if (index < min || index > max) - throw new IndexOutOfBoundsException(index + " !in " + "[" + min + ".." + max + "]"); - } - - /** - * Returns the capacity of this set -- the maximum number of tuples that it can - * hold, given its universe and arity. - * - * @return this.universe.size() ^ this.arity - */ - public final int capacity() { - return (int) StrictMath.pow(universe.size(), arity); - } - - /** - * Returns this.universe. - * - * @return this.universe - */ - public Universe universe() { - return universe; - } - - /** - * Returns this.arity - * - * @return this.arity - */ - public int arity() { - return arity; - } - - /** - * Returns an unmodifiable int set view of the tuples stored in this set. - * Specifically, the returned int set contains an integer i iff this set - * contains a tuple with the index i. The view is backed by this set, so changes - * to this set are reflected in the index set. - * - * @return { s: IntSet | s.ints = {i: int | some t: this.tuples | t.index = i} - */ - public IntSet indexView() { - if (indexView == null) { - indexView = Ints.unmodifiableIntSet(tuples); - } - return indexView; - } - - /** - * Returns an unmodifiable view of the this tupleset. This method allows modules - * to provide "read-only" access to internal tuple sets. Query operations on the - * returned set "read through" to the specified set, and attempts to modify the - * returned set, whether direct or via its iterator, result in an - * UnsupportedOperationException. - * - * @return an unmodifiable view of the this tupleset - */ - public TupleSet unmodifiableView() { - return new TupleSet(universe, arity, indexView()); - } - - /** - * Returns a tuple set that is the cross product of this and the specified set. - * - * @return {t: TupleSet | t.arity = this.arity + s.arity && t.universe = - * this.universe && t.tuples = this.tuples->s.tuples } - * @throws NullPointerException s = null - * @throws IllegalArgumentException s.universe != this.universe - */ - public TupleSet product(TupleSet s) { - if (!s.universe().equals(universe)) - throw new IllegalArgumentException("s.universe != this.universe"); - final TupleSet ret = new TupleSet(universe, arity + s.arity()); - if (!s.isEmpty()) { - final int mCapacity = (int) StrictMath.pow(universe.size(), s.arity); - for (IntIterator indeces0 = tuples.iterator(); indeces0.hasNext();) { - int i0 = mCapacity * indeces0.next(); - for (IntIterator indeces1 = s.tuples.iterator(); indeces1.hasNext();) { - ret.tuples.add(i0 + indeces1.next()); - } - } - } - return ret; - } - - /** - * Projects this TupleSet onto the given dimension. - * - * @return {s: TupleSet | s.arity = 1 && s.universe = this.universe && s.tuples - * = { t: Tuple | some q: this.tuples | q.atoms[dimension] = - * t.atoms[int] } } - * @throws IllegalArgumentException dimension < 0 || dimension >= this.arity - */ - public TupleSet project(int dimension) { - if (dimension < 0 || dimension >= arity) { - throw new IllegalArgumentException("dimension < 0 || dimension >= this.arity"); - } - final IntSet projection = Ints.bestSet(universe.size()); - final TupleFactory factory = universe.factory(); - for (IntIterator indexIter = tuples.iterator(); indexIter.hasNext();) { - projection.add(factory.project(indexIter.next(), arity, dimension)); - } - return new TupleSet(universe, 1, projection); - } - - /** - * Returns a deep copy of this tuple set. - * - * @return {s: TupleSet - this | s.universe = this.universe && s.tuples = - * this.tuples } - */ - @Override - public TupleSet clone() { - // ok to use a copy constructor to clone a final class - return new TupleSet(this); - } - - /** - * Returns an iterator over the tuples in this tupleset. - * - * @return an iterator over the tuples in this tupleset. - */ - @Override - public Iterator iterator() { - return new Iterator() { - - IntIterator indexIter = tuples.iterator(); - - @Override - public boolean hasNext() { - return indexIter.hasNext(); - } - - @Override - public Tuple next() { - return universe.factory().tuple(arity, indexIter.next()); - } - - @Override - public void remove() { - indexIter.remove(); - } - }; - } - - /** - * Returns the index of the given tuple, if the tuple has the same arity and - * universe as this. Otherwise throws an IllegalArgumentException. - * - * @return t.index - * @throws IllegalArgumentException t.arity != this.arity || t.universe != - * this.universe - */ - private final int extractIndex(Tuple t) { - if (t.arity() != arity || !t.universe().equals(universe)) { - throw new IllegalArgumentException("t.arity != this.arity || t.universe != this.universe"); - } - return t.index(); - } - - /** - * Returns true if this contains the given object. - * - * @return o in this.tuples - * @throws IllegalArgumentException o.arity != this.arity || o.universe != - * this.universe - */ - @Override - public boolean contains(Object o) { - return tuples.contains(extractIndex((Tuple) o)); - } - - /** - * Returns the size of this tupleset. - * - * @return #this.tuples - */ - @Override - public int size() { - return tuples.size(); - } - - /** - * Removes all tuples from this tupleset. - * - * @ensures no this.tuples' - */ - @Override - public void clear() { - tuples.clear(); - } - - /** - * Adds the specified tuple to this tupleset. Returns true if this set was - * changed as the result of the operation. - * - * @ensures this.tuples' = this.tuples + t - * @return o !in this.tuples - * @throws IllegalArgumentException t.universe != this.universe || t.arity != - * this.arity - */ - @Override - public boolean add(Tuple t) { - return tuples.add(extractIndex(t)); - } - - /** - * Removes the given object from this tupleset, if present, and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.tuples' = this.tuples - o - * @return o in this.tuples - * @throws IllegalArgumentException o.universe != this.universe || o.arity != - * this.arity - */ - @Override - public boolean remove(Object o) { - return tuples.remove(extractIndex((Tuple) o)); - } - - /** - * If c is not a TupleSet or it is a tupleset with a universe different than - * this.universe, returns null. Otherwise, returns the tuples associated with - * the modifiable view of c. - * - * @requires c in TupleSet => c.arity = this.arity - * @return c in TupleSet && c.universe = this.universe && c.arity = this.arity - * => c.tuples, null - * @throws NullPointerException s = null - * @throws IllegalArgumentException this.arity!=s.arity - */ - private IntSet extractTuples(Collection< ? > c) { - if (c instanceof TupleSet) { - final TupleSet s = (TupleSet) c; - if (arity != s.arity()) - throw new IllegalArgumentException("this.arity!=c.arity"); - return universe.equals(s.universe()) ? s.tuples : null; - } - return null; - } - - /** - * Returns true if this contains all tuples from c. Otherwise returns false. - * - * @return c.elements in this.tuples - * @throws IllegalArgumentException some t: c.elements | t.universe != - * this.universe || t.arity != this.arity - */ - @Override - public boolean containsAll(Collection< ? > c) { - final IntSet cTuples = extractTuples(c); - return cTuples == null ? super.containsAll(c) : tuples.containsAll(cTuples); - } - - /** - * Adds all tuples from c to this, if not present, and returns true. Otherwise - * does nothing and returns false. - * - * @ensures this.tuples' = this.tuples + c.elements - * @return c.elements !in this.tuples - * @throws IllegalArgumentException some t: c.elements | t.universe != - * this.universe || t.arity != this.arity - */ - @Override - public boolean addAll(Collection< ? extends Tuple> c) { - final IntSet cTuples = extractTuples(c); - return cTuples == null ? super.addAll(c) : tuples.addAll(cTuples); - } - - /** - * Removes all tuples in c from this, if present, and returns true. Otherwise - * does nothing and returns false. - * - * @ensures this.tuples' = this.tuples - c.elements - * @return some c.elements & this.tuples - * @throws IllegalArgumentException some t: c.elements | t.universe != - * this.universe || t.arity != this.arity - */ - @Override - public boolean removeAll(Collection< ? > c) { - final IntSet cTuples = extractTuples(c); - return cTuples == null ? super.removeAll(c) : tuples.removeAll(cTuples); - } - - /** - * Removes all tuples from this that are not in c, if any, and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.tuples' = this.tuples & c.elements - * @return this.tuples !in c.elements - * @throws IllegalArgumentException some t: c.elements | t.universe != - * this.universe || t.arity != this.arity - */ - @Override - public boolean retainAll(Collection< ? > c) { - final IntSet cTuples = extractTuples(c); - return cTuples == null ? super.retainAll(c) : tuples.retainAll(cTuples); - } - - /** - * Returns true if o contains the same tuples as this. - * - * @return this.tuples = o.elements - */ - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o instanceof TupleSet) { - final TupleSet s = (TupleSet) o; - return arity == s.arity && universe.equals(s.universe) && tuples.equals(s.tuples); - } - return super.equals(o); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return tuples.hashCode(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Universe.java b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Universe.java deleted file mode 100644 index 3e3c51b0f..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/Universe.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.instance; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import kodkod.util.collections.Containers; - -/** - *

- * Represents an ordered set of unique atoms. Objects used as atoms must - * properly implement {@link java.lang.Object#equals equals} and - * {@link java.lang.Object#hashCode hashCode} methods. The behavior of a - * universe is not specified if the value of an object is changed in a manner - * that affects equals comparisons while the object is an atom in the universe. - *

- *

- * Each universe provides a {@link kodkod.instance.TupleFactory tuple factory} - * to facilitate creation of {@link kodkod.instance.Tuple tuples} and - * {@link kodkod.instance.TupleSet sets of tuples} based on the atoms in the - * universe. - *

- *

- * Implementation Note: although the atoms in a universe are not - * interpreted in any way by the Kodkod engine, it is strongly recommended that - * the atoms of the same 'type' be grouped together. For instance, suppose that - * a client model is specified in terms of disjoint types Person = {Person0, - * Person1, Person2} and Dog = {Dog0, Dog1}. Then, the client may observe an - * improvement in performance if he constructs the universe over the sequences - * {Person0, Person1, Person2, Dog0, Dog1} or {Dog0, Dog1, Person0, Person1, - * Person2} rather than any other permutation of these five atoms. - * - * @specfield size: int - * @specfield atoms: [0..size)->one Object - * @specfield factory: TupleFactory - * @invariant factory = (TupleFactory<:universe).this - * @invariant size > 0 - * @author Emina Torlak - */ -public final class Universe implements Iterable { - - private final Object[] atoms; - private final Map indices; - private final TupleFactory factory; - - /** - * Constructs a new Universe consisting of the given atoms, in the order that - * they are returned by the specified Collection's Iterator. - * - * @ensures this.size' = atoms.size && this.atoms' = atoms.iterator - * @throws NullPointerException atoms = null - * @throws IllegalArgumentException atoms contains duplicates - * @throws IllegalArgumentException atoms is empty - */ - public Universe(Collection< ? > atoms) { - if (atoms.isEmpty()) - throw new IllegalArgumentException("Cannot create an empty universe."); - this.atoms = new Object[atoms.size()]; - this.indices = new HashMap(); - int i = 0; - for (Object atom : atoms) { - if (indices.containsKey(atom)) - throw new IllegalArgumentException(atom + " appears multiple times."); - indices.put(atom, i); - this.atoms[i] = atom; - i++; - } - this.factory = new TupleFactory(this); - } - - /** - * Constructs a new Universe consisting of the given atoms, in the order that - * they appear in the specified array - * - * @ensures this.size' = atoms.length && this.atoms' = atoms - * @throws NullPointerException atoms = null - * @throws IllegalArgumentException atoms contains duplicates - * @throws IllegalArgumentException atoms is empty - */ - public Universe(Object... atoms) { - if (atoms.length == 0) - throw new IllegalArgumentException("Cannot create an empty universe."); - this.atoms = Containers.copy(atoms, new Object[atoms.length]); - this.indices = new HashMap(); - for (int i = 0; i < atoms.length; i++) { - if (indices.containsKey(atoms[i])) - throw new IllegalArgumentException(atoms[i] + " appears multiple times."); - indices.put(atoms[i], i); - } - this.factory = new TupleFactory(this); - } - - /** - * // * Returns a universe that stores the given atoms explicitly, in the - * specified order. // * The returned universe provides constant time index and - * atom lookup. // * @ensures { u: Universe | u.size = atoms.length && u.atoms = - * atoms } // * @throws IllegalArgumentException atoms contains duplicates // - * * @throws IllegalArgumentException atoms is empty // - */ - // public static Universe universe(Object...atoms) { return new - // ExplicitUniverse(atoms); } - // - // /** - // * Returns a universe that stores the given atoms explicitly, in the order - // in which they - // * are returned by the collection's iterator. The returned universe - // provides constant - // * time index and atom lookup. - // * @ensures { u: Universe | u.size = atoms.size() && u.atoms[int] = atoms - // } - // * @throws IllegalArgumentException atoms contains duplicates - // * @throws IllegalArgumentException atoms is empty - // */ - // public static Universe universe(Collection atoms) { return new - // ExplicitUniverse(atoms); } - - /** - * Returns a TupleFactory that can be used to construct tuples and sets of - * tuples based on this universe. - * - * @return this.factory - */ - public TupleFactory factory() { - return this.factory; - } - - /** - * Returns the size of this universe - * - * @return #this.atoms - */ - public int size() { - return atoms.length; - } - - /** - * Returns true if atom is in this universe, otherwise returns false. - * - * @return atom in this.atoms[int] - */ - public boolean contains(Object atom) { - return indices.containsKey(atom); - } - - /** - * Returns the i_th atom in this universe - * - * @return this.atoms[i] - * @throws IndexOutOfBoundsException i < 0 || i >= this.size - */ - public Object atom(int index) { - if (index < 0 || index >= atoms.length) - throw new IndexOutOfBoundsException("Invalid universe index: " + index); - return atoms[index]; - } - - /** - * Returns the index of the specified atom in this universe; if the atom is not - * in this universe, an IllegalArgumentException is thrown. - * - * @return this.atoms.atom - * @throws IllegalArgumentException no this.atoms.atom - */ - public int index(Object atom) { - if (indices.containsKey(atom)) - return indices.get(atom); - else - throw new IllegalArgumentException("No such atom in the universe: " + atom); - } - - /** - * Returns an iterator over atoms in this universe, according to their order in - * the universe. - * - * @return an iterator over atoms in this universe, according to their order in - * the universe - */ - @Override - public Iterator iterator() { - return Containers.iterate(atoms); - } - - /** - * Returns a string representation of this universe. - * - * @return string representation of this universe. - */ - @Override - public String toString() { - return Arrays.toString(atoms); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/package.html deleted file mode 100644 index ade655f53..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/package.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - -Contains classes for creating tuples, sets of tuples, bounds, and instances -drawn from a finite universe of uninterpreted atoms. - -

Package Specification

- -

Contains classes for creating {@linkplain kodkod.instance.Tuple tuples}, -{@linkplain kodkod.instance.TupleSet sets of tuples}, {@linkplain kodkod.instance.Bounds bounds}, and -{@linkplain kodkod.instance.Instance instances} drawn from a finite -{@linkplain kodkod.instance.Universe universe} of uninterpreted atoms.

- -

Related Documentation

- -@see kodkod.instance.Universe -@see kodkod.instance.TupleFactory -@see kodkod.instance.Bounds -@see kodkod.instance.Instance - - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/instance/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/instance/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/ArrayStack.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/ArrayStack.java deleted file mode 100644 index ef09effa0..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/ArrayStack.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.EmptyStackException; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * A Stack implementation based on an array. - * - * @author Emina Torlak - */ -public class ArrayStack extends Stack { - - /* - * stack elements: the last element in the array is at the top of the stack. - */ - private T[] elems; - private int size; - - /** - * Constructs an empty stack with the inital capacity of 10. - * - * @ensures no this.elems' - */ - public ArrayStack() { - this(10); - } - - @SuppressWarnings("unchecked" ) - public ArrayStack(int initialCapacity) { - if (initialCapacity < 0) - throw new IllegalArgumentException(initialCapacity + "<0"); - elems = (T[]) new Object[initialCapacity]; - size = 0; - } - - /** - * Increases the capacity of this ArrayStack, if necessary, to ensure that it - * can hold at least the number of elements specified by the minimum capacity - * argument. - */ - @SuppressWarnings("unchecked" ) - public void ensureCapacity(int minCapacity) { - final int oldCapacity = elems.length; - if (minCapacity > oldCapacity) { - final T[] oldElems = elems; - elems = (T[]) new Object[StrictMath.max(minCapacity, (oldCapacity * 3) / 2)]; - System.arraycopy(oldElems, 0, elems, 0, size); - } - } - - /** - * Trims the capacity of this ArrayStack to be the stack's current size. An - * application can use this operation to minimize the storage of an ArrayStack - * instance. - */ - @SuppressWarnings("unchecked" ) - public void trimToSize() { - final int oldCapacity = elems.length; - if (size < oldCapacity) { - final Object oldElems[] = elems; - elems = (T[]) new Object[size]; - System.arraycopy(oldElems, 0, elems, 0, size); - } - } - - /** - * @see kodkod.util.collections.Stack#size() - */ - @Override - public int size() { - return size; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.collections.Stack#push - */ - @Override - public T push(T item) { - ensureCapacity(size + 1); - elems[size++] = item; - return item; - } - - /** - * @see kodkod.util.collections.Stack#pop() - */ - @Override - public T pop() { - if (empty()) - throw new EmptyStackException(); - final T top = elems[--size]; - elems[size] = null; - return top; - } - - /** - * @see kodkod.util.collections.Stack#peek() - */ - @Override - public T peek() { - if (empty()) - throw new EmptyStackException(); - return elems[size - 1]; - } - - /** - * @see kodkod.util.collections.Stack#search(java.lang.Object) - */ - @Override - public int search(Object o) { - for (int i = size - 1; i >= 0; i--) { - if (equal(o, elems[i])) - return i; - } - return -1; - } - - /** - * @see kodkod.util.collections.Stack#empty() - */ - @Override - public boolean empty() { - return size == 0; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.collections.Stack#iterator() - */ - @Override - public Iterator iterator() { - return new Iterator() { - - int cursor = size - 1, lastReturned = -1; - - @Override - public boolean hasNext() { - return cursor >= 0; - } - - @Override - public T next() { - if (cursor < 0) - throw new NoSuchElementException(); - lastReturned = cursor; - return elems[cursor--]; - } - - @Override - public void remove() { - if (lastReturned < 0) - throw new UnsupportedOperationException(); - size--; - System.arraycopy(elems, lastReturned + 1, elems, lastReturned, size - lastReturned); - elems[size] = null; - lastReturned = -1; - } - - }; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/CacheSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/CacheSet.java deleted file mode 100644 index a75678502..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/CacheSet.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * Implements the Set interface, backed by a hash table. It makes no - * guarantees as to the iteration order of the set; in particular, it does not - * guarantee that the order will remain constant over time. This class does not - * permit the null element. - *

- * This class offers constant time performance for the basic operations - * (add, remove, contains and size), - * assuming the hash function disperses the elements properly among the buckets. - * Iterating over this set requires time proportional to the sum of the - * HashSet instance's size (the number of elements) plus the "capacity" - * of the backing map (the number of buckets). Thus, it's very important not to - * set the initial capacity too high (or the load factor too low) if iteration - * performance is important. - *

- *

- * This set differs from Java's HashSet in that it provides methods for - * retrieving elements with a particular hashcode. This makes it easy - * to set as a cache in which cached objects' hashcodes are their keys. - *

- *

- * Note that this implementation is not synchronized. The iterators - * returned by this class's iterator method are not fail-fast - *

- * - * @specfield elts: set T - * @author Emina Torlak - */ -public final class CacheSet extends AbstractSet { - - /* - * implementation adapted from java.util.HashMap and java.util.HashSet - */ - /** - * The default initial capacity - MUST be a power of two. - */ - private static final int DEFAULT_INITIAL_CAPACITY = 16; - - /** - * The maximum capacity, used if a higher value is implicitly specified by - * either of the constructors with arguments. MUST be a power of two <= 1<<30. - */ - private static final int MAXIMUM_CAPACITY = 1 << 30; - - /** - * The load factor used when none specified in constructor. - **/ - private static final float DEFAULT_LOAD_FACTOR = 0.75f; - - /** - * The table, resized as necessary. Length MUST Always be a power of two. - */ - private Entry[] table; - - /** - * The number of key-value mappings contained in this identity hash map. - */ - private int size; - - /** - * The next size value at which to resize (capacity * load factor). - */ - private int threshold; - - /** - * The load factor for the hash table. - */ - final float loadFactor; - - /** - * Constructs a new, empty set; the backing map has default initial capacity - * (16) and load factor (0.75). - * - * @ensures no this.elts' - */ - @SuppressWarnings("unchecked" ) - public CacheSet() { - loadFactor = DEFAULT_LOAD_FACTOR; - threshold = (int) (DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR); - table = new Entry[DEFAULT_INITIAL_CAPACITY]; - } - - /** - * Constructs a new, empty set; the backing map has the specified initial - * capacity and the specified load factor. - * - * @param initialCapacity the initial capacity of the hash map. - * @param loadFactor the load factor of the hash map. - * @throws IllegalArgumentException if the initial capacity is less than zero, - * or if the load factor is nonpositive. - * @ensures no this.elts' - */ - @SuppressWarnings("unchecked" ) - public CacheSet(int initialCapacity, float loadFactor) { - if (initialCapacity < 0) - throw new IllegalArgumentException("Illegal initial capacity: " + initialCapacity); - if (initialCapacity > MAXIMUM_CAPACITY) - initialCapacity = MAXIMUM_CAPACITY; - if (loadFactor <= 0 || Float.isNaN(loadFactor)) - throw new IllegalArgumentException("Illegal load factor: " + loadFactor); - - // Find a power of 2 >= initialCapacity - int capacity = 1; - while (capacity < initialCapacity) - capacity <<= 1; - - this.loadFactor = loadFactor; - threshold = (int) (capacity * loadFactor); - table = new Entry[capacity]; - } - - /** - * Constructs a new set containing the elements in the specified collection. The - * HashMap is created with default load factor (0.75) and an initial - * capacity sufficient to contain the elements in the specified collection. - * - * @param c the collection whose elements are to be placed into this set. - * @throws NullPointerException if the specified collection is null. - */ - public CacheSet(Collection< ? extends E> c) { - this(c.size(), .75f); - addAll(c); - } - - /** - * Returns a hash value for the specified integer. The shift distances in this - * function were chosen as the result of an automated search over the entire - * four-dimensional search space. - */ - private static int hash(int h) { - h += ~(h << 9); - h ^= (h >>> 14); - h += (h << 4); - h ^= (h >>> 10); - return h; - } - - /** - * Returns a hash value for the specified object. In addition to the object's - * own hashCode, this method applies a "supplemental hash function," which - * defends against poor quality hash functions. This is critical because HashMap - * uses power-of two length hash tables. - *

- * The shift distances in this function were chosen as the result of an - * automated search over the entire four-dimensional search space. - */ - private static int hash(Object x) { - return hash(x.hashCode()); - } - - /** - * Returns index for hash code h. - */ - private static int indexFor(int h, int length) { - return h & (length - 1); - } - - /** - * Returns the number of elements in this set. - * - * @return #this.elts - * @see java.util.Set#size() - */ - @Override - public int size() { - return size; - } - - /** - * Returns true if this set is empty. - * - * @return no this.elts - * @see java.util.Set#isEmpty() - */ - @Override - public boolean isEmpty() { - return size == 0; - } - - /** - * Returns true if this set contains the given element. - * - * @return elt in this.elts - * @throws NullPointerException elt = null - * @see java.util.Set#contains(java.lang.Object) - */ - @Override - public boolean contains(Object elt) { - Entry e = table[indexFor(hash(elt), table.length)]; - while (e != null) { - if (e.val.equals(elt)) - return true; - e = e.next; - } - return false; - } - - /** - * Returns an iterator over the elements in this set. - * - * @return an iterator over this.elts. - * @see java.util.Set#iterator() - */ - @Override - public Iterator iterator() { - return new SetIterator(); - } - - /** - * Adds the given element to this set, if not already present. - * - * @ensures this.elts' = this.elts + elt - * @throws NullPointerException elt = null - * @return elt !in this.elts - */ - @Override - public boolean add(E elt) { - final int i = indexFor(hash(elt), table.length); - - for (Entry e = table[i]; e != null; e = e.next) { - if (e.val.equals(elt)) { - return false; - } - } - - table[i] = new Entry(elt, table[i]); - if (size++ >= threshold) - resize(2 * table.length); - - return true; - } - - /** - * Rehashes the contents of this map into a new array with a larger capacity. - * This method is called automatically when the number of keys in this map - * reaches its threshold. If current capacity is MAXIMUM_CAPACITY, this method - * does not resize the map, but sets threshold to Integer.MAX_VALUE. This has - * the effect of preventing future calls. - * - * @param newCapacity the new capacity, MUST be a power of two; must be greater - * than current capacity unless current capacity is MAXIMUM_CAPACITY - * (in which case value is irrelevant). - */ - @SuppressWarnings("unchecked" ) - private void resize(int newCapacity) { - Entry[] oldTable = table; - int oldCapacity = oldTable.length; - if (oldCapacity == MAXIMUM_CAPACITY) { - threshold = Integer.MAX_VALUE; - return; - } - - Entry[] newTable = new Entry[newCapacity]; - transfer(newTable); - table = newTable; - threshold = (int) (newCapacity * loadFactor); - } - - /** - * Transfer all entries from current table to newTable. - */ - private void transfer(Entry[] newTable) { - Entry[] src = table; - int newCapacity = newTable.length; - for (int j = 0; j < src.length; j++) { - Entry e = src[j]; - if (e != null) { - src[j] = null; - do { - Entry next = e.next; - int i = indexFor(hash(e.val), newCapacity); - e.next = newTable[i]; - newTable[i] = e; - e = next; - } - while (e != null); - } - } - } - - /** - * Removes the specified object from this set, if present. - * - * @ensures this.elts' = this.elts - elt - * @return elt in this.elts - * @throws NullPointerException elt = null - * @see java.util.Set#remove(java.lang.Object) - */ - @Override - public boolean remove(Object elt) { - int i = indexFor(hash(elt), table.length); - Entry prev = table[i]; - Entry e = prev; - - while (e != null) { - Entry next = e.next; - if (e.val.equals(elt)) { - size--; - if (prev == e) - table[i] = next; - else - prev.next = next; - return true; - } - prev = e; - e = next; - } - - return false; - - } - - /** - * Returns an iterator over the elements whose hashcode() method returns the - * given hash. - * - * @return an iterator over {e: this.elts | e.hashCode() = hash } - */ - public Iterator get(final int hash) { - final int i = indexFor(hash(hash), table.length); - return new Iterator() { - - Entry current = null, next = table[i]; - - @Override - public boolean hasNext() { - while (next != null && next.val.hashCode() != hash) { - next = next.next; - } - return next != null; - } - - @Override - public E next() { - if (!hasNext()) - throw new NoSuchElementException(); - current = next; - next = next.next; - return current.val; - } - - @Override - public void remove() { - if (current == null) - throw new IllegalStateException(); - Entry prev = table[i]; - Entry e = prev; - - while (e.next != current) { - prev = e; - e = e.next; - } - - size--; - if (prev == e) - table[i] = next; - else - prev.next = next; - current = null; - } - - }; - } - - /** - * Removes all elements from this set. - * - * @ensures no this.elts' - * @see java.util.Set#clear() - */ - @Override - public void clear() { - for (int i = 0; i < table.length; i++) - table[i] = null; - size = 0; - } - - private static final class Entry { - - Entry next; - T val; - - Entry(T val, Entry next) { - this.val = val; - this.next = next; - } - } - - private final class SetIterator implements Iterator { - - Entry next; // next entry to return - int index; // current slot - Entry current; // current entry - - SetIterator() { - index = table.length; - next = null; - if (size != 0) { // advance to first entry - while (index > 0 && (next = table[--index]) == null) - ; - } - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public E next() { - Entry e = next; - if (e == null) - throw new NoSuchElementException(); - - Entry n = e.next; - while (n == null && index > 0) - n = table[--index]; - next = n; - return (current = e).val; - - } - - @Override - public void remove() { - if (current == null) - throw new IllegalStateException(); - - CacheSet.this.remove(current.val); - current = null; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Containers.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Containers.java deleted file mode 100644 index a70a3c6fd..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Containers.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.AbstractSet; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.NoSuchElementException; -import java.util.Set; - -/** - * Provides utility methods for working with arrays and collections. - * - * @author Emina Torlak - */ -public final class Containers { - - private static Comparator identityComparator; - private static Comparator hashComparator; - - private Containers() {} - - /** - * Returns a new iterator over the given array of items. The iterator is backed - * by the given array. The contents of the array are not modified by the - * iterator. The effect of this method is the same as calling - * Iterators.iterator(0, items.length, items). - * - * @throws NullPointerException items = null - */ - @SafeVarargs - public static final Iterator iterate(final E... items) { - return new AscendingArrayIterator(0, items.length, items); - } - - /** - * Returns a new iterator over the given array of items. The iterator is backed - * by the given array. The contents of the array are not modified by the - * iterator. The returned iterator enumerates the items located between indeces - * start, inclusive, and end, exclusive. If start < end, the elements are - * returned in the ascending order; otherwise, they are returned in the - * descending order. - * - * @throws NullPointerException items = null - * @throws IllegalArgumentException start < end && (start < 0 || end > - * items.length) || start > end && (start >= items.length || end < - * -1) - */ - @SafeVarargs - public static final Iterator iterate(int start, int end, final E... items) { - if (start < end) - return new AscendingArrayIterator(start, end, items); - else if (start > end) - return new DescendingArrayIterator(start, end, items); - else - return emptyIterator(); - } - - /** - * Returns an iterator that has no elements. That is, calls to hasNext will - * return false, and all other calls will result in a runtime exception. - * - * @return an empty iterator - */ - @SuppressWarnings("unchecked" ) - public static final Iterator emptyIterator() { - return (Iterator) Collections.emptySet().iterator(); - } - - /** - * Calls System.arraycopy(src, srcPos, dest, destPos, length) and returns the - * destination array. - * - * @ensures System.arraycopy(src, srcPos, dest, destPos, length) - * @return dest - */ - public static final T[] copy(T[] src, int srcPos, T[] dest, int destPos, int length) { - System.arraycopy(src, srcPos, dest, destPos, length); - return dest; - } - - /** - * Calls System.arraycopy(src, 0, dest, 0, src.length) and returns the - * destination array. - * - * @requires dest.length >= src.length - * @ensures System.arraycopy(src, 0, dest, 0, src.length) - * @return dest - */ - public static final T[] copy(T[] src, T[] dest) { - System.arraycopy(src, 0, dest, 0, src.length); - return dest; - } - - /** - * Returns a comparator that compares objects according to their - * {@link System#identityHashCode(Object) identity hashcodes}. - * - * @return a comparator that compares objects according to their - * {@link System#identityHashCode(Object) identity hashcodes}. - */ - public static final Comparator identityComparator() { - if (identityComparator == null) { - identityComparator = new Comparator() { - - @Override - public int compare(Object o1, Object o2) { - final int c1 = System.identityHashCode(o1); - final int c2 = System.identityHashCode(o2); - return c1 == c2 ? 0 : (c1 < c2 ? -1 : 1); - } - }; - } - return identityComparator; - } - - /** - * Returns 0 if o is null, otherwise returns o.hashCode(). - * - * @return o=null => 0, o.hashCode() - */ - static final int hash(Object o) { - return o == null ? 0 : o.hashCode(); - } - - /** - * Returns true if both o1 and o2 are null or if o1.equals(o2) - * - * @return true if both o1 and o2 are null or if o1.equals(o2) - */ - static final boolean eq(Object o1, Object o2) { - return o1 == null ? o2 == null : o1.equals(o2); - } - - /** - * Returns a comparator that compares objects according to their - * {@link Object#hashCode() hashcodes}. The null reference is considered to have - * a hashcode of 0. - * - * @return a comparator that compares objects according to their - * {@link Object#hashCode() hashcodes}. - */ - public static final Comparator hashComparator() { - if (hashComparator == null) { - hashComparator = new Comparator() { - - @Override - public int compare(Object o1, Object o2) { - final int c1 = hash(o1); - final int c2 = hash(o2); - return c1 == c2 ? 0 : (c1 < c2 ? -1 : 1); - } - }; - } - return hashComparator; - } - - /** - * Calls {@link java.util.Arrays#sort(Object[], Comparator)} on the given array - * and returns it. The elements are sorted in the ascending order of their - * identity hashcodes. - * - * @ensures java.util.Arrays.sort(array, {@link #identityComparator()}) - * @return the given array, with its elements sorted in the increasing order of - * identity hashcodes - */ - public static final T[] identitySort(T[] array) { - java.util.Arrays.sort(array, identityComparator()); - return array; - } - - /** - * Calls {@link java.util.Arrays#sort(Object[], Comparator)} on the given array - * and returns it. The elements are sorted in the ascending order of their - * hashcodes. - * - * @ensures java.util.Arrays.sort(array, {@link #hashComparator()}) - * @return the given array, with its elements sorted in the increasing order of - * hashcodes - */ - public static final T[] hashSort(T[] array) { - java.util.Arrays.sort(array, hashComparator()); - return array; - } - - /** - * Searches the specified array for the specified object using the binary search - * algorithm and reference equality. The array must be sorted into ascending - * order according to the identity hashcodes of its elements (as by - * {@link #identitySort(Object[])}) prior to making this call. If it is not - * sorted, the results are undefined. If the array contains multiple occurences - * of the specified object, there is no guarantee which one will be found. - * - * @requires all i, j: [0..array.length) | i < j => array[i].hashCode() <= - * array[j].hashCode()) - * @return index of the search key, if it is contained in the array; otherwise, - * (-(insertion point) - 1). The insertion point is defined as the point - * at which the key would be inserted into the array: the index of the - * first element greater than the key, or array.length, if all elements - * in the array are less than the specified key. Note that this - * guarantees that the return value will be >= 0 if and only if the key - * is found. - */ - public static final int identityBinarySearch(Object[] array, Object key) { - int low = 0; - int high = array.length - 1; - int index = System.identityHashCode(key); - - while (low <= high) { - int mid = (low + high) >>> 1; - int midIndex = System.identityHashCode(array[mid]); - if (midIndex < index) - low = mid + 1; - else if (midIndex > index) - high = mid - 1; - else { // index found, now check that variables are the same - if (array[mid] == key) - return mid; - // check all variables with the same index (if any) - for (int i = mid + 1; i < array.length && System.identityHashCode(array[i]) == index; i++) { - if (array[i] == key) - return i; - } - for (int i = mid - 1; i >= 0 && System.identityHashCode(array[i]) == index; i--) { - if (array[i] == key) - return i; - } - return -(mid + 1); // var not found - } - } - - return -(low + 1); // key not found. - } - - /** - * Searches the specified array for the specified object using the binary search - * algorithm and object equality. The array must be sorted into ascending order - * according to the hashcodes of its elements (as by - * {@link #hashSort(Object[])}) prior to making this call. If it is not sorted, - * the results are undefined. If the array contains multiple occurences of the - * specified object, there is no guarantee which one will be found. - * - * @requires all i, j: [0..array.length) | i < j => - * System.identityHashCode(array[i]) <= - * System.identityHashCode(array[j]) - * @return index of the search key, if it is contained in the array; otherwise, - * (-(insertion point) - 1). The insertion point is defined as the point - * at which the key would be inserted into the array: the index of the - * first element greater than the key, or array.length, if all elements - * in the array are less than the specified key. Note that this - * guarantees that the return value will be >= 0 if and only if the key - * is found. - */ - public static final int hashBinarySearch(Object[] array, Object key) { - int low = 0; - int high = array.length - 1; - int index = hash(key); - - while (low <= high) { - int mid = (low + high) >>> 1; - int midIndex = hash(array[mid]); - if (midIndex < index) - low = mid + 1; - else if (midIndex > index) - high = mid - 1; - else { // index found, now check that variables are the same - if (eq(array[mid], key)) - return mid; - // check all variables with the same index (if any) - for (int i = mid + 1; i < array.length && hash(array[i]) == index; i++) { - if (eq(array[i], key)) - return i; - } - for (int i = mid - 1; i >= 0 && hash(array[i]) == index; i--) { - if (eq(array[i], key)) - return i; - } - return -(mid + 1); // var not found - } - } - - return -(low + 1); // key not found. - } - - /** - * Returns an identity set backed by the given array (i.e. a set that uses - * reference equality for comparisons). The array must contain no duplicates, - * its elements must be sorted in the increasing order of identity hashcodes (as - * by {@link #identitySort(Object[])}), and its contents must not be changed - * while it is in use by the returned set. - * - * @requires all i, j: [0..array.length) | i < j => - * System.identityHashCode(array[i]) <= - * System.identityHashCode(array[j]) - * @return an unmodifiable identity Set view of the given array - */ - public static final Set asIdentitySet(final T[] array) { - return new AbstractSet() { - - @Override - public boolean contains(Object o) { - return identityBinarySearch(array, o) >= 0; - } - - @Override - public Iterator iterator() { - return iterate(array); - } - - @Override - public int size() { - return array.length; - } - - @Override - public int hashCode() { - int result = 0; - for (Object o : array) { - result += System.identityHashCode(o); - } - return result; - } - }; - } - - /** - * Returns a set backed by the given array (i.e. a set that uses object equality - * for comparisons). The array must contain no duplicates, its elements must be - * sorted in the increasing order of hashcodes (as by - * {@link #hashSort(Object[])}), and its contents must not be changed while it - * is in use by the returned set. - * - * @requires all i, j: [0..array.length) | i < j => array[i].hashCode() <= - * array[j].hashCode - * @return an unmodifiable Set view of the given array - */ - public static final Set asHashSet(final T[] array) { - return new AbstractSet() { - - @Override - public boolean contains(Object o) { - return hashBinarySearch(array, o) >= 0; - } - - @Override - public Iterator iterator() { - return iterate(array); - } - - @Override - public int size() { - return array.length; - } - }; - } - - /** - * Returns a new set that contains the asymmetric difference between the left - * and the right sets. - * - * @return some s: Set | s.elements = left.elements - right.elements - */ - public static final Set setDifference(Set left, Set right) { - final Set ret = new LinkedHashSet(left); - ret.removeAll(right); - return ret; - } - - /** - * An unmodifying iterator over an array. - */ - private static abstract class ArrayIterator implements Iterator { - - final T[] items; - final int end; - int cursor; - - /** - * Constructs a new iterator over the given array of items. The iterator is - * backed by the given array. The contents of the array are not modified by the - * iterator. The constructed iterator returns the items located between the - * indeces start, inclusive, and end, exclusive. - * - * @requires items != null && start < end => end in [0..items.length] && start - * in [0..end], start in [0..items.length) && end in [-1..start] - */ - @SafeVarargs - ArrayIterator(int start, int end, final E... items) { - this.items = items; - this.cursor = start; - this.end = end; - } - - @Override - public final void remove() { - throw new UnsupportedOperationException(); - } - } - - /** - * An ascending iterator over an array. - */ - private static final class AscendingArrayIterator extends ArrayIterator { - - /** - * Constructs a new iterator over the given array of items. - * - * @requires items != null && start < end - * @throws IllegalArgumentException start < 0 || end > items.length - */ - AscendingArrayIterator(int start, int end, E[] items) { - super(start, end, items); - if (start < 0 || end > items.length) { - throw new IllegalArgumentException("start < end && (start < 0 || end > items.length)"); - } - } - - @Override - public boolean hasNext() { - return cursor >= 0 && cursor < end; - } - - @Override - public T next() { - if (!hasNext()) - throw new NoSuchElementException(); - return items[cursor++]; - } - } - - /** - * A descending iterator over an array. - */ - private static final class DescendingArrayIterator extends ArrayIterator { - - /** - * Constructs a new iterator over the given array of items. - * - * @requires items != null && start > end - * @throws IllegalArgumentException start >= items.length || end < -1 - */ - DescendingArrayIterator(int start, int end, E[] items) { - super(start, end, items); - if (start >= items.length || end < -1) { - throw new IllegalArgumentException("start > end && (start >= items.length || end < -1)"); - } - } - - @Override - public boolean hasNext() { - return cursor > end; - } - - @Override - public T next() { - if (!hasNext()) - throw new NoSuchElementException(); - return items[cursor--]; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/FixedMap.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/FixedMap.java deleted file mode 100644 index da1b3ee85..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/FixedMap.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -/** - * A map with a fixed set of keys that acts as an indexer, assigning a unique - * integer in the range [0..#keys) to each key. This class implements the - * Map interface with an array, using reference-equality in place of - * object-equality when comparing keys (and values). In other words, in a - * FixedMap, two keys k1 and k2 are considered equal - * if and only if (k1==k2). (In normal Map implementations - * (like HashMap) two keys k1 and k2 are considered - * equal if and only if (k1==null ? k2==null : k1.equals(k2)).) - *

- *

- * This class is not a general-purpose Map implementation! - * While this class implements the Map interface, it intentionally - * violates Map's general contract, which mandates the use of the - * equals method when comparing objects. - *

- *

- * This class provides {@link #put(Object, Object)} operation for the keys - * within its fixed key set and permits null values and the - * null key. The {@link #remove(Object)} operation is not supported. - * This class guarantees that the order of the map will remain constant over - * time. - *

- *

- * This class provides log-time performance for the basic operations - * (get and put), assuming the system identity hash function - * ({@link System#identityHashCode(Object)}) disperses elements properly among - * the buckets. - *

- *

- * This implementation is not synchronized, and its iterators are not fail-fast. - *

- * - * @specfield keys: set K - * @specfield map: keys -> one V - * @specfield indices: keys lone->one [0..#keys) - * @author Emina Torlak - */ -public final class FixedMap extends AbstractMap implements Indexer { - - private final Object[] keys; - private final Object[] values; - - /** - * Constructs a new fixed map from the given map. - * - * @ensures this.keys' = keys && this.map = map.map - */ - public FixedMap(Map map) { - this(map.keySet()); - for (int i = 0, size = map.size(); i < size; i++) { - values[i] = map.get(keys[i]); - } - } - - /** - * Constructs a new fixed map for the given set of keys. - * - * @ensures this.keys' = keys && no this.map' - */ - public FixedMap(Set keys) { - final int size = keys.size(); - this.keys = Containers.identitySort(keys.toArray(new Object[size])); - values = new Object[size]; - } - - /** - * Constructs a new fixed map, backed by the given array of keys. The provided - * array must not contain duplicates, its entries must be sorted in the - * increasing order of identity hashcodes, and it must not be modified while in - * use by this map. The map will not behave correctly if these requirements are - * violated. - * - * @requires no disj i, j: [0..keys.length) | keys[i] == keys[j] - * @requires all i, j: [0..keys.length) | i < j => - * System.identityHashCode(keys[i]) <= - * System.identityHashCode(keys[j]) - * @ensures this.keys' = keys && no this.map' - */ - public FixedMap(K[] keys) { - this.keys = keys; - this.values = new Object[keys.length]; - } - - /** - * Returns the index of the given key, if it is in this.keys. Otherwise returns - * a negative number. - * - * @return key in this.keys => this.indices[key], {i: int | i < 0 } - */ - @Override - public final int indexOf(K key) { - return Containers.identityBinarySearch(keys, key); - } - - /** - * Returns the key at the given index. - * - * @return this.indices.index - * @throws IndexOutOfBoundsException index !in this.indices[this.keys] - */ - @Override - @SuppressWarnings("unchecked" ) - public final K keyAt(int index) { - try { - return (K) keys[index]; - } catch (ArrayIndexOutOfBoundsException e) { - throw new IndexOutOfBoundsException(); - } - } - - /** - * Tests whether the specified object reference is a key in this fixed map. - * - * @return key in this.keys - */ - @Override - @SuppressWarnings("unchecked" ) - public final boolean containsKey(Object key) { - return indexOf((K) key) >= 0; - } - - /** - * Tests whether the specified object reference is a value in this fixed map. - * - * @return value in this.map[this.keys] - */ - @Override - public final boolean containsValue(Object value) { - for (Object o : values) { - if (o == value) - return true; - } - return false; - } - - /** - * Returns a set view of the mappings contained in this map. Each element in the - * returned set is a reference-equality-based Map.Entry. The set is - * backed by the map, so changes to the map are reflected in the set, and - * vice-versa. If the map is modified while an iteration over the set is in - * progress, the results of the iteration are undefined. The set does support - * neither removal nor addition. - *

- * Like the backing map, the Map.Entry objects in the set returned by - * this method define key and value equality as reference-equality rather than - * object-equality. This affects the behavior of the equals and - * hashCode methods of these Map.Entry objects. A - * reference-equality based Map.Entry - * e is equal to an object o if and only if o is a - * Map.Entry and e.getKey()==o.getKey() && - * e.getValue()==o.getValue(). To accommodate these equals semantics, the - * hashCode method returns System.identityHashCode(e.getKey()) ^ - * System.identityHashCode(e.getValue()). - *

- * Owing to the reference-equality-based semantics of the Map.Entry - * instances in the set returned by this method, it is possible that the - * symmetry and transitivity requirements of the {@link Object#equals(Object)} - * contract may be violated if any of the entries in the set is compared to a - * normal map entry, or if the set returned by this method is compared to a set - * of normal map entries (such as would be returned by a call to this method on - * a normal map). However, the Object.equals contract is guaranteed to - * hold among identity-based map entries, and among sets of such entries. - * - * @return a set view of the identity-mappings contained in this map. - */ - @Override - public final Set> entrySet() { - return new AbstractSet>() { - - @Override - @SuppressWarnings("unchecked" ) - public boolean contains(Object o) { - final Map.Entry e = (Map.Entry) o; - final int index = FixedMap.this.indexOf(e.getKey()); - return index < 0 ? false : values[index] == e.getValue(); - } - - @Override - public Iterator> iterator() { - return new EntryIterator(); - } - - @Override - public int size() { - return keys.length; - } - - @Override - public Object[] toArray() { - int size = size(); - Object[] result = new Object[size]; - for (int i = 0; i < size; i++) - result[i] = new Entry(i); - return result; - } - - @Override - @SuppressWarnings("unchecked" ) - public T[] toArray(T[] a) { - int size = size(); - if (a.length < size) - a = (T[]) java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size); - for (int i = 0; i < size; i++) - a[i] = (T) new Entry(i); - if (a.length > size) - a[size] = null; - return a; - } - }; - } - - /** - * Returns the value to which the specified key is mapped in this fixed map, or - * null if the map contains no mapping for this key. A return value of - * null does not necessarily indicate that the map contains no - * mapping for the key; it is also possible that the map explicitly maps the key - * to null. The containsKey method may be used to distinguish - * these two cases. - * - * @return this.map[key] - */ - @Override - @SuppressWarnings("unchecked" ) - public final V get(Object key) { - final int index = indexOf((K) key); - return index < 0 ? null : (V) values[index]; - } - - /** - * Returns the value to which the key at the specified index is mapped in this - * fixed map. - * - * @requires index in this.indices[this.keys] - * @return this.map[this.indices.index] - * @throws IndexOutOfBoundsException index !in this.indices[this.keys] - */ - @SuppressWarnings("unchecked" ) - public final V get(int index) { - try { - return (V) values[index]; - } catch (ArrayIndexOutOfBoundsException e) { - throw new IndexOutOfBoundsException(); - } - } - - /** - * @see java.util.Map#isEmpty() - */ - @Override - public final boolean isEmpty() { - return keys.length == 0; - } - - /** - * Associates the specified value with the specified key in this fixed map. If - * the map previously contained a mapping for this key, the old value is - * replaced. This method assumes that the given key is in the fixed keyset of - * this map. - * - * @requires key in this.keys - * @return this.map[key] - * @ensures this.map' = this.map ++ key->value - * @throws IllegalArgumentException key !in this.keys - */ - - @Override - @SuppressWarnings("unchecked" ) - public final V put(K key, V value) { - final int index = indexOf(key); - if (index < 0) - throw new IllegalArgumentException(); - final V oldValue = (V) values[index]; - values[index] = value; - return oldValue; - } - - /** - * Throws an {@link UnsupportedOperationException} exception. - * - * @see java.util.Map#remove(java.lang.Object) - */ - @Override - public final V remove(Object key) { - throw new UnsupportedOperationException(); - } - - /** - * @see java.util.Map#size() - */ - @Override - public final int size() { - return keys.length; - } - - /** - * Returns the hash code value for this map. The hash code of a map is defined - * to be the sum of the hashcode of each entry in the map's entrySet view. This - * ensures that t1.equals(t2) implies that - * t1.hashCode()==t2.hashCode() for any two FixedMap instances - * t1 and t2, as required by the general contract of - * {@link Object#hashCode()}. - *

- * Owing to the reference-equality-based semantics of the Map.Entry - * instances in the set returned by this map's entrySet method, it is - * possible that the contractual requirement of Object.hashCode - * mentioned in the previous paragraph will be violated if one of the two - * objects being compared is an FixedMap instance and the other is a - * normal map. - * - * @return the hash code value for this map. - * @see Object#hashCode() - * @see Object#equals(Object) - * @see #equals(Object) - */ - @Override - public int hashCode() { - int result = 0; - for (int i = 0; i < keys.length; i++) - result += System.identityHashCode(keys[i]) ^ System.identityHashCode(values[i]); - return result; - } - - /** - * Compares the specified object with this map for equality. Returns - * true if the given object is also a map and the two maps represent - * identical object-reference mappings. More formally, this map is equal to - * another map m if and only if map - * this.entrySet().equals(m.entrySet()). - *

- * Owing to the reference-equality-based semantics of this map it is possible - * that the symmetry and transitivity requirements of the Object.equals - * contract may be violated if this map is compared to a normal map. However, - * the Object.equals contract is guaranteed to hold among - * FixedMap instances. - * - * @param o object to be compared for equality with this map. - * @return true if the specified object is equal to this map. - * @see Object#equals(Object) - */ - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } else if (o instanceof FixedMap) { - FixedMap< ? , ? > m = (FixedMap< ? , ? >) o; - if (m.size() != size()) - return false; - for (int i = 0; i < keys.length; i++) { - if (keys[i] != m.keys[i] || values[i] != m.values[i]) - return false; - } - return true; - } else if (o instanceof Map) { - Map< ? , ? > m = (Map< ? , ? >) o; - return entrySet().equals(m.entrySet()); - } else { - return false; // o is not a Map - } - } - - private class Entry implements Map.Entry { - - int index; - - Entry(int index) { - this.index = index; - } - - @Override - @SuppressWarnings("unchecked" ) - public final K getKey() { - return (K) keys[index]; - } - - @Override - @SuppressWarnings("unchecked" ) - public final V getValue() { - return (V) values[index]; - } - - @Override - public V setValue(V value) { - throw new UnsupportedOperationException(); - } - - @Override - public int hashCode() { - return System.identityHashCode(keys[index]) ^ System.identityHashCode(values[index]); - } - - @Override - public boolean equals(Object o) { - if (o instanceof Map.Entry) { - final Map.Entry< ? , ? > e = (Map.Entry< ? , ? >) o; - return keys[index] == e.getKey() && values[index] == e.getValue(); - } else - return false; - } - - @Override - public String toString() { - return keys[index] + "=" + values[index]; - } - } - - private final class EntryIterator extends Entry implements Iterator> { - - int next = 0; - - EntryIterator() { - super(-1); - } - - @Override - @SuppressWarnings("unchecked" ) - public V setValue(V value) { - final V oldValue = (V) values[index]; - values[index] = value; - return oldValue; - } - - @Override - public boolean hasNext() { - return next < keys.length; - } - - @Override - public Map.Entry next() { - if (!hasNext()) - throw new NoSuchElementException(); - index = next++; - return this; - } - - @Override - public int hashCode() { - return index < 0 ? System.identityHashCode(this) : super.hashCode(); - } - - @Override - public boolean equals(Object o) { - return index < 0 ? this == o : super.equals(o); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public String toString() { - return index < 0 ? "[]" : super.toString(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/IdentityHashSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/IdentityHashSet.java deleted file mode 100644 index 2bb939938..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/IdentityHashSet.java +++ /dev/null @@ -1,600 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.AbstractSet; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - *

- * Implements the Set interface with a hash table, using - * reference-equality in place of object-equality when comparing elements. In - * other words, in an IdentityHashSet, two elements e1 and - * e2 are considered equal if and only if (e1==e2). (In normal - * Set implementations (like Set) two elements e1 and - * e2 are considered equal if and only if - * (e1==null ? e2==null : e1.equals(e2)).) - *

- * This class is not a general-purpose Set implementation! - * While this class implements the Set interface, it intentionally - * violates Set's general contract, which mandates the use of the - * equals method when comparing objects. This class is designed for use - * only in the rare cases wherein reference-equality semantics are required. - *

- * This class provides all of the optional set operations, and permits - * null elements. This class makes no guarantees as to the order of the - * set; in particular, it does not guarantee that the order will remain constant - * over time. - *

- * This class provides constant-time performance for the basic operations - * (get and put), assuming the system identity hash function - * ({@link System#identityHashCode(Object)}) disperses elements properly among - * the buckets. - *

- * This class has one tuning parameter (which affects performance but not - * semantics): expected maximum size. This parameter is the maximum - * number of elements that the set is expected to hold. Internally, this - * parameter is used to determine the number of buckets initially comprising the - * hash table. The precise relationship between the expected maximum size and - * the number of buckets is unspecified. - *

- * If the size of the set sufficiently exceeds the expected maximum size, the - * number of buckets is increased Increasing the number of buckets ("rehashing") - * may be fairly expensive, so it pays to create identity hash sets with a - * sufficiently large expected maximum size. On the other hand, iteration - * requires time proportional to the number of buckets in the hash table, so it - * pays not to set the expected maximum size too high if you are especially - * concerned with iteration performance or memory usage. - *

- * Note that this implementation is not synchronized. The iterators - * returned by all of this class are not fail-fast: in the face of - * concurrent modification, the iterator risks arbitrary, non-deterministic - * behavior at an undetermined time in the future. - *

- * Implementation note: This is a simple linear-probe hash table, as - * described for example in texts by Sedgewick and Knuth. For many JRE - * implementations and operation mixes, this class will yield better performance - * than {@link HashSet} (which uses chaining rather than linear-probing). - * - * @specfield elems: set T - * @author Emina Torlak - */ -public final class IdentityHashSet extends AbstractSet { - - /* implementation adapted from java.util.IdentityHashMap */ - /** - * The minimum capacity, used if a lower value is implicitly specified by either - * of the constructors with arguments. The value 4 corresponds to an expected - * maximum size of 2, given a load factor of 2/3. MUST be a power of two. - */ - private static final int MINIMUM_CAPACITY = 4; - - /** - * The maximum capacity, used if a higher value is implicitly specified by - * either of the constructors with arguments. MUST be a power of two <= 1<<29. - */ - private static final int MAXIMUM_CAPACITY = 1 << 29; - - /** - * Value representing null elements inside tables. - */ - private static final Object NULL = new Object(); - - /** - * Use NULL for key if it is null. - */ - private static Object maskNull(Object o) { - return (o == null ? NULL : o); - } - - /** - * Return internal representation of null key back to caller as null - */ - private static Object unmaskNull(Object o) { - return (o == NULL ? null : o); - } - - /** - * The table, resized as necessary. Length MUST always be a power of two. - */ - private Object[] table; - - /** - * The number of key-value mappings contained in this identity hash map. - */ - private int size; - - /** - * The next size value at which to resize (capacity * load factor). - */ - private int threshold; - - /** - * Constructs a new, empty identity hash map with a default expected maximum - * size of 16. - * - * @ensures no this.elems' - */ - public IdentityHashSet() { - this(16); - } - - /** - * Constructs a new, empty set with the specified expected maximum size. Putting - * more than the expected number of elements into the set may cause the internal - * data structure to grow, which may be somewhat time-consuming. - * - * @ensures no this.elems' - * @throws IllegalArgumentException expectedMaxSize < 0 - */ - public IdentityHashSet(int expectedMaxSize) { - if (expectedMaxSize < 0) - throw new IllegalArgumentException("expectedMaxSize < 0: " + expectedMaxSize); - - final int initCapacity = capacity(expectedMaxSize); - threshold = (initCapacity * 2) / 3; - table = new Object[initCapacity]; - size = 0; - } - - /** - * Constructs a new identity hash set containing the elements in the specified - * collection. - * - * @ensures this.elems' = c.elems - * @throws NullPointerException c = null - */ - public IdentityHashSet(Collection< ? extends T> c) { - // Allow for a bit of growth - this((int) ((1 + c.size()) * 1.1)); - addAll(c); - } - - /** - * Returns the appropriate capacity for the specified expected maximum size. - * Returns the smallest power of two between MINIMUM_CAPACITY and - * MAXIMUM_CAPACITY, inclusive, that is greater than (3 * expectedMaxSize)/2, if - * such a number exists. Otherwise returns MAXIMUM_CAPACITY. If (3 * - * expectedMaxSize)/2 is negative, it is assumed that overflow has occurred, and - * MAXIMUM_CAPACITY is returned. - */ - private static int capacity(int expectedMaxSize) { - // Compute min capacity for expectedMaxSize given a load factor of 2/3 - final int minCapacity = (3 * expectedMaxSize) / 2; - - // Compute the appropriate capacity - int result; - if (minCapacity > MAXIMUM_CAPACITY || minCapacity < 0) { - result = MAXIMUM_CAPACITY; - } else { - result = StrictMath.max(MINIMUM_CAPACITY, Integer.highestOneBit(minCapacity)); - if (result < minCapacity) - result <<= 1; - } - return result; - } - - /** - * @inheritDoc - */ - @Override - public Iterator iterator() { - return new IdentityIterator(); - } - - /** - * @inheritDoc - */ - @Override - public int size() { - return size; - } - - /** - * @inheritDoc - */ - @Override - public boolean isEmpty() { - return size == 0; - } - - /** - * Return index for Object x in a table of size length. - */ - private static int hash(Object x, int length) { - return System.identityHashCode(x) & (length - 1); - } - - /** - * Circularly traverse table of size length. - **/ - private static int nextKeyIndex(int i, int length) { - return (i + 3) & (length - 1); - } - - /** - * Tests whether the specified object reference is an element in this identity - * hash map. - * - * @return o in this.elems - */ - @Override - public boolean contains(Object o) { - o = maskNull(o); - - for (int i = hash(o, table.length);; i = nextKeyIndex(i, table.length)) { - Object item = table[i]; - if (item == o) - return true; - if (item == null) - return false; - } - } - - /** - * @inheritDoc - */ - @Override - public boolean add(T element) { - final Object o = maskNull(element); - - int i = hash(o, table.length); - - for (Object item = table[i]; item != null; item = table[i]) { - if (item == o) - return false; - i = nextKeyIndex(i, table.length); - } - - table[i] = o; - - if (++size >= threshold) - resize(table.length << 1); // newCapacity == 2 * current capacity. - - return true; - } - - /** - * Resize the table to hold given capacity. The new capacity must be a power of - * two. - */ - private void resize(int newCapacity) { - final int oldLength = table.length; - - if (oldLength == MAXIMUM_CAPACITY) {// can't expand any further - if (threshold == MAXIMUM_CAPACITY - 1) - throw new IllegalStateException("Capacity exhausted."); - threshold = MAXIMUM_CAPACITY - 1; - return; - } - - if (oldLength >= newCapacity) - return; - - final Object[] newTable = new Object[newCapacity]; - - for (int j = 0; j < oldLength; j++) { - Object o = table[j]; - if (o != null) { - table[j] = null; - int i = hash(o, newCapacity); - while (newTable[i] != null) - i = nextKeyIndex(i, newCapacity); - newTable[i] = o; - } - } - - table = newTable; - threshold = (newCapacity * 2) / 3; - } - - /** - * @inheritDoc - */ - @Override - public boolean remove(Object o) { - o = maskNull(o); - - for (int i = hash(o, table.length);; i = nextKeyIndex(i, table.length)) { - Object item = table[i]; - if (item == o) { - size--; - table[i] = null; - closeDeletion(i); - return true; - } - if (item == null) - return false; - } - - } - - /** - * Rehash all possibly-colliding entries following a deletion. This preserves - * the linear-probe collision properties required by get, put, etc. - * - * @param d the index of a newly empty deleted slot - */ - private void closeDeletion(int d) { - // Adapted from Knuth Section 6.4 Algorithm R - - // Look for items to swap into newly vacated slot - // starting at index immediately following deletion, - // and continuing until a null slot is seen, indicating - // the end of a run of possibly-colliding keys. - Object item; - for (int i = nextKeyIndex(d, table.length); (item = table[i]) != null; i = nextKeyIndex(i, table.length)) { - // The following test triggers if the item at slot i (which - // hashes to be at slot r) should take the spot vacated by d. - // If so, we swap it in, and then continue with d now at the - // newly vacated i. This process will terminate when we hit - // the null slot at the end of this run. - // The test is messy because we are using a circular table. - int r = hash(item, table.length); - if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { - table[d] = item; - table[i] = null; - d = i; - } - } - } - - /** - * @inheritDoc - */ - @Override - public boolean addAll(Collection< ? extends T> c) { - int n = c.size(); - if (n == 0) - return false; - if (n > threshold) // conservatively pre-expand - resize(capacity(n)); - - return super.addAll(c); - } - - /** - * @inheritDoc - */ - @Override - public boolean removeAll(Collection< ? > c) { - /* - * Must revert from AbstractSet's impl to AbstractCollection's, as the former - * contains an optimization that results in incorrect behavior when c is a - * smaller "normal" (non-identity-based) Set. - */ - boolean modified = false; - Iterator< ? > e = iterator(); - while (e.hasNext()) { - if (c.contains(e.next())) { - e.remove(); - modified = true; - } - } - return modified; - } - - /** - * @inheritDoc - */ - @Override - public void clear() { - for (int i = 0; i < table.length; i++) - table[i] = null; - size = 0; - } - - /** - * Compares the specified object with this set for equality. Returns - * true if the given object is also a set and the two sets contain - * identical object-references. - *

- * Owing to the reference-equality-based semantics of this set it is possible - * that the symmetry and transitivity requirements of the Object.equals - * contract may be violated if this set is compared to a normal set. However, - * the Object.equals contract is guaranteed to hold among - * IdentityHashSet instances. - * - * @return true if the specified object is equal to this set. - * @see Object#equals(Object) - */ - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } else if (o instanceof IdentityHashSet) { - final IdentityHashSet< ? > s = (IdentityHashSet< ? >) o; - if (s.size() != size) - return false; - final Object[] tab = s.table; - for (int i = 0; i < tab.length; i++) { - Object k = tab[i]; - if (k != null && !contains(k)) - return false; - } - return true; - } else { - return super.equals(o); - } - } - - /** - * Returns the hash code value for this set. The hash code of a set is defined - * to be the sum of the hashcode of each entry in the set. This ensures that - * t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for - * any two IdentityHashSet instances t1 and t2, as - * required by the general contract of {@link Object#hashCode()}. - *

- * Owing to the reference-equality-based semantics of the elements in this - * set, it is possible that the contractual requirement of - * Object.hashCode mentioned in the previous paragraph will be violated - * if one of the two objects being compared is an IdentityHashSet - * instance and the other is a normal set. - * - * @return the hash code value for this set. - * @see Object#hashCode() - * @see Object#equals(Object) - * @see #equals(Object) - */ - @Override - public int hashCode() { - int result = 0; - for (Object o : table) { - if (o != null) { - result += System.identityHashCode(unmaskNull(o)); - } - } - return result; - } - - /** - * An iterator over the elements of an IdentityHashSet. - */ - private final class IdentityIterator implements Iterator { - - int index = (size != 0 ? 0 : table.length); // current - // slot. - int lastReturnedIndex = -1; // to - // allow - // remove() - Object[] traversalTable = table; // reference - // to - // main - // table - // or - // copy - - @Override - public boolean hasNext() { - for (int i = index; i < traversalTable.length; i++) { - if (traversalTable[i] != null) { - index = i; - return true; - } - } - index = traversalTable.length; - return false; - } - - @Override - @SuppressWarnings("unchecked" ) - public T next() { - if (!hasNext()) - throw new NoSuchElementException(); - - lastReturnedIndex = index++; - return (T) unmaskNull(traversalTable[lastReturnedIndex]); - } - - @Override - public void remove() { - if (lastReturnedIndex == -1) - throw new IllegalStateException(); - - final int deletedSlot = lastReturnedIndex; - lastReturnedIndex = -1; - - // If traversing a copy, remove in real table. - // We can skip gap-closure on copy. - if (traversalTable != IdentityHashSet.this.table) { - IdentityHashSet.this.remove(traversalTable[deletedSlot]); - traversalTable[deletedSlot] = null; - } else { // we are working on the real table... - // back up index to revisit new contents after deletion - size--; - index = deletedSlot; - - // Removal code proceeds as in closeDeletion except that - // it must catch the rare case where an element already - // seen is swapped into a vacant slot that will be later - // traversed by this iterator. We cannot allow future - // next() calls to return it again. The likelihood of - // this occurring under 2/3 load factor is very slim, but - // when it does happen, we must make a copy of the rest of - // the table to use for the rest of the traversal. Since - // this can only happen when we are near the end of the table, - // even in these rare cases, this is not very expensive in - // time or space. - final Object[] tab = traversalTable; - final int length = tab.length; - - int d = deletedSlot; - tab[d] = null; // vacate the slot - - Object item; - for (int i = nextKeyIndex(d, length); (item = tab[i]) != null; i = nextKeyIndex(i, length)) { - int r = hash(item, length); - // See closeDeletion for explanation of this conditional - if ((i < r && (r <= d || d <= i)) || (r <= d && d <= i)) { - - // If we are about to swap an already-seen element - // into a slot that may later be returned by next(), - // then clone the rest of table for use in future - // next() calls. It is OK that our copy will have - // a gap in the "wrong" place, since it will never - // be used for searching anyway. - if (i < deletedSlot && d >= deletedSlot && traversalTable == IdentityHashSet.this.table) { - int remaining = length - deletedSlot; - Object[] newTable = new Object[remaining]; - System.arraycopy(tab, deletedSlot, newTable, 0, remaining); - traversalTable = newTable; - index = 0; - } - tab[d] = item; - tab[i] = null; - d = i; - } - } - } - } - - } - - // public static void main(String[] args) { - // IdentityHashSet s = new IdentityHashSet(21); - // Integer[] elts = new Integer[21]; - // for(int i = 0; i < elts.length; i++) { - // elts[i] = new Integer(i); - // s.add(elts[i]); - // } - // System.out.println(s); - // System.out.println(s.size()); - // System.out.println(s.table.length); - // System.out.println(s.threshold); - // System.out.println(s.contains(2)); - // System.out.println(s.contains(elts[2])); - // System.out.println(s.remove(new Integer(0))); - // System.out.println(s.remove(elts[0])); - // System.out.println(s); - // - // for(Iterator iter = s.iterator(); iter.hasNext(); ) { - // System.out.println(iter.next()); - // iter.remove(); - // } - // System.out.println(s); - // - // } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Indexer.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Indexer.java deleted file mode 100644 index dc61fcd4d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Indexer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -/** - * An index generator for a set of keys. An indexer maps each key in its keyset - * to a unique integer in the range [0..#keys) - * - * @specfield keys: set K - * @specfield indices: keys lone->one [0..#keys) - * @author Emina Torlak - */ -public interface Indexer { - - /** - * Returns the index of the given key, if it is in this.keys. Otherwise returns - * a negative number. - * - * @return key in this.keys => this.indices[key], {i: int | i < 0 } - */ - public abstract int indexOf(K key); - - /** - * Returns the key at the given index. - * - * @return this.indices.index - * @throws IndexOutOfBoundsException index !in this.indices[this.keys] - */ - public abstract K keyAt(int index); - - /** - * Returns the number of keys in this.indexer. - * - * @return #this.keys - */ - public abstract int size(); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/LinkedStack.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/LinkedStack.java deleted file mode 100644 index fbf015499..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/LinkedStack.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.EmptyStackException; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * A Stack implementation based on a singly linked list. - * - * @author Emina Torlak - */ -public final class LinkedStack extends Stack { - - private StackEntry head; - private int size; - - /** - * Constructs an empty stack. - * - * @ensures no this.elems' - */ - public LinkedStack() { - head = null; - size = 0; - } - - /** - * @see kodkod.util.collections.Stack#size() - */ - @Override - public int size() { - return size; - } - - /** - * Pushes an item onto the top of this stack and returns it. - * - * @ensures this.size' = this.size + 1 && this.elems'[0] = item && all i: - * [0..this.size) | this.elems'[i+1] = this.elems[i] - * @return item - */ - @Override - public T push(T item) { - head = new StackEntry(item, head); - size++; - return item; - } - - /** - * Removes the object at the top of this stack and returns that object as the - * value of this function. - * - * @ensures this.size' = this.size - 1 && all i: [1..this.size) | - * this.elems'[i-1] = this.elems[i] - * @return this.elems[0] - * @throws EmptyStackException no this.elems - */ - @Override - public T pop() { - if (head == null) - throw new EmptyStackException(); - final T pop = head.data; - head = head.next; - size--; - return pop; - } - - /** - * Looks at the object at the top of this stack without removing it from the - * stack. - * - * @return this.elems[0] - * @throws EmptyStackException no this.elems - */ - @Override - public T peek() { - if (head == null) - throw new EmptyStackException(); - return head.data; - } - - /** - * Returns the 1-based position where an object is on this stack. If the object - * o occurs as an item in this stack, this method returns the distance from the - * top of the stack of the occurrence nearest the top of the stack; the topmost - * item on the stack is considered to be at distance 1. The equals method is - * used to compare o to the items in this stack. - * - * @return o in this.elems[int] => min(this.elems.o) + 1, -1 - */ - @Override - public int search(Object o) { - StackEntry e = head; - int position = 1; - while (e != null) { - if (equal(o, e.data)) - return position; - e = e.next; - position++; - } - return -1; - } - - /** - * Returns true if the stack is empty; otherwise returns false. - * - * @return no this.elems - */ - @Override - public boolean empty() { - return head == null; - } - - /** - * Iterates over the items in this LinkedStack, starting at the top of the stack - * and working its way down. - * - * @return iterator over the elements in this stack. - */ - @Override - public Iterator iterator() { - return new Iterator() { - - private StackEntry cursor = head, prev = null, pprev = null; - - @Override - public boolean hasNext() { - return cursor != null; - } - - @Override - public T next() { - if (cursor == null) - throw new NoSuchElementException(); - pprev = prev; - prev = cursor; - cursor = cursor.next; - return prev.data; - } - - @Override - public void remove() { - if (prev == pprev) { - throw new UnsupportedOperationException(); - } else if (prev == head) { - head = cursor; - } else { - pprev.next = cursor; - prev.next = null; - } - prev = pprev; - size--; - } - - }; - } - - /** - * Represents a stack entry. - * - * @specfield data: T - * @specfield next: StackEntry - */ - private static final class StackEntry { - - T data; - StackEntry next; - - StackEntry(T data, StackEntry next) { - this.data = data; - this.next = next; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Pair.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Pair.java deleted file mode 100644 index 8da3bf7ae..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Pair.java +++ /dev/null @@ -1,50 +0,0 @@ -package kodkod.util.collections; - -public class Pair { - - public final A a; - public final B b; - - public Pair(A a, B b) { - this.a = a; - this.b = b; - } - - @Override - public String toString() { - return "<" + a + ", " + b + ">"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((a == null) ? 0 : a.hashCode()); - result = prime * result + ((b == null) ? 0 : b.hashCode()); - return result; - } - - @SuppressWarnings("rawtypes" ) - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Pair other = (Pair) obj; - if (a == null) { - if (other.a != null) - return false; - } else if (!a.equals(other.a)) - return false; - if (b == null) { - if (other.b != null) - return false; - } else if (!b.equals(other.b)) - return false; - return true; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/SingletonIdentitySet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/SingletonIdentitySet.java deleted file mode 100644 index 65f508dbf..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/SingletonIdentitySet.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Set; - -/** - *

- * This is an immutable singleton set implementation that tests for membership - * using reference-equality in place of object-equality when comparing elements. - *

- * - * @specfield element: V - * @author Emina Torlak - */ -public final class SingletonIdentitySet extends AbstractSet { - - private final V element; - - /** - * Constructs a SingletonIdentitySet that will hold the given element. - * - * @ensures this.element' = element - */ - public SingletonIdentitySet(V element) { - this.element = element; - } - - /** - * Constructs a SingletonIdentitySet that will hold the first element returned - * by the given collection's iterator. - * - * @ensures this.element' = collection.iterator().next() - * @throws NoSuchElementException collection.isEmpty() - */ - public SingletonIdentitySet(Collection< ? extends V> collection) { - this.element = collection.iterator().next(); - } - - /** - * Returns true iff this.element and obj are the same object. - * - * @return this.element == obj - */ - @Override - public boolean contains(Object obj) { - return element == obj; - } - - /** - * @see java.util.Set#containsAll(java.util.Collection) - */ - @Override - public boolean containsAll(Collection< ? > collection) { - if (collection.isEmpty()) - return true; - else if (collection.size() == 1) - return collection.iterator().next() == this.element; - else - return false; - } - - /** - * Returns false. - * - * @return false. - */ - @Override - public boolean isEmpty() { - return false; - } - - /** - * @see java.util.Set#iterator() - */ - @Override - @SuppressWarnings("unchecked" ) - public Iterator iterator() { - return Containers.iterate(this.element); - } - - /** - * Returns 1. - * - * @return 1 - */ - @Override - public int size() { - return 1; - } - - /** - * Compares the specified object with this set for equality. Returns - * true if the given object is also a set and the two sets contain - * identical object-references. - *

- * Owing to the reference-equality-based semantics of this set it is possible - * that the symmetry and transitivity requirements of the Object.equals - * contract may be violated if this set is compared to a normal set. However, - * the Object.equals contract is guaranteed to hold among - * SingletonHashSet instances. - * - * @return true if the specified object is equal to this set. - * @see Object#equals(Object) - */ - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } else if (o instanceof Set) { - final Set< ? > s = (Set< ? >) o; - return s.size() == 1 && s.iterator().next() == this.element; - } else { - return false; - } - } - - /** - * Returns 0 if this.element is null; otherwise returns this.element.hashCode(). - * - * @return this.element = null ? 0 : this.element.hashCode() - * @see java.util.AbstractSet#hashCode() - */ - @Override - public int hashCode() { - return this.element == null ? 0 : element.hashCode(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Stack.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Stack.java deleted file mode 100644 index 8ca85688a..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/Stack.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.collections; - -import java.util.EmptyStackException; -import java.util.Iterator; - -/** - * Represents a last-in-first-out (LIFO) stack of objects. The usual push and - * pop operations are provided, as well as a method to peek at the top item on - * the stack, a method to test for whether the stack is empty, and an iterator - * over the elements in the stack (that does not support removal). When a stack - * is first created, it contains no items. - * - * @specfield size: int - * @specfield elems: [0..size)->one T - * @author Emina Torlak - */ -public abstract class Stack implements Iterable { - - /** - * Constructs a new stack. - */ - protected Stack() {} - - /** - * Returns the size of this stack. - * - * @return this.size - */ - public abstract int size(); - - /** - * Pushes an item onto the top of this stack and returns it. - * - * @ensures this.size' = this.size + 1 && this.elems'[0] = item && all i: - * [0..this.size) | this.elems'[i+1] = this.elems[i] - * @return item - */ - public abstract T push(T item); - - /** - * Removes the object at the top of this stack and returns that object as the - * value of this function. - * - * @ensures this.size' = this.size - 1 && all i: [1..this.size) | - * this.elems'[i-1] = this.elems[i] - * @return this.elems[0] - * @throws EmptyStackException no this.elems - */ - public abstract T pop(); - - /** - * Looks at the object at the top of this stack without removing it from the - * stack. - * - * @return this.elems[0] - * @throws EmptyStackException no this.elems - */ - public abstract T peek(); - - /** - * Returns the 1-based position where an object is on this stack. If the object - * o occurs as an item in this stack, this method returns the distance from the - * top of the stack of the occurrence nearest the top of the stack; the topmost - * item on the stack is considered to be at distance 1. The equals method is - * used to compare o to the items in this stack. - * - * @return o in this.elems[int] => min(this.elems.o) + 1, -1 - */ - public abstract int search(Object o); - - /** - * Returns true if the stack is empty; otherwise returns false. - * - * @return no this.elems - */ - public abstract boolean empty(); - - /** - * Iterates over the items in this Stack, starting at the top of the stack and - * working its way down. - * - * @return iterator over the elements in this stack. - */ - @Override - public abstract Iterator iterator(); - - /** - * Returns true if both o1 and o2 are null, or if they are non-null and 'equals' - * to each other. - * - * @return o1=null && o2=null || o1.equals(o2) - */ - static boolean equal(Object o1, Object o2) { - return (o1 == null ? o2 == null : o1.equals(o2)); - } - - /** - * Returns true if o is a stack containing the same elements as this stack, in - * the same order. - * - * @return o in Stack && this.elems = o.elems - */ - @Override - @SuppressWarnings("unchecked" ) - public boolean equals(Object o) { - if (this == o) - return true; - else if (o instanceof Stack) { - final Stack s = (Stack) o; - if (size() != s.size()) - return false; - final Iterator iter0 = iterator(), iter1 = s.iterator(); - while (iter0.hasNext()) { - if (!equal(iter0.next(), iter1.next())) - return false; - } - return true; - } - return false; - } - - /** - * Returns the hashcode for this stack. - * - * @return the hashcode for this stack. - */ - @Override - public int hashCode() { - int code = 0; - for (T item : this) { - if (item != null) - code += item.hashCode(); - } - return code; - } - - /** - * Returns a string represention of this stack. - */ - @Override - public String toString() { - final StringBuilder buffer = new StringBuilder("[ "); - final Iterator elems = iterator(); - if (elems.hasNext()) - buffer.append(elems.next()); - while (elems.hasNext()) { - buffer.append(", "); - buffer.append(elems.next()); - } - buffer.append(" ]"); - return buffer.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/package.html deleted file mode 100644 index 0b4d679d7..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/package.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - -Contains specialized collections, such as a set that provides methods for -retrieving elements with a particular hashcode. - -

Package Specification

- -

Contains specialized collections, such as a set that provides methods for -retrieving elements with a particular hashcode. It also provides a -utility class for working with arrays.

- - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/collections/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntCollection.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntCollection.java deleted file mode 100644 index 5c753be6d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntCollection.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * A skeletal implementation of the IntCollection interface. - * - * @author Emina Torlak - */ -public abstract class AbstractIntCollection implements IntCollection { - - /** - * Constructs an empty int collection. - * - * @ensures this.isEmpty() - */ - protected AbstractIntCollection() {} - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#isEmpty() - */ - @Override - public boolean isEmpty() { - return size() == 0; - } - - /** - * Iterates through this.ints and returns true if it finds i, otherwise returns - * false. - * - * @return true if i is in this collection, otherwise returns false. - */ - @Override - public boolean contains(int i) { - for (IntIterator iter = iterator(); iter.hasNext();) { - if (i == iter.next()) - return true; - } - return false; - } - - /** - * Throws an UnsupportedOperationException. - * - * @throws UnsupportedOperationException - */ - @Override - public boolean add(int i) { - throw new UnsupportedOperationException(); - } - - /** - * Iterates through the elements of this, removes i if it finds it and returns - * true. Otherwise returns false. Throws an UnsupportedOperationException if - * this.iterator() does not support removal. - * - * @ensures iterates through the elements of this and removes i if it finds it - * @return true if this collection has changed as a result of the call - * @throws UnsupportedOperationException this.iterator() does not support - * removal - */ - @Override - public boolean remove(int i) { - for (IntIterator iter = iterator(); iter.hasNext();) { - if (i == iter.next()) { - iter.remove(); - return true; - } - } - return false; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#containsAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean containsAll(IntCollection c) { - if (size() >= c.size()) { - for (IntIterator itr = c.iterator(); itr.hasNext();) { - if (!contains(itr.next())) - return false; - } - return true; - } - return false; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#addAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean addAll(IntCollection c) { - boolean modified = false; - for (IntIterator itr = c.iterator(); itr.hasNext();) { - if (add(itr.next())) - modified = true; - } - return modified; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#retainAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean retainAll(IntCollection c) { - boolean modified = false; - for (IntIterator itr = iterator(); itr.hasNext();) { - if (!c.contains(itr.next())) { - modified = true; - itr.remove(); - } - } - return modified; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#removeAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean removeAll(IntCollection c) { - boolean modified = false; - for (IntIterator itr = iterator(); itr.hasNext();) { - if (c.contains(itr.next())) { - modified = true; - itr.remove(); - } - } - return modified; - } - - /** - * This implementation iterates over this set, removing each element using the - * Iterator.remove operation. Most implementations will probably choose - * to override this method for efficiency. - *

- * Note that this implementation will throw an - * UnsupportedOperationException if the iterator returned by this - * collection's iterator method does not implement the remove - * method and this collection is non-empty. - * - * @throws UnsupportedOperationException if the clear method is not - * supported by this collection. - */ - @Override - public void clear() { - for (IntIterator itr = iterator(); itr.hasNext();) { - itr.next(); - itr.remove(); - } - } - - /** - * Returns the result of calling {@linkplain #toArray(int[])} with a freshly - * constructed array of length this.size(). - * - * @return this.toArray(new int[size()]) - * @see kodkod.util.ints.IntCollection#toArray() - */ - @Override - public int[] toArray() { - return toArray(new int[size()]); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#toArray(int[]) - */ - @Override - public int[] toArray(int[] array) { - if (array.length < size()) { - array = new int[size()]; - } - int i = 0; - for (IntIterator itr = iterator(); itr.hasNext();) { - array[i++] = itr.next(); - } - return array; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntSet.java deleted file mode 100644 index ed9cf9bd0..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntSet.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.NoSuchElementException; - -/** - * A skeletal implementation of the IntSet interface. - * - * @author Emina Torlak - */ -public abstract class AbstractIntSet extends AbstractIntCollection implements IntSet { - - /** - * Constructs an empty int set. - * - * @ensures no this.ints' - */ - protected AbstractIntSet() {} - - /** - * Throws a NoSuchElementException if this is an empty set. - * - * @throws NoSuchElementException this.isEmpty() - */ - final void checkNonEmpty() { - if (isEmpty()) - throw new NoSuchElementException("no this.ints"); - } - - /** - * Returns an ascending iterator over all elements in this set. This method - * calls this.iterator(Integer.MIN_VALUE, Integer.MAX_VALUE). - * - * @return an ascending iterator over all elements in this set. - */ - @Override - public IntIterator iterator() { - return iterator(Integer.MIN_VALUE, Integer.MAX_VALUE); - } - - /** - * Returns the first element returned by this.iterator(). If this set is empty, - * throws a NoSuchElementException(). - * - * @return min(this.ints) - * @throws NoSuchElementException no this.ints - */ - @Override - public int min() { - return iterator().next(); - } - - /** - * Returns the first element returned by this.iterator(Integer.MAX_VALUE, - * Integer.MIN_VALUE). If this set is empty, throws a NoSuchElementException(). - * - * @return max(this.ints) - * @throws NoSuchElementException no this.ints - */ - @Override - public int max() { - return iterator(Integer.MAX_VALUE, Integer.MIN_VALUE).next(); - } - - /** - * Returns the result of calling super.clone(). - * - * @return the result of calling super.clone() - * @see java.lang.Object#clone() - */ - @Override - public IntSet clone() throws CloneNotSupportedException { - return (IntSet) super.clone(); - } - - /** - * Compares the specified object with this set for equality. Returns true if the - * specified object is also an IntSet, the two sets have the same size, and - * every member of the specified set is contained in this set (or equivalently, - * every member of this set is contained in the specified set). This definition - * ensures that the equals method works properly across different - * implementations of the IntSet interface. - * - * @return o instanceof IntSet and o.size() = this.size() and - * this.containsAll(o) - */ - @Override - public boolean equals(Object o) { - if (o == this) - return true; - else if (o instanceof IntSet) { - final IntSet s = (IntSet) o; - return size() == s.size() && containsAll(s); - } else - return false; - } - - /** - * Returns the hash code value for this set. The hash code of a set is defined - * to be the {@link Ints#superFastHash(int[])} of the elements in the set, taken - * in the ascending order of values. This ensures that s1.equals(s2) implies - * that s1.hashCode()==s2.hashCode() for any two IntSets s1 and s2, as required - * by the general contract of the Object.hashCode method. - * - * @return Ints.superFastHash(this.toArray()) - */ - @Override - public int hashCode() { - int hash = size(); - for (IntIterator iter = iterator(); iter.hasNext();) { - hash = Ints.superFastHashIncremental(iter.next(), hash); - } - return Ints.superFastHashAvalanche(hash); - } - - /** - * Returns a string representation of this int set. - * - * @return a string representation of this int set. - */ - @Override - public String toString() { - final StringBuilder buf = new StringBuilder("{"); - final IntIterator itr = iterator(); - if (itr.hasNext()) - buf.append(itr.next()); - while (itr.hasNext()) { - buf.append(", "); - buf.append(itr.next()); - } - buf.append("}"); - return buf.toString(); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntVector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntVector.java deleted file mode 100644 index 4dc5af8d3..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractIntVector.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.NoSuchElementException; - -/** - * A skeletal implementation of the IntVector interface. - * - * @specfield length: int - * @specfield elements: [0..size) ->one int - * @author Emina Torlak - */ -public abstract class AbstractIntVector extends AbstractIntCollection implements IntVector { - - /** - * Constructs an empty int vector. - * - * @ensures no this.elements' - */ - protected AbstractIntVector() {} - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#contains(int) - */ - @Override - public boolean contains(int element) { - for (int i = 0, max = size(); i < max; i++) { - if (get(i) == element) - return true; - } - return false; - } - - /** - * Throws {@link UnsupportedOperationException}. - * - * @see kodkod.util.ints.IntVector#set(int,int) - */ - @Override - public int set(int index, int element) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#indexOf(int) - */ - @Override - public int indexOf(int element) { - for (int i = 0, length = size(); i < length; i++) { - if (get(i) == element) - return i; - } - return -1; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#lastIndexOf(int) - */ - @Override - public int lastIndexOf(int element) { - for (int i = size() - 1; i >= 0; i--) { - if (get(i) == element) - return i; - } - return -1; - } - - /** - * Calls this.add(this.size(), element) - * - * @see kodkod.util.ints.IntVector#add(int) - * @see kodkod.util.ints.IntVector#add(int,int) - */ - @Override - public boolean add(int element) { - final int length = size(); - add(length, element); - return length != size(); - } - - /** - * Throws {@link UnsupportedOperationException} - * - * @see kodkod.util.ints.IntVector#add(int, int) - */ - @Override - public void add(int index, int element) { - throw new UnsupportedOperationException(); - } - - /** - * Returns the result of calling {@linkplain #addAll(int, IntCollection) - * this.addAll(size(), c)}. - * - * @return this.addAll(size(), c) - * @see kodkod.util.ints.AbstractIntCollection#addAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean addAll(IntCollection c) { - return addAll(size(), c); - } - - /** - * Throws an UnsupportedOperationException. - * - * @see kodkod.util.ints.IntVector#addAll(int, kodkod.util.ints.IntCollection) - */ - @Override - public boolean addAll(int index, IntCollection c) { - throw new UnsupportedOperationException(); - } - - /** - * Throws an UnsupportedOperationException. - * - * @see kodkod.util.ints.IntVector#removeAt(int) - */ - @Override - public int removeAt(int index) { - throw new UnsupportedOperationException(); - } - - /** - * Calls this.iterator(0, length()) - * - * @see kodkod.util.ints.IntVector#iterator() - * @see kodkod.util.ints.IntVector#iterator(int,int) - */ - @Override - public IntIterator iterator() { - return iterator(0, size()); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#iterator(int, int) - */ - @Override - public IntIterator iterator(int fromIndex, int toIndex) { - return fromIndex <= toIndex ? new AscendingIntVectorIterator(fromIndex, toIndex) : new DescendingIntVectorIterator(fromIndex, toIndex); - } - - /** - * Returns the hash code value for this vector. - * - * @return the hash code value for this vector. - * @see Object#hashCode() - * @see Object#equals(Object) - * @see #equals(Object) - */ - @Override - public int hashCode() { - final int length = size(); - int hash = length; - for (int i = 0; i < length; i++) { - hash = Ints.superFastHashIncremental(get(i), hash); - } - return Ints.superFastHashAvalanche(hash); - } - - /** - * Compares the specified object with this vector for equality. Returns - * true if and only if the specified object is also an int vector, both - * vectors have the same size, and all corresponding pairs of elements in the - * two vectors are equal. - * - * @return true if the specified object is equal to this vector. - */ - @Override - public boolean equals(Object o) { - if (o == this) - return true; - if (o instanceof IntVector) { - final IntVector l = (IntVector) o; - final int length = size(); - if (l.size() == length) { - for (int i = 0; i < length; i++) { - if (get(i) != l.get(i)) - return false; - } - return true; - } - } - return false; - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder buf = new StringBuilder(); - buf.append("["); - IntIterator itr = iterator(); - if (itr.hasNext()) - buf.append(itr.next()); - while (itr.hasNext()) { - buf.append(", "); - buf.append(itr.next()); - } - buf.append("]"); - return buf.toString(); - } - - private abstract class IntVectorIterator implements IntIterator { - - int next, end, last; - - IntVectorIterator(int fromIndex, int toIndex) { - next = fromIndex; - end = toIndex; - last = -1; - } - - @Override - public final void remove() { - if (last < 0) - throw new IllegalStateException(); - AbstractIntVector.this.removeAt(last); - next = last; - last = -1; - } - } - - private final class AscendingIntVectorIterator extends IntVectorIterator { - - /** - * Constructs a new AscendingIntArrayIterator. - * - * @requires fromIndex <= toIndex - */ - AscendingIntVectorIterator(int fromIndex, int toIndex) { - super(fromIndex, toIndex); - } - - @Override - public boolean hasNext() { - return last < Integer.MAX_VALUE && next < end; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - last = next++; - return get(last); - } - } - - private final class DescendingIntVectorIterator extends IntVectorIterator { - - /** - * Constructs a new AscendingIntArrayIterator. - * - * @requires fromIndex >= toIndex - */ - DescendingIntVectorIterator(int fromIndex, int toIndex) { - super(fromIndex, toIndex); - } - - @Override - public boolean hasNext() { - return next > end; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - last = next--; - return get(last); - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractSparseSequence.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractSparseSequence.java deleted file mode 100644 index 2168be0b2..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/AbstractSparseSequence.java +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * A skeletal implementation of the SparseSequence interface. The class provides - * an implementation for the isEmpty, putAll, - * contains, indices, equals, - * hashCode, and toString methods. All other methods - * must be implemented by the subclasses. - * - * @specfield entries: int -> lone V - * @author Emina Torlak - */ -public abstract class AbstractSparseSequence implements SparseSequence { - - /** - * Constructs a sparse sequence - * - * @ensures no this.entries' - */ - protected AbstractSparseSequence() {} - - /** - * Returns true if the size of this sequence is 0. - * - * @return this.size()==0 - */ - @Override - public boolean isEmpty() { - return size() == 0; - } - - /** - * Returns an iterator over the entries in this sequence in the ascending order - * of indeces, starting at this.first(). This method calls - * this.iterator(Integer.MIN_VALUE, Integer.MAX_VALUE). - * - * @return an iterator over this.entries starting at the entry with the smallest - * index - */ - @Override - public Iterator> iterator() { - return iterator(Integer.MIN_VALUE, Integer.MAX_VALUE); - } - - /** - * Returns the first element in this sequence, if any. This method first checks - * that the sequence is not empty, and if not, returns this.iterator().next(); - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#first() - */ - @Override - public IndexedEntry first() { - return isEmpty() ? null : iterator().next(); - } - - /** - * Returns the last element in this sequence, if any. This method first checks - * that the sequence is not empty, and if not, returns - * this.iterator(Integer.MAX_VALUE, Integer.MIN_VALUE).next(); {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#last() - */ - @Override - public IndexedEntry last() { - return isEmpty() ? null : iterator(Integer.MAX_VALUE, Integer.MIN_VALUE).next(); - } - - /** - * Returns the entry whose index is the ceiling of the given index in this - * sequence. This method calls this.iterator(index, Integer.MAX_VALUE), and if - * the resulting iterator has a next element returns it. {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#ceil(int) - */ - @Override - public IndexedEntry ceil(int index) { - final Iterator> itr = iterator(index, Integer.MAX_VALUE); - return itr.hasNext() ? itr.next() : null; - } - - /** - * Returns the entry whose index is the floor of the given index in this - * sequence. This method calls this.iterator(index, Integer.MIN_VALUE), and if - * the resulting iterator has a next element returns it. {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#floor(int) - */ - @Override - public IndexedEntry floor(int index) { - final Iterator> itr = iterator(index, Integer.MIN_VALUE); - return itr.hasNext() ? itr.next() : null; - } - - /** - * Returns the set of all indices mapped by this sparse sequence. The returned - * set supports removal iff this is not an unmodifiable sparse sequence. - * - * @return {s: IntSet | s.ints = this.entries.V} - */ - @Override - public IntSet indices() { - return new AbstractIntSet() { - - @Override - public IntIterator iterator(final int from, final int to) { - return new IntIterator() { - - Iterator> iter = AbstractSparseSequence.this.iterator(from, to); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public int next() { - return iter.next().index(); - } - - @Override - public void remove() { - iter.remove(); - } - }; - } - - @Override - public int size() { - return AbstractSparseSequence.this.size(); - } - - @Override - public boolean contains(int i) { - return containsIndex(i); - } - - @Override - public int min() { - final IndexedEntry first = AbstractSparseSequence.this.first(); - if (first == null) - throw new NoSuchElementException(); - return first.index(); - } - - @Override - public int max() { - final IndexedEntry last = AbstractSparseSequence.this.last(); - if (last == null) - throw new NoSuchElementException(); - return last.index(); - } - - @Override - public boolean remove(int i) { - final boolean isMapped = containsIndex(i); - AbstractSparseSequence.this.remove(i); - return isMapped; - } - - @Override - public int floor(int i) { - final IndexedEntry floor = AbstractSparseSequence.this.floor(i); - if (floor == null) - throw new NoSuchElementException(); - return floor.index(); - } - - @Override - public int ceil(int i) { - final IndexedEntry ceil = AbstractSparseSequence.this.ceil(i); - if (ceil == null) - throw new NoSuchElementException(); - return ceil.index(); - } - - @Override - public void clear() { - AbstractSparseSequence.this.clear(); - } - - @Override - public IntSet clone() throws CloneNotSupportedException { - final IntSet s; - if (size() == 0) - s = Ints.bestSet(Integer.MIN_VALUE, Integer.MAX_VALUE); - else - s = Ints.bestSet(min(), max()); - s.addAll(this); - return s; - } - }; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#values() - */ - @Override - public Collection values() { - return new AbstractCollection() { - - @Override - public int size() { - return AbstractSparseSequence.this.size(); - } - - @Override - public boolean isEmpty() { - return AbstractSparseSequence.this.isEmpty(); - } - - @Override - public boolean contains(Object arg0) { - return AbstractSparseSequence.this.contains(arg0); - } - - @Override - public Iterator iterator() { - return new Iterator() { - - Iterator> iter = AbstractSparseSequence.this.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public V next() { - return iter.next().value(); - } - - @Override - public void remove() { - iter.remove(); - } - }; - } - - @Override - public void clear() { - AbstractSparseSequence.this.clear(); - } - }; - } - - /** - * Returns true if this sparse sequence has an entry for the given index; - * otherwise returns false. This method returns the value of - * this.iterator(index,index).hasNext(); {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#containsIndex(int) - */ - @Override - public boolean containsIndex(int index) { - return iterator(index, index).hasNext(); - } - - /** - * Iterates through all the entries in this sequence and returns true if one of - * the encountered entries has the given object as its value. - * - * @return {@inheritDoc} - * @see kodkod.util.ints.SparseSequence#contains(java.lang.Object) - */ - @Override - public boolean contains(Object value) { - for (IndexedEntry< ? > v : this) { - if (equal(value, v.value())) - return true; - } - return false; - } - - /** - * Returns the result of calling super.clone(). - * - * @see java.lang.Object#clone() - */ - @Override - @SuppressWarnings("unchecked" ) - public SparseSequence clone() throws CloneNotSupportedException { - return (SparseSequence) super.clone(); - } - - /*---------- adapted from java.util.AbstractMap -----------*/ - - /** - * Removes the entry with the given index, if it exists, and returns the value - * previously stored at the index. If the sequence had no previous mapping for - * the index, null is returned. This method obtains an iterator from index to - * index and removes its sole element, if any. {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#remove(int) - */ - @Override - public V remove(int index) { - final Iterator> itr = iterator(index, index); - if (itr.hasNext()) { - final V ret = itr.next().value(); - itr.remove(); - return ret; - } - return null; - } - - /** - * Removes all entries from this sequences. This method obtains an iterator over - * the sequences and calls remove() after each call to next(). {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#clear() - */ - @Override - public void clear() { - final Iterator> itr = iterator(); - while (itr.hasNext()) { - itr.next(); - itr.remove(); - } - } - - /** - * Throws an UnsupportedOperationException. - * - * @throws UnsupportedOperationException - */ - @Override - public V put(int index, V value) { - throw new UnsupportedOperationException(); - } - - /** - * Copies all of the entries from the specified sparse sequence to this - * sequence. This implementation calls put(e.index, e.value) on this sequence - * once for each entry e in the specified sequence. - * - * @ensures this.entries' = this.entries ++ s.entries - */ - @Override - public void putAll(SparseSequence< ? extends V> s) { - Iterator< ? extends IndexedEntry< ? extends V>> i = s.iterator(); - while (i.hasNext()) { - IndexedEntry< ? extends V> e = i.next(); - put(e.index(), e.value()); - } - } - - /** - * Returns true if both o1 and o2 are null, or o1.equals(o2) - * - * @return o1 and o2 are equal - */ - static boolean equal(Object o1, Object o2) { - return o1 == null ? o2 == null : o1.equals(o2); - } - - /** - * Returns true if the indexed entries e0 and e1 are equal to each other. - * - * @requires e0 != null && e1 != null - * @return e0.index = e1.index && e0.value = e1.value - */ - static boolean equal(IndexedEntry< ? > e0, IndexedEntry< ? > e1) { - return e0.index() == e1.index() && equal(e0.value(), e1.value()); - } - - /** - * Compares the specified object with this sequence for equality. Returns - * true if the given object is also a sequence and the two sequences - * represent the same function from integers to E. - *

- * This implementation first checks if the specified object is this sequence; if - * so it returns true. Then, it checks if the specified object is a - * sequence whose size is identical to the size of this set; if not, it returns - * false. If so, it iterates over this sequences's entries, and checks - * that the specified sequence contains each entry that this sequence contains. - * If the specified sequence fails to contain such an entry, false is - * returned. If the iteration completes, true is returned. - * - * @return o in SparseSequence && o.entries = this.entries - */ - @Override - @SuppressWarnings("unchecked" ) - public boolean equals(Object o) { - if (o == this) - return true; - - if (!(o instanceof SparseSequence)) - return false; - - SparseSequence s = (SparseSequence) o; - if (s.size() != size()) - return false; - - try { - final Iterator> i1 = iterator(), i2 = s.iterator(); - while (i1.hasNext()) { - if (!equal(i1.next(), i2.next())) - return false; - } - } catch (ClassCastException unused) { - return false; - } catch (NullPointerException unused) { - return false; - } - - return true; - } - - /** - * Returns the hashcode for an indexed entry. - * - * @requires e != null - * @return e.index ^ e.value.hashCode() - */ - static int hashCode(IndexedEntry< ? > e) { - return e.index() ^ (e.value() == null ? 0 : e.value().hashCode()); - } - - /** - * Returns the hash code value for this sparse sequence. The hash code of a - * sparse sequence is defined to be the sum of the hashCodes of each entry of - * its entries. This ensures that t1.equals(t2) implies that - * t1.hashCode()==t2.hashCode() for any two sequences t1 and t2, as required by - * the general contract of Object.hashCode. This implementation iterates over - * this.entries, calling hashCode on each IndexedEntry in the sequence, - * and adding up the results. - * - * @return sum(this.entries.hashCode()) - */ - @Override - public int hashCode() { - int h = 0; - for (IndexedEntry e : this) - h += hashCode(e); - return h; - } - - /** - * Returns a string representation of this sequence. The string representation - * consists of a list of index-value mappings in the order returned by the - * sequences iterator, enclosed in brackets ("[]"). Adjacent - * entries are separated by the characters ", " (comma and space). Each - * index-value mapping is rendered as the index followed by an equals sign - * ("=") followed by the associated value. Elements are converted to - * strings as by String.valueOf(Object). - *

- * This implementation creates an empty string buffer, appends a left bracket, - * and iterates over the map's entries, appending the string representation of - * each IndexedEntry in turn. After appending each entry except the - * last, the string ", " is appended. Finally a right bracket is - * appended. A string is obtained from the stringbuffer, and returned. - * - * @return a String representation of this map. - */ - @Override - public String toString() { - final StringBuilder buf = new StringBuilder(); - buf.append("["); - - final Iterator> i = iterator(); - boolean hasNext = i.hasNext(); - while (hasNext) { - IndexedEntry e = i.next(); - buf.append(e.index()); - buf.append("="); - if (e.value() == this) - buf.append("(this sequence)"); - else - buf.append(e.value()); - hasNext = i.hasNext(); - if (hasNext) - buf.append(", "); - } - - buf.append("]"); - return buf.toString(); - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArrayIntSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArrayIntSet.java deleted file mode 100644 index 22f015288..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArrayIntSet.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Arrays; -import java.util.NoSuchElementException; - -/** - * An immutable set of integers, stored in a sorted array. - * - * @specfield ints: set int - * @author Emina Torlak - */ -public final class ArrayIntSet extends AbstractIntSet { - - private final int[] ints; - private final int hashcode; - - /** - * Constructs a set view for the given array. The array must contain no - * duplicates, its elements must be sorted in the ascending order, and its - * contents must not be changed while it is in use by this set - * - * @requires all i, j: [0..ints.length) | i < j => array[i] <= array[j] - * @ensures this.ints' = ints - */ - public ArrayIntSet(int[] ints) { - this.ints = ints; - this.hashcode = Ints.superFastHash(ints); - } - - /** - * Constructs an ArrayIntSet that is equal to the given set. - * - * @ensures this.ints' = s.ints - */ - public ArrayIntSet(IntSet s) { - this(s.toArray()); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#iterator(int, int) - */ - @Override - public IntIterator iterator(final int from, final int to) { - return from <= to ? new AscendingIntArrayIterator(from, to) : new DescendingIntArrayIterator(from, to); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#size() - */ - @Override - public int size() { - return ints.length; - } - - /** - * @see kodkod.util.ints.IntSet#ceil(int) - */ - @Override - public int ceil(int i) { - final int index = Arrays.binarySearch(ints, i); - if (index == -ints.length - 1) - throw new NoSuchElementException(); - else - return index >= 0 ? ints[index] : ints[-index - 1]; - } - - /** - * @see kodkod.util.ints.IntSet#floor(int) - */ - @Override - public int floor(int i) { - final int index = Arrays.binarySearch(ints, i); - if (index == -1) - throw new NoSuchElementException(); - else - return index >= 0 ? ints[index] : ints[-index - 2]; - } - - /** - * Returns true if i is in this set. - * - * @return i in this.ints - * @see kodkod.util.ints.IntSet#contains(int) - */ - @Override - public boolean contains(int i) { - return Arrays.binarySearch(ints, i) >= 0; - } - - /** - * Returns the smallest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return min(this.ints) - * @throws java.util.NoSuchElementException no this.ints - * @see kodkod.util.ints.IntSet#max() - */ - @Override - public int max() { - if (ints.length == 0) - throw new NoSuchElementException(); - return ints[ints.length - 1]; - } - - /** - * Returns the largest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return max(this.ints) - * @throws java.util.NoSuchElementException no this.ints - * @see kodkod.util.ints.IntSet#min() - */ - @Override - public int min() { - if (ints.length == 0) - throw new NoSuchElementException(); - return ints[0]; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#toArray() - */ - @Override - public int[] toArray() { - final int[] ret = new int[ints.length]; - System.arraycopy(ints, 0, ret, 0, ints.length); - return ret; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#toArray(int[]) - */ - @Override - public int[] toArray(int[] array) { - if (array.length < size()) { - array = new int[ints.length]; - } - System.arraycopy(ints, 0, array, 0, ints.length); - return array; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#hashCode() - */ - @Override - public int hashCode() { - return hashcode; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - return (o instanceof ArrayIntSet) ? java.util.Arrays.equals(ints, ((ArrayIntSet) o).ints) : super.equals(o); - } - - /** - * An iterator that returns the elements of this int set in the ascending order. - * - * @author Emina Torlak - */ - private final class AscendingIntArrayIterator implements IntIterator { - - private int next, end; - - /** - * Constructs a new AscendingIntArrayIterator. - * - * @requires from <= to - */ - AscendingIntArrayIterator(int from, int to) { - final int fromIndex = Arrays.binarySearch(ints, from); - final int toIndex = Arrays.binarySearch(ints, to); - next = fromIndex >= 0 ? fromIndex : -fromIndex - 1; - end = toIndex >= 0 ? toIndex : -toIndex - 2; - } - - @Override - public boolean hasNext() { - return next >= 0 && next <= end; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - return ints[next++]; - } - - @Override - public final void remove() { - throw new UnsupportedOperationException(); - } - } - - /** - * An iterator that returns the elements of this int set in the descending - * order. - * - * @author Emina Torlak - */ - private final class DescendingIntArrayIterator implements IntIterator { - - private int next, end; - - /** - * Constructs a new AscendingIntArrayIterator. - * - * @requires from >= to - */ - DescendingIntArrayIterator(int from, int to) { - final int fromIndex = Arrays.binarySearch(ints, from); - final int toIndex = Arrays.binarySearch(ints, to); - next = fromIndex >= 0 ? fromIndex : -fromIndex - 2; - end = toIndex >= 0 ? toIndex : -toIndex - 1; - } - - @Override - public boolean hasNext() { - return next >= end; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - return ints[next--]; - } - - @Override - public final void remove() { - throw new UnsupportedOperationException(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArrayIntVector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArrayIntVector.java deleted file mode 100644 index fdfadbdc5..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArrayIntVector.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * A mutable implementation of the IntVector interface. Implements all - * optional IntVector operations. In addition to implementing the - * IntVector interface, this class provides methods to manipulate the - * size of the array that is used internally to store the elements of the - * IntVector. - *

- * The size, isEmpty, get, set, and - * iterator operations run in constant time. The insert - * operations run in amortized constant time, that is, adding n elements - * requires O(n) time. All of the other operations run in linear time (roughly - * speaking). - *

- * Each MutableIntVector instance has a capacity. The capacity - * is the size of the array used to store the elements in the list. It is always - * at least as large as the list size. As elements are added to a - * MutableIntVector, its capacity grows automatically. The details of the growth - * policy are not specified beyond the fact that adding an element has constant - * amortized time cost. - *

- * An application can increase the capacity of an MutableIntVector - * instance before adding a large number of elements using the - * ensureCapacity operation. This may reduce the amount of incremental - * reallocation. - *

- * This impementation is not synchronized and its iterators are not fail-fast. - * - * @author Emina Torlak - */ -public final class ArrayIntVector extends AbstractIntVector { - - private int[] elements; - private int size; - - /** - * Constructs an empty MutableIntVector with the specified initial - * capacity. - * - * @exception IllegalArgumentException if the specified initial capacity is - * negative - */ - public ArrayIntVector(int initialCapacity) { - if (initialCapacity < 0) - throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity); - this.elements = new int[initialCapacity]; - } - - /** - * Constructs an empty MutableIntVector with an initial capacity of - * ten. - */ - public ArrayIntVector() { - this(10); - } - - /** - * Constructs a MutableIntVector containing the elements of the - * specified array, in proper sequence. The MutableIntVector instance - * has an initial capacity of 110% the size of the specified collection. - * - * @throws NullPointerException if the specified array is null. - */ - public ArrayIntVector(int[] array) { - size = array.length; - // Allow 10% room for growth - int capacity = (int) Math.min((size * 110L) / 100, Integer.MAX_VALUE); - elements = new int[capacity]; - System.arraycopy(array, 0, elements, 0, size); - } - - /** - * Trims the capacity of this MutableIntVector instance to be the - * list's current size. An application can use this operation to minimize the - * storage of an MutableIntVector instance. - */ - public void trimToSize() { - - int oldCapacity = elements.length; - if (size < oldCapacity) { - int[] oldData = elements; - elements = new int[size]; - System.arraycopy(oldData, 0, elements, 0, size); - } - } - - /** - * Increases the capacity of this MutableIntVector instance, if - * necessary, to ensure that it can hold at least the number of elements - * specified by the minimum capacity argument. - */ - public void ensureCapacity(int minCapacity) { - - int oldCapacity = elements.length; - if (minCapacity > oldCapacity) { - int[] oldData = elements; - int newCapacity = (oldCapacity * 3) / 2 + 1; - if (newCapacity < minCapacity) - newCapacity = minCapacity; - elements = new int[newCapacity]; - System.arraycopy(oldData, 0, elements, 0, size); - } - } - - /** - * @throws IndexOutOfBoundsException index < 0 or index >= size - */ - private void checkExcludeLength(int index) { - if (index < 0 || index >= size) - throw new IndexOutOfBoundsException(); - } - - /** - * @throws IndexOutOfBoundsException index < 0 or index > size - */ - private void checkIncludeLength(int index) { - if (index < 0 || index > size) - throw new IndexOutOfBoundsException(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#get(int) - */ - @Override - public int get(int index) { - checkExcludeLength(index); - return elements[index]; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#size() - */ - @Override - public int size() { - return size; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#set(int, int) - */ - @Override - public int set(int index, int element) { - final int oldValue = get(index); - elements[index] = element; - return oldValue; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#add(int) - */ - @Override - public boolean add(int element) { - ensureCapacity(size + 1); - elements[size++] = element; - return true; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#add(int, int) - */ - @Override - public void add(int index, int element) { - checkIncludeLength(index); - - ensureCapacity(size + 1); - System.arraycopy(elements, index, elements, index + 1, size - index); - elements[index] = element; - size++; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntVector#addAll(int, kodkod.util.ints.IntCollection) - */ - @Override - public boolean addAll(int index, IntCollection c) { - checkIncludeLength(index); - - final int csize = c.size(); - if (csize == 0) - return false; - - ensureCapacity(size + csize); - System.arraycopy(elements, index, elements, index + csize, size - index); - - for (IntIterator iter = c.iterator(); iter.hasNext();) { - elements[index++] = iter.next(); - } - - return true; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.AbstractIntVector#removeAt(int) - */ - @Override - public int removeAt(int index) { - checkExcludeLength(index); - final int old = elements[index]; - System.arraycopy(elements, index + 1, elements, index, size - index - 1); - size--; - return old; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.AbstractIntCollection#toArray(int[]) - */ - @Override - public int[] toArray(int[] array) { - if (array.length < size) { - array = new int[size]; - } - System.arraycopy(elements, 0, array, 0, size); - return array; - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArraySequence.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArraySequence.java deleted file mode 100644 index 510845edb..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/ArraySequence.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * An implementation of a sparse sequence based on an array. This implementation - * can be used only when the indices of the sequence are known in advance. The - * indices with which an ArraySequence is construct remain fixed throughout. The - * put operation fails whenever its index argument is not one of the sequence's - * pre-set indices, and iteration time is proportional to the number of pre-set - * indices. This sequence does not allow null values. The lookup and put - * operations are logarithmic in the number of pre-set indices. - * - * @specfield indeces: set int - * @specfield entries: indeces -> lone (V - null) - * @author Emina Torlak - */ -public final class ArraySequence extends AbstractSparseSequence implements Cloneable { - - private final EntryView[] entries; - private int size; - - /** - * Constructs an array sequence that contains the given indeces. - * - * @ensures this.indeces' = indeces && no this.entries' - * @throws NullPointerException indeces = null - */ - @SuppressWarnings("unchecked" ) - public ArraySequence(IntSet indices) { - this.entries = new EntryView[indices.size()]; - this.size = indices.size(); - final IntIterator indexIter = indices.iterator(); - for (int i = 0; indexIter.hasNext(); i++) { - entries[i] = new EntryView(indexIter.next(), null); - } - } - - /** - * Constructs a new array sequence with the same index/value mappings as the - * given sequence. - * - * @ensures this.entries' = s.entries - * @throws NullPointerException s = null || null in s - */ - @SuppressWarnings("unchecked" ) - public ArraySequence(SparseSequence< ? extends V> s) { - this.entries = new EntryView[s.size()]; - this.size = s.size(); - int i = 0; - for (IndexedEntry< ? > entry : s) { - if (entry.value() == null) - throw new NullPointerException(); - entries[i++] = new EntryView(entry.index(), (V) entry.value()); - } - } - - /** - * Copy constructor. - * - * @ensures constructs a deep copy of the original array sequence. - */ - @SuppressWarnings("unchecked" ) - private ArraySequence(ArraySequence original) { - this.size = original.size; - this.entries = new EntryView[original.entries.length]; - int i = 0; - for (EntryView e : original.entries) - this.entries[i++] = new EntryView(e.index(), e.value()); - } - - /** - * Returns the number of entries in this sequence. - * - * @return #this.entries - * @see kodkod.util.ints.SparseSequence#size() - */ - @Override - public int size() { - return size; - } - - /** - * Returns true if this sequence is empty; otherwise returns false. - * - * @return no this.entries - * @see kodkod.util.ints.SparseSequence#isEmpty() - */ - @Override - public boolean isEmpty() { - return size == 0; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#clear() - */ - @Override - public void clear() { - for (EntryView e : entries) { - e.setValue(null); - } - } - - /** - * Searches this.entries for the specified index using the binary search - * algorithm. If the index is not found, then -insertionPoint - 1 is returned, - * where insertionPoint is the point at which the given index would be inserted - * into this.entries. - * - * @return the position in this.entries where the entry with the given index is - * located, or -insertionPoint - 1 if the index is not in this.indeces - */ - private final int search(int index) { - int low = 0; - int high = entries.length - 1; - - while (low <= high) { - int mid = (low + high) >>> 1; - int midIndex = entries[mid].index(); - if (midIndex < index) - low = mid + 1; - else if (midIndex > index) - high = mid - 1; - else - return mid; // key found - } - - return -(low + 1); // key not found. - } - - /** - * Puts the given value at the specified index. If the sequence already mapped - * the index to a value, the previous value is replaced with the new one and - * returned. - * - * @ensures this.entries' = this.entries + index->value - * @return this.entries[index] - * @throws IndexOutOfBoundsException index !in this.indeces - * @throws NullPointerException value = null - * @see kodkod.util.ints.SparseSequence#put(int, Object) - */ - @Override - public V put(int index, V value) { - if (value == null) - throw new NullPointerException(); - final int position = search(index); - if (position < 0) - throw new IndexOutOfBoundsException("" + index); - if (entries[position] == null) - size++; - return entries[position].setValue(value); - } - - /** - * Returns the value to which this sequence maps the given index. If the index - * is not mapped, null is returned. - * - * @return this.entries[index] - * @see kodkod.util.ints.SparseSequence#get(int) - */ - @Override - public V get(int index) { - final int position = search(index); - return position < 0 ? null : entries[position].value(); - } - - /** - * Removes the entry with the given index, if it exists, and returns the value - * previously stored at the index. If the sequence had no previous mapping for - * the index, null is returned. - * - * @ensures this.entries' = this.entries - index->E - * @return this.entries[index] - * @see kodkod.util.ints.SparseSequence#remove(int) - */ - @Override - public V remove(int index) { - final int position = search(index); - if (position < 0) - return null; - else { - if (entries[position].value() != null) - size--; - return entries[position].setValue(null); - } - } - - /** - * Returns true if this sparse sequence has an entry for the given index; - * otherwise returns false. - * - * @return index in this.indeces - * @see kodkod.util.ints.SparseSequence#containsIndex(int) - */ - @Override - public boolean containsIndex(int index) { - final int position = search(index); - return position >= 0 && entries[position].value() != null; - } - - /** - * Returns an iterator over the entries in this sequence, whose indeces are - * between from and to. If from < to, the entries are returned in the ascending - * order of indeces. Otherwise, they are returned in the descending order of - * indeces. - * - * @return an iterator over the entries in this sequence whose indeces are - * between from and to. Formally, if from < to, then the first and last - * entries returned by the iterator are this.ceil(from) and - * this.floor(to). Otherwise, they are this.floor(from) and - * this.ceil(to). - * @see kodkod.util.ints.SparseSequence#iterator(int, int) - */ - @Override - public Iterator> iterator(int from, int to) { - return from <= to ? new AscendingIterator(from, to) : new DescendingIterator(from, to); - } - - /** - * Returns the entry with the smallest index. If the sequence is empty, returns - * null. - * - * @return {e: IndexedEntry | e.index = min(this.entries.E) && e.value = - * this.entries[e.index] } - * @see kodkod.util.ints.SparseSequence#first() - */ - @Override - public IndexedEntry first() { - if (size == 0) - return null; - for (EntryView e : entries) { - if (e.value() != null) - return e; - } - throw new InternalError(); // unreachable code - } - - /** - * Returns the entry with the largest index. If the sequence is empty, returns - * null. - * - * @return {e: IndexedEntry | e.index = max(this.entries.E) && e.value = - * this.entries[e.index] } - * @see kodkod.util.ints.SparseSequence#last() - */ - @Override - public IndexedEntry last() { - if (size == 0) - return null; - for (int i = entries.length - 1; i >= 0; i--) { - if (entries[i].value() != null) - return entries[i]; - } - throw new InternalError(); // unreachable code - } - - /** - * If an entry for the given index exists, it is returned. Otherwise, - * successor(index) is returned. - * - * @return this.containsIndex(index) => {e: IndexedEntry | e.index = index && - * e.value = this.entries[index] }, successor(index) - * @see kodkod.util.ints.SparseSequence#ceil(int) - */ - @Override - public IndexedEntry ceil(int index) { - final int position = search(index); - for (int i = position < 0 ? -position - 1 : position; i < entries.length; i++) { - if (entries[i].value() != null) - return entries[i]; - } - return null; - } - - /** - * If an entry for the given index exists, it is returned. Otherwise, - * predecessor(index) is returned. - * - * @return this.containsIndex(index) => {e: IndexedEntry | e.index = index && - * e.value = this.entries[index] }, predecessor(index) - * @see kodkod.util.ints.SparseSequence#floor(int) - */ - @Override - public IndexedEntry floor(int index) { - final int position = search(index); - for (int i = position < -1 ? -position - 2 : position; i >= 0; i--) { - if (entries[i].value() != null) - return entries[i]; - } - return null; - } - - /** - * Returns a copy of this sparse sequence. The copy is independent of this - * sequence. - * - * @return a copy of this sparse sequence. - * @see kodkod.util.ints.SparseSequence#clone() - */ - @Override - public ArraySequence clone() { - return new ArraySequence(this); - } - - /** - * An iterator that traverses this sequence in the ascending order. - * - * @author Emina Torlak - */ - private final class AscendingIterator implements Iterator> { - - final int endIndex; - IndexedEntry lastReturned = null; - int cursor; - - /** - * @requires from <= to - */ - AscendingIterator(int from, int to) { - final int fromPos = search(from); - final int toPos = search(to); - cursor = fromPos < 0 ? -fromPos - 1 : fromPos; - endIndex = toPos < -1 ? -toPos - 2 : toPos; - } - - @Override - public boolean hasNext() { - while (cursor < entries.length && entries[cursor].value() == null) - cursor++; - return cursor <= endIndex; - } - - @Override - public IndexedEntry next() { - if (!hasNext()) - throw new NoSuchElementException(); - return lastReturned = entries[cursor++]; - } - - @Override - public void remove() { - if (lastReturned == null) - throw new IllegalStateException(); - entries[lastReturned.index()].setValue(null); - lastReturned = null; - } - } - - /** - * An iterator that traverses this sequence in the descending order. - * - * @author Emina Torlak - */ - private final class DescendingIterator implements Iterator> { - - final int endIndex; - IndexedEntry lastReturned = null; - int cursor; - - /** - * @requires from >= to - */ - DescendingIterator(int from, int to) { - final int fromPos = search(from); - final int toPos = search(to); - cursor = fromPos < -1 ? -fromPos - 2 : fromPos; - endIndex = toPos < 0 ? -toPos - 1 : toPos; - } - - @Override - public boolean hasNext() { - while (cursor >= 0 && entries[cursor].value() == null) - cursor--; - return cursor >= endIndex; - } - - @Override - public IndexedEntry next() { - if (!hasNext()) - throw new NoSuchElementException(); - return lastReturned = entries[cursor--]; - } - - @Override - public void remove() { - if (lastReturned == null) - throw new IllegalStateException(); - entries[lastReturned.index()].setValue(null); - lastReturned = null; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/EntryView.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/EntryView.java deleted file mode 100644 index ee86d800d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/EntryView.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * A mutable IndexedEntry. This class provides various convience method for - * changing the entry state. - * - * @author Emina Torlak - */ -class EntryView implements IndexedEntry { - - private int index; - private V value; - - /** - * Constructs a new entry view with the given index and value. - * - * @ensures this.index' = index and this.value' = value - */ - EntryView(int index, V value) { - this.index = index; - this.value = value; - } - - /** - * Sets this.index to the given index, and returns the old index. - * - * @ensures this.index' = newIndex - * @return this.index - */ - int setIndex(int newIndex) { - final int oldIndex = this.index; - this.index = newIndex; - return oldIndex; - } - - /** - * Sets this.value to the given value, and returns the old value. - * - * @ensures this.value' = newValue - * @return this.value - */ - V setValue(V newValue) { - final V oldValue = this.value; - this.value = newValue; - return oldValue; - } - - /** - * Sets this.index and this.value to the given index and value, and returns - * this. - * - * @ensures this.index' = newIndex && this.value' = newValue - * @return this - */ - IndexedEntry setView(int newIndex, V newValue) { - this.index = newIndex; - this.value = newValue; - return this; - } - - /** - * Sets this.index to the given index, and returns this. - * - * @ensures this.index' = newIndex - * @return this - */ - IndexedEntry setIndexView(int newIndex) { - this.index = newIndex; - return this; - } - - /** - * Sets this.value to the given value, and returns this. - * - * @ensures this.value' = newValue - * @return this - */ - IndexedEntry setValueView(V newValue) { - this.value = newValue; - return this; - } - - /** - * @see kodkod.util.ints.IndexedEntry#index() - */ - @Override - public int index() { - return index; - } - - /** - * @see kodkod.util.ints.IndexedEntry#value() - */ - @Override - public V value() { - return value; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public final String toString() { - return index + "=" + value; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public final boolean equals(Object o) { - if (o == this) - return true; - if (!(o instanceof IndexedEntry)) - return false; - return AbstractSparseSequence.equal(this, (IndexedEntry< ? >) o); - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public final int hashCode() { - return AbstractSparseSequence.hashCode(this); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/HomogenousSequence.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/HomogenousSequence.java deleted file mode 100644 index 733509a05..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/HomogenousSequence.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Iterator; - -/** - * A sparse sequence implementation based on an {@link kodkod.util.ints.IntSet - * IntSet}. This implementation can be used only when all entries in the - * sequence map to the same value. - *

- * Important Implementation Note: As this implementation does not - * actually store any {@link kodkod.util.ints.IndexedEntry indexed entries}, the - * methods {@link #first()}, {@link #last()}, {@link #ceil(int)}, and - * {@link #floor(int)} may re-use the same IndexedEntry object. For - * example, suppose that an entry e with e.index = 1 is - * returned by a call to predecessor(2) on a homogenous sequence - * h = {<0,v>, <1,v>, <2,v>}. A subsequent call to - * h.predecessor(1) may return the same object e, with its - * index set to 0. Hence, the following assertion may fail: - *

- * - *
- * IndexedEntry e1 = h.predecessor(2);
- * assert e1.index() == 1; // this will work
- * IndexedEntry e2 = h.predecessor(1);
- * assert e1.index() == 1; // this may fail, as e1 may be == to e2
- * 
- *

- * The entries returned by this implementation's {@link #iterator()} are unique - * to that iterator (but not necessarily independent of each other). For - * example, - *

- * - *
- * // let s be a range sequence abstractly represented as { 0->v, 1->v, 2->v }
- * Iterator> iter1 = s.iterator();
- * IndexedEntry e1 = iter1.next();
- * assert e1.index() == 0; // this will work
- * iter1.next();
- * assert e1.index() == 0; // this may fail, as the previous call may have
- *                        // changed the state of e1
- * Iterator> iter2 = s.iterator();
- * IndexedEntry e2 = iter2.next();
- * iter1.next();
- * assert e2.index() == 0; // this will work
- * 
- * - * @specfield indeces: set int - * @specfield entries: indeces -> one V - * @author Emina Torlak - */ -public final class HomogenousSequence extends AbstractSparseSequence { - - private final IntSet indices; - private final V value; - private final EntryView view; - - /** - * Constructs a new homogenous sequence for the given value, backed by a - * {@link IntTreeSet IntTreeSet} instance. - * - * @ensures this.value' = value && no this.indices' - */ - public HomogenousSequence(V value) { - this.value = value; - this.indices = new IntTreeSet(); - this.view = new EntryView(Integer.MIN_VALUE, value); - } - - /** - * Constructs a new homogenous sequence for the given value, backed by the - * specified intset. Any changes to the provided set will be reflected in this - * sequence, and vice versa. This sequence will be unmodifiable if the given - * index set is unmodifiable. - * - * @requires indices is cloneable - * @ensures this.value' = value && this.indices' = indices - */ - public HomogenousSequence(V value, IntSet indices) { - this.value = value; - this.indices = indices; - this.view = new EntryView(Integer.MIN_VALUE, value); - } - - /** - * Copy constructor - * - * @ensures constructs a deep copy of the original - */ - private HomogenousSequence(HomogenousSequence original) { - this.value = original.value; - this.view = new EntryView(Integer.MIN_VALUE, value); - try { - this.indices = original.indices.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code. - } - } - - /** - * Constructs a new homogeneous sequence from the provided sequence. The - * returned sequence is backed by a {@link IntTreeSet IntTreeSet} instance. - * - * @requires one seq.entries[int] - * @ensures this.value' = seq.entries[int] && this.indices' = seq.indices() - * @throws NullPointerException seq = null - * @throws IllegalArgumentException seq.isEmpty() - * @throws IllegalArgumentException #seq.entries[int] > 1 - */ - public HomogenousSequence(SparseSequence< ? extends V> seq) { - if (seq.isEmpty()) - throw new IllegalArgumentException(); - this.indices = new IntTreeSet(); - this.value = seq.first().value(); - this.view = new EntryView(Integer.MIN_VALUE, value); - for (IndexedEntry< ? > e : seq) { - if (!value.equals(e.value())) - throw new IllegalArgumentException(); - indices.add(e.index()); - } - } - - /** - * Returns the set of all indices mapped by this sparse sequence. The returned - * set supports removal and addition iff this is not backed by an unmodifiable - * intset. - * - * @return {s: IntSet | s.ints = this.entries.V} - */ - @Override - public IntSet indices() { - return indices; - } - - /** - * Returns an iterator over the entries in this sequence, whose indeces are - * between from and to. If from < to, the entries are returned in the ascending - * order of indeces. Otherwise, they are returned in the descending order of - * indeces. - *

- * While the returned iterator i re-uses the same IndexedEntry object, it - * is not shared with other iterators or other method calls. In particular, no - * other call except i.next() can change the value of the re-used - * object. - *

- * - * @return an iterator over the entries in this sequence whose indeces are - * between from and to. Formally, if from < to, then the first and last - * entries returned by the iterator are this.ceil(from) and - * this.floor(to). Otherwise, they are this.floor(from) and - * this.ceil(to). - * @see kodkod.util.ints.AbstractSparseSequence#iterator(int, int) - */ - @Override - public Iterator> iterator(int from, int to) { - return new HomogenousIterator(indices.iterator(from, to), value); - } - - /** - * Returns the number of entries in this sequence. - * - * @return #this.entries - * @see kodkod.util.ints.SparseSequence#size() - */ - @Override - public int size() { - return indices.size(); - } - - /** - * Removes all entries from this sequences. - * - * @ensures no this.entries' - * @see kodkod.util.ints.SparseSequence#clear() - */ - @Override - public void clear() { - indices.clear(); - } - - /** - * Puts the given value at the specified index. If the sequence already mapped - * the index to a value, the previous value is replaced with the new one and - * returned. - * - * @requires this.value = value - * @ensures this.indices' = this.indices + index - * @return this.entries[index] - * @throws IllegalArgumentException this.value != value - * @see kodkod.util.ints.SparseSequence#put(int, Object) - */ - @Override - public V put(int index, V value) { - if (!equal(this.value, value)) - throw new IllegalArgumentException(); - return indices.add(index) ? null : value; - } - - /** - * Returns the value to which this sequence maps the given index. If the index - * is not mapped, null is returned. - * - * @return this.entries[index] - * @see kodkod.util.ints.SparseSequence#get(int) - */ - @Override - public V get(int index) { - return indices.contains(index) ? value : null; - } - - /** - * Removes the entry with the given index, if it exists, and returns the value - * previously stored at the index. If the sequence had no previous mapping for - * the index, null is returned. - * - * @ensures this.entries' = this.entries - index->E - * @return this.entries[index] - * @see kodkod.util.ints.SparseSequence#remove(int) - */ - @Override - public V remove(int index) { - return indices.remove(index) ? value : null; - } - - /** - * Returns true if this sparse sequence has an entry for the given index; - * otherwise returns false. - * - * @return some this.entries[index] - * @see kodkod.util.ints.SparseSequence#containsIndex(int) - */ - @Override - public boolean containsIndex(int index) { - return indices.contains(index); - } - - /** - * Returns true if this sequence has an entry with the given value; otherwise - * returns false. - * - * @return some this.indices && this.value = value - * @see kodkod.util.ints.SparseSequence#contains(java.lang.Object) - */ - @Override - public boolean contains(Object value) { - return !indices.isEmpty() && equal(this.value, value); - } - - /** - * Returns the entry with the smallest index. If the sequence is empty, returns - * null. - * - * @return {e: IndexedEntry | e.index = min(this.entries.E) && e.value = - * this.entries[e.index] } - * @see kodkod.util.ints.SparseSequence#first() - */ - @Override - public IndexedEntry first() { - return indices.isEmpty() ? null : view.setIndexView(indices.min()); - } - - /** - * Returns the entry with the largest index. If the sequence is empty, returns - * null. - * - * @return {e: IndexedEntry | e.index = max(this.entries.E) && e.value = - * this.entries[e.index] } - * @see kodkod.util.ints.SparseSequence#last() - */ - @Override - public IndexedEntry last() { - return indices.isEmpty() ? null : view.setIndexView(indices.max()); - } - - /** - * If an entry for the given index exists, it is returned. Otherwise, - * successor(index) is returned. - * - * @return this.containsIndex(index) => {e: IndexedEntry | e.index = index && - * e.value = this.entries[index] }, successor(index) - * @see kodkod.util.ints.SparseSequence#ceil(int) - */ - @Override - public IndexedEntry ceil(int index) { - if (indices.isEmpty() || index > indices.max()) - return null; - else - return view.setIndexView(indices.ceil(index)); - } - - /** - * If an entry for the given index exists, it is returned. Otherwise, - * predecessor(index) is returned. - * - * @return this.containsIndex(index) => {e: IndexedEntry | e.index = index && - * e.value = this.entries[index] }, predecessor(index) - * @see kodkod.util.ints.SparseSequence#floor(int) - */ - @Override - public IndexedEntry floor(int index) { - if (indices.isEmpty() || index < indices.min()) - return null; - else - return view.setIndexView(indices.floor(index)); - } - - /** - * Returns a copy of this sparse sequence. The copy is independent of this - * sequence. - * - * @return a copy of this sparse sequence. - * @see kodkod.util.ints.SparseSequence#clone() - */ - @Override - public HomogenousSequence clone() { - // ok to clone a final class using a copy constructor - return new HomogenousSequence(this); - } - - /** - * An iterator over a homogenous sequence. - * - * @author Emina Torlak - */ - private static final class HomogenousIterator extends EntryView implements Iterator> { - - private final IntIterator iter; - - /** - * Constructs a wrapper for the given IntIterator and value - */ - HomogenousIterator(IntIterator iter, V value) { - super(Integer.MIN_VALUE, value); - this.iter = iter; - } - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public IndexedEntry next() { - return setIndexView(iter.next()); - } - - @Override - public void remove() { - iter.remove(); - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IndexedEntry.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IndexedEntry.java deleted file mode 100644 index 3364791da..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IndexedEntry.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * An entry in a {@link SparseSequence sparse sequence}. - * - * @specfield index: int - * @specfield value: E - * @author Emina Torlak - */ -public interface IndexedEntry { - - /** - * Returns the index of this entry. - * - * @return this.index - */ - public abstract int index(); - - /** - * Returns the value stored in this entry. - * - * @return this.value - */ - public abstract E value(); - - /** - * Compares the specified object with this entry for equality. Returns true if - * the given object is also an indexed entry and the two entries have the same - * indeces and values. More formally, two entries e1 and e2 are equal if - * e1.index = e2.index && e1.value = e2.value. This ensures that the equals - * method works properly across different implementations of the IndexedEntry - * interface. - * - * @return o in IndexedEntry && o.index = this.index && o.value = this.value - */ - @Override - public abstract boolean equals(Object o); - - /** - * Returns the hash code value for this indexed entry. The hash code of an - * indexed entry e is defined to be: e.index ^ (e.value=null ? 0 : - * e.value.hashCode()). This ensures that e1.equals(e2) implies that - * e1.hashCode()==e2.hashCode() for any two IndexedEntries e1 and e2, as - * required by the general contract of Object.hashCode. - */ - @Override - public abstract int hashCode(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntBitSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntBitSet.java deleted file mode 100644 index a9a32afc1..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntBitSet.java +++ /dev/null @@ -1,573 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Arrays; -import java.util.NoSuchElementException; - -/** - * An implementation of the IntSet interface based on a bit map. An IntBitSet - * can store only numbers in the half-open range [0..capacity) where capacity is - * a user-specified value. The implementation will allocated enough bits to - * explicitly represent all allowed integers; it performs better than a tree set - * when the stored integers are not clustered. - * - * @specfield capacity: [0..Integer.MAX_VALUE] - * @invariant all i: this.ints | 0 <= i < capacity - * @author Emina Torlak - */ -public final class IntBitSet extends AbstractIntSet implements Cloneable { - - // implementation adapted from java.util.JumboEnumSet - private final int capacity; - /* - * Bit vector representation of this set. The ith bit of the jth element of this - * array represents the presence of universe[64*j +i] in this set. - */ - private long elements[]; - - // Redundant - maintained for performance - private int size; - - /** - * Constructs an empty IntBitSet that can store up to capacity elements. - * - * @ensures no this.ints' && this.capacity' = capacity - * @throws IllegalArgumentException capacity < 0 - */ - public IntBitSet(int capacity) { - if (capacity < 0) - throw new IllegalArgumentException("capacity < 0"); - this.capacity = capacity; - elements = new long[(capacity >>> 6) + 1]; - size = 0; - } - - /** - * Constructs an IntBitSet that can store up to capacity elements. The set is - * initialized to contain all integers i such that data[i>>>6] & (1L<>>6] & (1L<>>6)+1 > data.length - * @throws IllegalArgumentException capacity is out of range - */ - public IntBitSet(int capacity, long[] data) { - if (capacity > (data.length << 6)) - throw new IllegalArgumentException("capacity too large: " + capacity + ", max: " + (data.length << 6)); - this.capacity = capacity; - this.elements = data; - recalculateSize(); - - // System.out.println("capacity: " + capacity + ", max: " + max() + ", - // data.length: " + data.length); - // System.out.println(Arrays.toString(data)); - if (size > 0 && capacity <= max()) - throw new IllegalArgumentException("capacity too small"); - } - - /** - * Returns the smallest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return min(this.ints) - * @throws java.util.NoSuchElementException no this.ints - * @see kodkod.util.ints.IntSet#min() - */ - @Override - public int min() { - checkNonEmpty(); - int minWordIndex = 0; - while (elements[minWordIndex] == 0) { - minWordIndex++; - } - return (minWordIndex << 6) + Long.numberOfTrailingZeros(elements[minWordIndex]); - } - - /** - * Returns the largest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return max(this.ints) - * @throws java.util.NoSuchElementException no this.ints - * @see kodkod.util.ints.IntSet#max() - */ - @Override - public int max() { - checkNonEmpty(); - int maxWordIndex = elements.length - 1; - while (elements[maxWordIndex] == 0) { - maxWordIndex--; - } - return (maxWordIndex << 6) + 63 - Long.numberOfLeadingZeros(elements[maxWordIndex]); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#ceil(int) - */ - @Override - public int ceil(int i) { - if (i <= 0) - return min(); - int wordIndex = wordIndex(i); - long word = 0; - if (wordIndex < elements.length) { - word = (extendedMask(i) & elements[wordIndex]); - } - while (word == 0 && wordIndex < elements.length - 1) { - word = elements[++wordIndex]; - } - if (word == 0) - throw new NoSuchElementException(); - else - return (wordIndex << 6) + Long.numberOfTrailingZeros(word); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#floor(int) - */ - @Override - public int floor(int i) { - if (i < 0) - throw new NoSuchElementException(); - int wordIndex = wordIndex(i); - long word = 0; - if (wordIndex < elements.length) { - word = ((~extendedMask(i + 1)) & elements[wordIndex]); - } else { - wordIndex = elements.length - 1; - word = elements[wordIndex]; - } - while (word == 0 && wordIndex > 0) { - word = elements[--wordIndex]; - } - if (word == 0) - throw new NoSuchElementException(); - else - return (wordIndex << 6) + 63 - Long.numberOfLeadingZeros(word); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#iterator() - */ - @Override - public IntIterator iterator() { - return new AscendingIterator(0, capacity); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#iterator(int, int) - */ - @Override - public IntIterator iterator(int from, int to) { - return from > to ? new DescendingIterator(from, to) : new AscendingIterator(from, to); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#size() - */ - @Override - public int size() { - return size; - } - - /** - * Returns the capacity of this int bit set - * - * @return this.capacity - */ - public int capacity() { - return capacity; - } - - /** - * Returns the index of the word that contains the bit that represents the - * integer i. - * - * @requires 0 <= i < this.capacity - */ - private final int wordIndex(int i) { - return i >>> 6; - } - - /** - * Returns a bit mask that has 1 in the position representing the given integer - * within its word (obtained by wordIndex(i)) - * - * @requires 0 <= i < this.capacity - */ - private final long bitMask(int i) { - return 1L << i; - } - - /** - * Returns a bit mask that has 1 at every index greater than or equal to the - * position representing the given integer within its word. - * - * @requires 0 <= i < this.capacity - */ - private final long extendedMask(int i) { - return -1L << i; - } - - /** - * @return i in [0..this.capacity) - */ - private final boolean allows(int i) { - return 0 <= i && i < capacity; - } - - /** - * Returns true if i is in this set. - * - * @return i in this.ints - * @see kodkod.util.ints.IntSet#contains(int) - */ - @Override - public boolean contains(int i) { - return allows(i) && (elements[wordIndex(i)] & (bitMask(i))) != 0; - } - - /** - * Adds the given integer to this set if not already present and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.ints' = this.ints + i - * @return i in this.ints' - * @throws IllegalArgumentException i !in [0..this.capacity) - * @see kodkod.util.ints.IntSet#add(int) - */ - @Override - public boolean add(int i) { - if (!allows(i)) - throw new IllegalArgumentException(i + " !in [0.." + capacity + ")"); - - final int wordIndex = wordIndex(i); - final long oldElements = elements[wordIndex]; - elements[wordIndex] |= bitMask(i); - if (elements[wordIndex] != oldElements) { - size++; - return true; - } - return false; - } - - /** - * Removes the given integer from this set if already present and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.ints' = this.ints - i - * @return i !in this.ints' - * @see kodkod.util.ints.IntSet#remove(int) - */ - @Override - public boolean remove(int i) { - if (allows(i)) { - final int wordIndex = wordIndex(i); - final long oldElements = elements[wordIndex]; - elements[wordIndex] &= ~bitMask(i); - if (elements[wordIndex] != oldElements) { - size--; - return true; - } - } - - return false; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntCollection#isEmpty() - */ - @Override - public boolean isEmpty() { - return size == 0; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#containsAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean containsAll(IntCollection other) { - if (other instanceof IntBitSet) { - final IntBitSet s = (IntBitSet) other; - if (isEmpty() || s.isEmpty()) - return isEmpty() ? s.isEmpty() : true; - if (size < s.size || max() < s.max()) - return false; - final int minLength = StrictMath.min(elements.length, s.elements.length); - for (int wordIndex = 0; wordIndex < minLength; wordIndex++) { - if ((s.elements[wordIndex] & ~elements[wordIndex]) != 0) - return false; - } - return true; - } - return super.containsAll(other); - } - - /** - * Recalculates the size and returns true if the size has changed. - */ - private boolean recalculateSize() { - final int oldSize = size; - size = 0; - for (long elt : elements) { - size += Long.bitCount(elt); - } - return size != oldSize; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#addAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean addAll(IntCollection other) { - if (other instanceof IntBitSet) { - final IntBitSet s = (IntBitSet) other; - if (s.isEmpty()) - return false; - if (s.max() >= capacity) - throw new IllegalArgumentException(s.max() + " !in [0.." + capacity + ")"); - final int minLength = StrictMath.min(elements.length, s.elements.length); - for (int wordIndex = 0; wordIndex < minLength; wordIndex++) { - elements[wordIndex] |= s.elements[wordIndex]; - } - return recalculateSize(); - } - return super.addAll(other); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#retainAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean retainAll(IntCollection other) { - if (other instanceof IntBitSet) { - final IntBitSet s = (IntBitSet) other; - final int minLength = StrictMath.min(elements.length, s.elements.length); - int wordIndex = 0; - for (; wordIndex < minLength; wordIndex++) { - elements[wordIndex] &= s.elements[wordIndex]; - } - for (; wordIndex < elements.length; wordIndex++) { - elements[wordIndex] = 0; - } - return recalculateSize(); - } - return super.retainAll(other); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#removeAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean removeAll(IntCollection other) { - if (other instanceof IntBitSet) { - final IntBitSet s = (IntBitSet) other; - final int minLength = StrictMath.min(elements.length, s.elements.length); - for (int wordIndex = 0; wordIndex < minLength; wordIndex++) { - elements[wordIndex] &= ~s.elements[wordIndex]; - } - return recalculateSize(); - } - return super.removeAll(other); - } - - /** - * Removes all elements from this set. - * - * @ensures no this.ints' - * @see kodkod.util.ints.IntCollection#clear() - */ - @Override - public void clear() { - Arrays.fill(elements, 0); - size = 0; - } - - /** - * Returns a copy of this int bit set. The copy is independent of this IntSet. - * - * @return a copy of this IntSet. - * @see kodkod.util.ints.IntSet#clone() - */ - @Override - public IntBitSet clone() { - try { - final IntBitSet ret = (IntBitSet) super.clone(); - ret.elements = this.elements.clone(); - return ret; - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code - } - - } - - /** - * Stores common fields and methods for the ascending and descending iterators. - */ - private abstract class AbstractIterator implements IntIterator { - - long unseen; - int unseenIndex, lastReturned; - - @Override - public void remove() { - if (lastReturned < 0) - throw new IllegalStateException(); - elements[wordIndex(lastReturned)] -= bitMask(lastReturned); - size--; - lastReturned = -1; - } - } - - /** - * Implementation of an ascending iterator over (a subset of) this set. - */ - private final class AscendingIterator extends AbstractIterator { - - private final long maxMask; - private final int maxIndex; - - /** - * Constructs an ascending iterator that returns elements between from and to. - * - * @requires from <= to - */ - AscendingIterator(int from, int to) { - if (from >= capacity || to < 0) { - unseenIndex = maxIndex = elements.length; - unseen = maxMask = 0L; - } else { - if (to >= capacity) { - maxIndex = elements.length - 1; - maxMask = -1L; - } else { - maxIndex = wordIndex(to); - maxMask = (bitMask(to) == Long.MIN_VALUE ? -1L : ~extendedMask(to + 1)); - } - if (from < 0) { - unseenIndex = 0; - unseen = elements[0]; - } else { - unseenIndex = wordIndex(from); - unseen = elements[unseenIndex] & extendedMask(from); - } - - } - lastReturned = -1; - } - - @Override - public boolean hasNext() { - while (unseen == 0 && unseenIndex < elements.length - 1) - unseen = elements[++unseenIndex]; - return (unseenIndex < maxIndex && unseen != 0) || (unseenIndex == maxIndex && (unseen & maxMask) != 0); - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - final long lastReturnedMask = Long.lowestOneBit(unseen); - unseen -= lastReturnedMask; - lastReturned = (unseenIndex << 6) + Long.numberOfTrailingZeros(lastReturnedMask); - return lastReturned; - } - - } - - /** - * Implementation of a descending iterator over (a subset of) this set. - */ - private final class DescendingIterator extends AbstractIterator { - - private final long minMask; - private final int minIndex; - - /** - * Constructs a descending iterator that returns elements between from and to. - * - * @requires from >= to - */ - DescendingIterator(int from, int to) { - if (to >= capacity || from < 0) { - unseenIndex = minIndex = 0; - unseen = minMask = 0L; - } else { - if (from < capacity) { - unseenIndex = wordIndex(from); - unseen = elements[unseenIndex] & (bitMask(from) == Long.MIN_VALUE ? -1L : ~extendedMask(from + 1)); - } else { - unseenIndex = elements.length - 1; - unseen = elements[unseenIndex]; - } - if (to < 0) { - minIndex = 0; - minMask = -1L; - } else { - minIndex = wordIndex(to); - minMask = extendedMask(to); - } - } - lastReturned = -1; - } - - @Override - public boolean hasNext() { - while (unseen == 0 && unseenIndex > 0) - unseen = elements[--unseenIndex]; - return (unseenIndex > minIndex && unseen != 0) || (unseenIndex == minIndex && (unseen & minMask) != 0); - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - final long lastReturnedMask = Long.highestOneBit(unseen); - unseen -= lastReturnedMask; - lastReturned = (unseenIndex << 6) + 63 - Long.numberOfLeadingZeros(lastReturnedMask); - return lastReturned; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntCollection.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntCollection.java deleted file mode 100644 index 5386998e7..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntCollection.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * The root interface in the int collection hierarchy. A collection represents a - * group of integers, known as its elements. Some collections allow duplicate - * elements and others do not. Some are ordered and others unordered. Some allow - * all integers and others only integers in a certain range. - * - * @author Emina Torlak - */ -public interface IntCollection { - - /** - * Returns the number of elements in this collection. - * - * @return number of elements in this collection. - */ - public abstract int size(); - - /** - * Returns true if this collection has no elements; otherwise returns false. - * - * @return true if this collection has no elements, false otherwise. - */ - public abstract boolean isEmpty(); - - /** - * Returns an iterator over the elements in this collection. There are no - * guarantees concerning the order in which the elements are returned (unless - * this collection is an instance of some class that provides a guarantee). - * - * @return an iterator over the elements in this collection - */ - public abstract IntIterator iterator(); - - /** - * Returns true if i is an element in this collection. - * - * @return true if i is an element in this collection. - */ - public abstract boolean contains(int i); - - /** - * Ensures that this collection contains the given integer, and returns true if - * this collection has changed as a result of the call. - * - * @return true if this collection has changed as a result of the call - * @throws UnsupportedOperationException this is an unmodifiable collection - * @throws IllegalArgumentException some aspect of the element prevents it from - * being added to this collection. - */ - public abstract boolean add(int i); - - /** - * Removes a single instance of the given integer from this collection, and - * returns true if this collection has changed as a result of the call. - * - * @return true if this collection has changed as a result of the call - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - public abstract boolean remove(int i); - - /** - * Returns true if this collection contains all of the elements in the specified - * collection. - * - * @return true if this collection contains all of the elements in the specified - * collection. - * @throws NullPointerException c = null - */ - public abstract boolean containsAll(IntCollection c); - - /** - * Adds all of the elements in the specified collection to this collection. - * Returns true if this collection has changed as a result of the call. - * - * @return true if this collection has changed as a result of the call - * @throws NullPointerException c = null - * @throws UnsupportedOperationException this is an unmodifiable collection - * @throws IllegalArgumentException some aspect of an element of the specified - * collection prevents it from being added to this collection. - */ - public abstract boolean addAll(IntCollection c); - - /** - * Removes all of this collection's elements that are also contained in the - * specified collection. After this call returns, this collection will contain - * no elements in common with the specified collection. Returns true if this - * collection has changed as a result of the call. - * - * @return true if this collection has changed as a result of the call - * @throws NullPointerException c = null - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - public abstract boolean removeAll(IntCollection c); - - /** - * Retains only the elements in this collection that are contained in the - * specified collection. In other words, removes from this collection all of its - * elements that are not contained in the specified collection. Returns true if - * this collection has changed as a result of the call. - * - * @return rue if this collection has changed as a result of the call - * @throws NullPointerException c = null - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - public abstract boolean retainAll(IntCollection c); - - /** - * Removes all elements from this collection. - * - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - public abstract void clear(); - - /** - * Returns an array containing all of the elements in this collection. - * - * @return an array containing all of the elements in this collection. - */ - public abstract int[] toArray(); - - /** - * Copies the elements of this collection into the specified array, provided - * that it is large enough, and returns it. If the array is not large enough, - * the effect of this method is the same as calling {@linkplain #toArray()}. - * - * @return the given array, filled with the elements from this collection, if - * the it is large enough; otherwise a new array containing all of the - * elements in this collection. - * @throws NullPointerException array = null - */ - public abstract int[] toArray(int[] array); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntIterator.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntIterator.java deleted file mode 100644 index 269824e01..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntIterator.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * An iterator over integer primitives. - * - * @author Emina Torlak - */ -public interface IntIterator { - - /** - * Returns true if this iteration has more elements. - * - * @return true if this iteration has more elements. - */ - public abstract boolean hasNext(); - - /** - * Returns the next int in the iteration, if any. Otherwise throws a - * NoSuchElementException. - * - * @return the next element in the iteration - * @throws java.util.NoSuchElementException the iteration is empty. - */ - public abstract int next(); - - /** - * Removes the last returned element from the underlying collection. - * - * @ensures removes the last returned element from the underlying collection. - * @throws UnsupportedOperationException removal is not supported - * @throws IllegalStateException next() has not been called yet or remove() has - * already been called since the last call to next(). - */ - public abstract void remove(); - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntRange.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntRange.java deleted file mode 100644 index e2ebb5e66..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntRange.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * Represents a range of integers, [min..max]. - * - * @specfield min: int - * @specfield max: int - * @invariant min <= max - * @author Emina Torlak - */ -public abstract class IntRange { - - private IntRange() {} - - /** - * Returns the left endpoint of this range. - * - * @return this.min - */ - public abstract int min(); - - /** - * Returns the right endpoint of this range. - * - * @return this.max - */ - public abstract int max(); - - /** - * Returns the number of element in this range. - * - * @return this.max - this.min + 1 - */ - public int size() { - return max() - min() + 1; - } - - /** - * Returns true if the given integer is within this range; otherwise returns - * false. - * - * @return i in [min..max] - */ - public boolean contains(int i) { - return i >= min() && i <= max(); - } - - /** - * Returns true if this range contains the given range. - * - * @return this.min <= range.min <= range.max <= this.max - * @throws NullPointerException range = null - */ - public boolean contains(IntRange range) { - return min() <= range.min() && range.max() <= max(); - } - - /** - * Returns true if this and the given range intersect. - * - * @return some i: int | this.contains(i) && range.contains(i) - * @throws NullPointerException range = null - */ - public boolean intersects(IntRange range) { - return contains(range.min()) || contains(range.max()); - } - - /** - * Returns true if o is an int range with the same endpoints as this. - * - * @return o in IntRange && o.min==this.min && o.max==this.max - */ - @Override - public boolean equals(Object o) { - if (o instanceof IntRange) { - final IntRange r = (IntRange) o; - return min() == r.min() && max() == r.max(); - } - return false; - } - - /** - * Returns the hash code for this int range. The implementation is guaranteed to - * obey the Object contract. - * - * @return the hashcode for this intrange - */ - @Override - public int hashCode() { - return min() == max() ? min() : min() ^ max(); - } - - @Override - public String toString() { - return "[" + min() + ".." + max() + "]"; - } - - /** - * Represents an int range that consists of a single point. - * - * @invariant min==max - * @author Emina Torlak - */ - static final class OnePointRange extends IntRange { - - private final int min; - - /** - * Constructs a new one point range. - */ - OnePointRange(int min) { - this.min = min; - } - - @Override - public final int min() { - return min; - } - - @Override - public final int max() { - return min; - } - } - - /** - * Represents an int range with two distinct end points. - * - * @invariant min < max - * @author Emina Torlak - */ - static final class TwoPointRange extends IntRange { - - private final int min, max; - - /** - * Constructs a new two point range. - * - * @requires min < max - */ - TwoPointRange(int min, int max) { - assert min < max; - this.min = min; - this.max = max; - } - - @Override - public final int min() { - return min; - } - - @Override - public final int max() { - return max; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntSet.java deleted file mode 100644 index 5360bf638..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntSet.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.NoSuchElementException; - -/** - * An ordered set of integers. - * - * @specfield ints: set int - * @author Emina Torlak - */ -public interface IntSet extends IntCollection, Cloneable { - - /** - * Returns the cardinality of this set. - * - * @return #this.ints - */ - @Override - public abstract int size(); - - /** - * Returns true if this set has no elements; otherwise returns false. - * - * @return no this.ints - */ - @Override - public abstract boolean isEmpty(); - - /** - * Returns true if i is in this set. - * - * @return i in this.ints - */ - @Override - public abstract boolean contains(int i); - - /** - * Returns the smallest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return min(this.ints) - * @throws java.util.NoSuchElementException no this.ints - */ - public abstract int min(); - - /** - * Returns the largest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return max(this.ints) - * @throws java.util.NoSuchElementException no this.ints - */ - public abstract int max(); - - /** - * Returns the largest element in this set that is smaller than or equal to i. - * If this is emtpy or i is less than this.min(), NoSuchElementException is - * thrown. - * - * @return {j: this.ints | j <= i && no k: this.ints - j | k > j && k <= i} - * @throws NoSuchElementException no this.ints || i < this.min() - */ - public abstract int floor(int i); - - /** - * Returns the smallest element in this set that is greater than or equal to i. - * If this is emtpy or i is greater than this.max(), NoSuchElementException is - * thrown. - * - * @return {j: this.ints | j >= i && no k: this.ints - j | k < j && k >= i} - * @throws NoSuchElementException no this.ints || i > this.max() - */ - public abstract int ceil(int i); - - /** - * Returns an iterator over the integers in this set, in the ascending element - * order. - * - * @return an IntIterator over the integers in this set. - */ - @Override - public abstract IntIterator iterator(); - - /** - * Returns an iterator over the elements of this set that are in the closed - * range [from..to]. If from < to, the elements are returned in the ascending - * order. Otherwise, they are returned in the descending order. - * - * @return an iterator over the elements in this set that are in the closed - * range [from..to]. - */ - public abstract IntIterator iterator(int from, int to); - - /** - * Adds the given integer to this set if not already present and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.ints' = this.ints + i - * @return i in this.ints' - * @throws IllegalArgumentException this is a bounded set and i is out of bounds - */ - @Override - public abstract boolean add(int i); - - /** - * Removes the given integer from this set if already present and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.ints' = this.ints - i - * @return i !in this.ints' - */ - @Override - public abstract boolean remove(int i); - - /** - * Returns true if the elements of c are a subset of this set. - * - * @return { i: int | c.contains(i) } in this.ints - * @throws NullPointerException c = null - */ - @Override - public abstract boolean containsAll(IntCollection c); - - /** - * Adds all of the elements in the specified collection to this set if they're - * not already present. - * - * @ensures this.ints' = this.ints + { i: int | c.contains(i) } - * @return this.ints' != this.ints - * @throws NullPointerException c = null - * @throws UnsupportedOperationException this is an unmodifiable set - * @throws IllegalArgumentException some aspect of an element of the specified - * collection prevents it from being added to this collection. - */ - @Override - public abstract boolean addAll(IntCollection c); - - /** - * Removes from this set all of its elements that are contained in the specified - * set. - * - * @ensures this.ints' = this.ints - { i: int | c.contains(i) } - * @return this.ints' != this.ints - * @throws NullPointerException s = null - * @throws UnsupportedOperationException this is an unmodifiable set - */ - @Override - public abstract boolean removeAll(IntCollection c); - - /** - * Retains only the elements in this set that are contained in the specified - * set. - * - * @ensures this.ints' = this.ints & { i: int | c.contains(i) } - * @return this.ints' != this.ints - * @throws NullPointerException s = null - * @throws UnsupportedOperationException this is an unmodifiable set - */ - @Override - public abstract boolean retainAll(IntCollection c); - - /** - * Removes all elements from this set. - * - * @ensures no this.ints' - */ - @Override - public abstract void clear(); - - /** - * Returns a copy of this IntSet. The copy is independent of this IntSet unless - * this is a singleton or an immutable set, in which case clone() may return - * this. An implementing class that does not support cloning may throw a - * CloneNotSupportedException. - * - * @return a copy of this IntSet. - * @throws CloneNotSupportedException this is not cloneable - */ - public abstract IntSet clone() throws CloneNotSupportedException; - - /** - * Returns an array containing all of the elements in this set in the ascending - * order. - * - * @return an array containing all of the elements in this set in the ascending - * order. - */ - @Override - public abstract int[] toArray(); - - /** - * Copies the elements of this set into the specified array, in the ascending - * order, provided that the array is large enough. If the array is not large - * enough, the effect of this method is the same as calling - * {@linkplain #toArray()}. - * - * @ensures array.length>=this.size() => all i: [0..this.size()) | array'[i] in - * this.ints and #{e: this.ints | e < array'[i]} = i - * @return array.length>=this.size() => array' else this.toArray() - * @throws NullPointerException array = null - */ - @Override - public abstract int[] toArray(int[] array); - - /** - * Compares the specified object with this set for equality. Returns true if the - * specified object is also an IntSet, the two sets have the same size, and - * every member of the specified set is contained in this set (or equivalently, - * every member of this set is contained in the specified set). This definition - * ensures that the equals method works properly across different - * implementations of the IntSet interface. - * - * @return o instanceof IntSet and o.size() = this.size() and - * this.containsAll(o) - */ - @Override - public abstract boolean equals(Object o); - - /** - * Returns the hash code value for this set. The hash code of a set is defined - * to be the {@link Ints#superFastHash(int[])} of the elements in the set, taken - * in the ascending order of values. This ensures that s1.equals(s2) implies - * that s1.hashCode()==s2.hashCode() for any two IntSets s1 and s2, as required - * by the general contract of the Object.hashCode method. - * - * @return Ints.superFastHash(this.toArray()) - */ - @Override - public abstract int hashCode(); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntTree.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntTree.java deleted file mode 100644 index e698af2d6..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntTree.java +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * A tree with integer keys. - * - * @specfield root: lone N - * @specfield nodes: root.*(left + right) - * @author Emina Torlak - */ -final class IntTree> implements Cloneable { - - private static final boolean BLACK = true, RED = false; - - private N root; - - /** - * Creates an empty IntTree. - * - * @ensures no this.root' - */ - IntTree() { - root = null; - } - - /** - * Discards all elements from this tree. - * - * @ensures no this.root' - **/ - final void clear() { - root = null; - } - - /** - * Returns the node with the given key, or null no such node exists. - * - * @return this.nodes & key.index - */ - final N search(int k) { - N node = root; - while (node != null) { - if (node.key == k) - break; - else if (node.key > k) - node = node.left; - else - node = node.right; - } - return node; - } - - /** - * Returns the node whose key is the ceiling of k in this tree, or null - * if no such node exists. - * - * @return {n: this.nodes | n.key >= k && no n': this.nodes - n | n'.key >= k && - * n'.key < n.key } - */ - final N searchGTE(int k) { - if (root == null) - return null; - N c = root; - while (true) { - if (c.key == k) { - return c; - } else if (c.key > k) { - if (c.left != null) - c = c.left; - else - return c; - } else { - if (c.right != null) - c = c.right; - else - return successor(c); - } - } - } - - /** - * Returns the node whose key is the floor of k in this tree, or null - * if no such node exists. - * - * @return {n: this.nodes | n.key <= k && no n': this.nodes - n | n'.key <= k && - * n'.key > n.key } - */ - final N searchLTE(int k) { - if (root == null) - return null; - N f = root; - while (true) { - if (f.key == k) - return f; - else if (f.key > k) { - if (f.left != null) - f = f.left; - else - return predecessor(f); - } else { - if (f.right != null) - f = f.right; - else - return f; - } - } - } - - /** - * Implementation of the tree-predecessor algorithm from CLR. Returns the given - * node's predecessor, if it exists. Otherwise returns null. - * - * @return the given node's predecessor - * @throws NullPointerException node = null - */ - final N predecessor(N node) { - if (node.left != null) { - return max(node.left); - } else { - N n = node; - N ancestor = n.parent; - while (ancestor != null && n == ancestor.left) { - n = ancestor; - ancestor = ancestor.parent; - } - return ancestor; - } - } - - /** - * Implementation of the tree-successor algorithm from CLR. Returns the given - * node's successor, if it exists. Otherwise returns null. - * - * @return the given node's successor - * @throws NullPointerException node = null - */ - final N successor(N node) { - if (node.right != null) { - return min(node.right); - } else { - N n = node; - N ancestor = n.parent; - while (ancestor != null && n == ancestor.right) { - n = ancestor; - ancestor = ancestor.parent; - } - return ancestor; - } - } - - /** - * Returns the node with the smallest key. - * - * @return key.(min(this.nodes.key)) - */ - final N min() { - return min(root); - } - - /** - * Returns the node with the largest key. - * - * @return key.(max(this.nodes.key)) - */ - final N max() { - return max(root); - } - - /** - * Returns the leftmost node in the subtree rooted at start. The behavior of - * this method is unspecified if the given node is not in this tree. - * - * @requires node in this.nodes - * @return {n: start.*left | no n.left } - */ - private final N min(N start) { - if (start != null) { - while (start.left != null) { - start = start.left; - } - } - return start; - } - - /** - * Returns the rightmost in the subtree rooted at start. The behavior of this - * method is unspecified if the given node is not in this tree. - * - * @requires node in this.nodes - * @return {n: start.*left | no n.right } - */ - private final N max(N start) { - if (start != null) { - while (start.right != null) { - start = start.right; - } - } - return start; - } - - /** - * Replaces the old node, o, with the given new node, n, in this tree. - * - * @requires no n.(left + right + parent) - * @requires o = o.parent.left => n.key < o.parent.key - * @requires o = o.parent.right => n.key > o.parent.key - * @requires some o.left => n.key > o.left.key - * @requires some o.right => n.key < o.right.key - * @ensures this.nodes' = this.nodes - o + n - * @ensures o.parent' = o.left' = o.right' = null - */ - final void replace(N o, N n) { - n.color = o.color; - n.parent = o.parent; - n.left = o.left; - n.right = o.right; - if (o.left != null) { - o.left.parent = n; - } - if (o.right != null) { - o.right.parent = n; - } - if (o.parent == null) { - root = n; - } else if (o == o.parent.left) { - o.parent.left = n; - } else { - o.parent.right = n; - } - o.parent = o.left = o.right = null; - } - - private final N parentOf(N n) { - return n == null ? null : n.parent; - } - - private final N leftOf(N n) { - return n == null ? null : n.left; - } - - private final N rightOf(N n) { - return n == null ? null : n.right; - } - - private final boolean colorOf(N n) { - return n == null ? BLACK : n.color; - } - - private final void setColor(N n, boolean color) { - if (n != null) - n.color = color; - } - - /** - * Implementation of the CLR insertion algorithm. - * - * @requires no z.key & this.nodes.key - * @ensures this.nodes' = this.nodes + z - */ - final void insert(N z) { - N y = null; - for (N x = root; x != null;) { - y = x; - if (x.key > z.key) - x = x.left; - else - x = x.right; - } - - z.parent = y; - z.left = z.right = null; - if (y == null) { - root = z; - } else { - z.color = RED; - if (y.key > z.key) { - y.left = z; - } else { - y.right = z; - } - - insertFixUp(z); - } - } - - /** - * A slightly modified implementation of the CLR deletion algorithm. - * - * @requires z in this.nodes - * @ensures this.nodes' = this.nodes - z - */ - final void delete(N z) { - N y = (z.left == null || z.right == null ? z : successor(z)); - N x = (y.left != null ? y.left : y.right); - - N yparent = y.parent; - final boolean yleft = (y == leftOf(y.parent)); - final boolean ycolor = y.color; - - if (x != null) { - x.parent = yparent; - } - - if (yparent == null) { - root = x; - } else if (yleft) { - yparent.left = x; - } else { - yparent.right = x; - } - - if (y != z) { - replace(z, y); - } - - if (ycolor == BLACK) { - if (x != null) { - deleteFixUp(x); - } else if (yparent != null) { // z is not the only node - - if (z == yparent) - yparent = y; // y, z's successor, is z's right child - z.color = BLACK; - z.left = z.right = null; - z.parent = yparent; - if (yleft) { - yparent.left = z; - } else { - yparent.right = z; - } - - deleteFixUp(z); - if (z == z.parent.left) { - z.parent.left = null; - } else { - z.parent.right = null; - } - } - } - - z.left = z.right = z.parent = null; // cut z out of the tree by nulling - // out its pointers - } - - /** - * {@inheritDoc} - * - * @see java.lang.Object#clone() - * @throws CloneNotSupportedException nodes contained in this tree are not - * cloneable - */ - @Override - @SuppressWarnings("unchecked" ) - protected IntTree clone() throws CloneNotSupportedException { - final IntTree ret = (IntTree) super.clone(); - ret.root = clone(root, null); - return ret; - } - - /** - * Recursively clones the given node. - */ - @SuppressWarnings("unchecked" ) - private N clone(N n, N parent) throws CloneNotSupportedException { - if (n == null) - return null; - N clone = (N) n.clone(); - clone.parent = parent; - clone.left = clone(n.left, clone); - clone.right = clone(n.right, clone); - return clone; - } - - /*---------balancing operations (CLR, pp.278-289)---------*/ - /** - * From CLR. - */ - private void insertFixUp(N z) { - while (z != null && z != root && z.parent.color == RED) { - if (parentOf(z) == leftOf(parentOf(parentOf(z)))) { - N y = rightOf(parentOf(parentOf(z))); - if (colorOf(y) == RED) { - setColor(parentOf(z), BLACK); - setColor(y, BLACK); - setColor(parentOf(parentOf(z)), RED); - z = parentOf(parentOf(z)); - } else { - if (z == rightOf(parentOf(z))) { - z = parentOf(z); - rotateLeft(z); - } - setColor(parentOf(z), BLACK); - setColor(parentOf(parentOf(z)), RED); - if (parentOf(parentOf(z)) != null) - rotateRight(parentOf(parentOf(z))); - } - } else { - N y = leftOf(parentOf(parentOf(z))); - if (colorOf(y) == RED) { - setColor(parentOf(z), BLACK); - setColor(y, BLACK); - setColor(parentOf(parentOf(z)), RED); - z = parentOf(parentOf(z)); - } else { - if (z == leftOf(parentOf(z))) { - z = parentOf(z); - rotateRight(z); - } - setColor(parentOf(z), BLACK); - setColor(parentOf(parentOf(z)), RED); - if (parentOf(parentOf(z)) != null) - rotateLeft(parentOf(parentOf(z))); - } - } - } - root.color = BLACK; - } - - /** - * From CLR. - */ - private void deleteFixUp(N x) { - while (x != root && colorOf(x) == BLACK) { - if (x == leftOf(parentOf(x))) { - N sib = rightOf(parentOf(x)); - - if (colorOf(sib) == RED) { - setColor(sib, BLACK); - setColor(parentOf(x), RED); - rotateLeft(parentOf(x)); - sib = rightOf(parentOf(x)); - } - - if (colorOf(leftOf(sib)) == BLACK && colorOf(rightOf(sib)) == BLACK) { - setColor(sib, RED); - x = parentOf(x); - } else { - if (colorOf(rightOf(sib)) == BLACK) { - setColor(leftOf(sib), BLACK); - setColor(sib, RED); - rotateRight(sib); - sib = rightOf(parentOf(x)); - } - setColor(sib, colorOf(parentOf(x))); - setColor(parentOf(x), BLACK); - setColor(rightOf(sib), BLACK); - rotateLeft(parentOf(x)); - x = root; - } - } else { // symmetric - N sib = leftOf(parentOf(x)); - - if (colorOf(sib) == RED) { - setColor(sib, BLACK); - setColor(parentOf(x), RED); - rotateRight(parentOf(x)); - sib = leftOf(parentOf(x)); - } - - if (colorOf(rightOf(sib)) == BLACK && colorOf(leftOf(sib)) == BLACK) { - setColor(sib, RED); - x = parentOf(x); - } else { - if (colorOf(leftOf(sib)) == BLACK) { - setColor(rightOf(sib), BLACK); - setColor(sib, RED); - rotateLeft(sib); - sib = leftOf(parentOf(x)); - } - setColor(sib, colorOf(parentOf(x))); - setColor(parentOf(x), BLACK); - setColor(leftOf(sib), BLACK); - rotateRight(parentOf(x)); - x = root; - } - } - } - - setColor(x, BLACK); - - } - - /** - * From CLR. - */ - private void rotateLeft(N x) { - N y = x.right; - x.right = y.left; - if (y.left != null) - y.left.parent = x; - y.parent = x.parent; - if (x.parent == null) - root = y; - else if (x.parent.left == x) - x.parent.left = y; - else - x.parent.right = y; - y.left = x; - x.parent = y; - } - - /** - * From CLR. - */ - private void rotateRight(N x) { - N y = x.left; - x.left = y.right; - if (y.right != null) - y.right.parent = x; - y.parent = x.parent; - if (x.parent == null) - root = y; - else if (x.parent.right == x) - x.parent.right = y; - else - x.parent.left = y; - y.right = x; - x.parent = y; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return root.toString(); - } - - /** - * A node in an int tree. Subclasses need to implement the clone method iff - * IntTree.clone will be called on the tree containing the nodes. - * - * @specfield key: int - * @specfield parent: lone N - * @specfield left: lone N - * @specfield right: lone N - * @author Emina Torlak - */ - abstract static class Node> implements Cloneable { - - N parent, left, right; - boolean color; - /** - * Subclasses are required to maintain the following invariant: - * - * @invariant this = this.parent.left => this.key < this.parent.key && this = - * this.parent.right => this.key > this.parent.key && some this.left - * => this.key > this.left.key && some this.right => this.key < - * this.right.key - */ - protected int key; - - /** - * Constructs an empty node with the given key. - * - * @ensures no this.(parent' + left' + right') && this.key' = key - */ - Node(int key) { - this.parent = this.left = this.right = null; - this.color = BLACK; - this.key = key; - } - - /** - * Returns the left child of this node. - * - * @return this.left - */ - final N left() { - return left; - } - - /** - * Returns the right child of this node. - * - * @return this.right - */ - final N right() { - return right; - } - - /** - * Return the parent of this node. - * - * @return this.parent - */ - final N parent() { - return parent; - } - - /** - * Clones this node. Subclasses must override this method (and call - * super.clone()) in order for IntTree.clone() to function properly. - * - * @throws CloneNotSupportedException - * @see java.lang.Object#clone() - */ - @Override - @SuppressWarnings("unchecked" ) - protected Node clone() throws CloneNotSupportedException { - Node ret = (Node) super.clone(); - ret.parent = ret.left = ret.right = null; - return ret; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "[" + key + " " + (color ? "b" : "r") + " " + (left == this ? key : left) + " " + (right == this ? key : right) + "]"; - - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntTreeSet.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntTreeSet.java deleted file mode 100644 index ad672f92d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntTreeSet.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.NoSuchElementException; - -/** - * An implementation of the IntTreeSet interface based on a balanced binary - * search tree. - * - * @specfield ints: set int - * @author Emina Torlak - */ -public final class IntTreeSet extends AbstractIntSet implements Cloneable { - - /* - * The endpoints of the ranges in the tree do not touch, and they are sorted by - * their right endpoints. - * @invariant all n: tree.nodes | n.max = n.key && n.min <= n.max && all n': - * tree.nodes - n | n'.max < n.min - 1 || n'.min > n.max + 1 - */ - private final IntTree tree; - private int size; - - /** - * Constructs an empty int set. - * - * @ensures no this.ints' - */ - public IntTreeSet() { - tree = new IntTree(); - size = 0; - } - - /** - * Constructs a new int set containing the elements in the specified set. - * - * @ensures this.ints' = s.ints - * @throws NullPointerException s = null - */ - public IntTreeSet(IntSet s) { - this(); - addAll(s); - } - - /** - * Copy constructor. - * - * @ensures constructs a deep copy of the original set. - */ - private IntTreeSet(IntTreeSet original) { - this.size = original.size; - try { - this.tree = original.tree.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code - } - } - - // public String toString() { - // for(Range next = tree.min(); next != null; next = tree.successor(next) ) - // { - // System.out.print("[" + next.min + " .. " + next.key+ "] "); - // } - // System.out.println(""); - // return ""; - // } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#iterator(int,int) - */ - @Override - public IntIterator iterator(int from, int to) { - return from <= to ? new AscendingIterator(from, to) : new DescendingIterator(from, to); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#size() - */ - @Override - public int size() { - return size; - } - - /** - * Returns true if i is in this set. - * - * @return i in this.ints - * @see kodkod.util.ints.IntSet#contains(int) - */ - @Override - public boolean contains(int i) { - final Range r = tree.searchGTE(i); - return r != null && r.min <= i; - } - - /** - * Returns the smallest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return min(this.ints) - * @throws java.util.NoSuchElementException no this.ints - * @see kodkod.util.ints.IntSet#min() - */ - @Override - public int min() { - checkNonEmpty(); - return tree.min().min; - } - - /** - * Returns the largest element in this set. Throws a NoSuchElementException if - * this set is empty. - * - * @return max(this.ints) - * @throws java.util.NoSuchElementException no this.ints - * @see kodkod.util.ints.IntSet#max() - */ - @Override - public int max() { - checkNonEmpty(); - return tree.max().key; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#floor(int) - */ - @Override - public int floor(int i) { - checkNonEmpty(); - Range r = tree.searchGTE(i); - if (r == null || r.min > i) { - r = tree.searchLTE(i); - return r == null ? null : r.key; - } else - return i; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#ceil(int) - */ - @Override - public int ceil(int i) { - checkNonEmpty(); - final Range r = tree.searchGTE(i); - return r == null ? null : StrictMath.max(i, r.min); - } - - /** - * Adds the given integer to this set if not already present and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.ints' = this.ints + i - * @return i in this.ints' - * @see kodkod.util.ints.IntSet#add(int) - */ - @Override - public boolean add(int i) { - final Range ceil = tree.searchGTE(i); - if (ceil == null || ceil.min > i) { - - final Range floor = tree.searchLTE(i); - - if (floor != null && floor.key == i - 1) { - if (ceil != null && ceil.min == i + 1) { - tree.delete(ceil); - floor.key = ceil.key; - } else { - floor.key = i; - } - } else if (ceil != null && ceil.min == i + 1) { - ceil.min = i; - } else { - tree.insert(new Range(i, i)); - } - - size++; - return true; - } - - return false; - } - - /** - * Removes the given integer from this set if already present and returns true. - * Otherwise does nothing and returns false. - * - * @ensures this.ints' = this.ints - i - * @return i !in this.ints' - * @see kodkod.util.ints.IntSet#remove(int) - */ - @Override - public boolean remove(int i) { - final Range ceil = tree.searchGTE(i); - - if (ceil != null && i >= ceil.min) { - if (ceil.min == ceil.key) { - tree.delete(ceil); - } else if (i == ceil.min) { - ceil.min++; - } else if (i == ceil.key) { - ceil.key = i - 1; - } else { // split the range in two - tree.insert(new Range(ceil.min, i - 1)); - ceil.min = i + 1; - } - size--; - assert size >= 0; - return true; - } - - return false; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.IntSet#containsAll(kodkod.util.ints.IntCollection) - */ - @Override - public boolean containsAll(IntCollection other) { - if (other instanceof IntTreeSet) { - IntTreeSet s = (IntTreeSet) other; - if (size >= s.size) { - for (Range r1 = s.tree.min(); r1 != null; r1 = s.tree.successor(r1)) { - Range r0 = tree.searchGTE(r1.key); - if (r0 == null || r1.min < r0.min) - return false; - } - return true; - } - return false; - } - return super.containsAll(other); - } - - /** - * Removes all elements from this set. - * - * @ensures no this.ints' - * @see kodkod.util.ints.IntCollection#clear() - */ - @Override - public void clear() { - tree.clear(); - size = 0; - } - - /** - * Returns a copy of this int tree set. The copy is independent of this IntSet. - * - * @return a copy of this IntSet. - * @see kodkod.util.ints.IntSet#clone() - */ - @Override - public IntTreeSet clone() { - // ok to use copy constructor to clone a final class - return new IntTreeSet(this); - } - - /** - * A range of integers in an int set. - * - * @specfield min: int - * @specfield max: int - * @invariant min <= max - * @invariant max = key - * @author Emina Torlak - */ - private static final class Range extends IntTree.Node implements Cloneable { - - private int min; - - Range(int min, int max) { - super(max); - this.min = min; - } - - @Override - protected Range clone() throws CloneNotSupportedException { - return (Range) super.clone(); - } - - } - - /** - * An iterator that traverses the ints in this set in the ascending order. - * - * @author Emina Torlak - */ - private final class AscendingIterator implements IntIterator { - - private Range next; - private final int endpoint; - private int currentMax, cursor, lastReturned; - private boolean canRemove; - - /** - * @requires from <= to - */ - AscendingIterator(int from, int to) { - endpoint = to; - lastReturned = Integer.MIN_VALUE; - canRemove = false; - next = tree.searchGTE(from); - if (next == null) { - cursor = 0; - currentMax = -1; - } else { - cursor = StrictMath.max(next.min, from); - currentMax = next.key; - next = tree.successor(next); - } - } - - @Override - public boolean hasNext() { - if (cursor > currentMax) { - if (next == null) - return false; - this.cursor = next.min; - this.currentMax = next.key; - next = tree.successor(next); - } - return lastReturned < Integer.MAX_VALUE && cursor <= endpoint; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - canRemove = true; - return lastReturned = cursor++; - } - - @Override - public void remove() { - if (!canRemove) - throw new IllegalStateException(); - IntTreeSet.this.remove(lastReturned); - next = tree.searchGTE(cursor); - canRemove = false; - } - - } - - /** - * An iterator that traverses the ints in this set in the descending order. - * - * @author Emina Torlak - */ - private final class DescendingIterator implements IntIterator { - - private Range next; - private final int endpoint; - private int currentMin, cursor, lastReturned; - private boolean canRemove; - - /** - * @requires from >= to - */ - DescendingIterator(int from, int to) { - endpoint = to; - lastReturned = Integer.MAX_VALUE; - canRemove = false; - next = tree.searchGTE(from); - if (next == null || next.min > from) { - next = tree.searchLTE(from); - if (next == null) { - cursor = -1; - currentMin = 0; - } else { - cursor = StrictMath.min(next.key, from); - currentMin = next.min; - } - } else { - cursor = StrictMath.min(next.key, from); - currentMin = next.min; - } - } - - @Override - public boolean hasNext() { - if (cursor < currentMin) { - if (next == null) - return false; - this.cursor = next.key; - this.currentMin = next.min; - next = tree.predecessor(next); - } - return lastReturned > Integer.MIN_VALUE && cursor >= endpoint; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - canRemove = true; - return lastReturned = cursor--; - } - - @Override - public void remove() { - if (!canRemove) - throw new IllegalStateException(); - IntTreeSet.this.remove(lastReturned); - next = tree.searchLTE(cursor); - canRemove = false; - } - - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntVector.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntVector.java deleted file mode 100644 index c98e24c73..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/IntVector.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -/** - * A resizable array of integers. - * - * @specfield length: int - * @specfield elements: [0..size) ->one int - * @author Emina Torlak - */ -public interface IntVector extends IntCollection { - - /** - * Returns the number of elements in this vector. - * - * @return this.length - */ - @Override - public int size(); - - /** - * Returns true if this vector contains no elements. - * - * @return no this.elements - */ - @Override - public boolean isEmpty(); - - /** - * Returns true if this vector contains the specified element. - * - * @return element in this.elements[int] - */ - @Override - public boolean contains(int element); - - /** - * Returns the element at the specified position in this vector. - * - * @return this.elements[index] - * @throws IndexOutOfBoundsException if the index is out of range (index < 0 - * || index >= length()). - */ - public int get(int index); - - /** - * Returns an iterator over the elements in this vector in proper sequence. - * - * @return an iterator over the elements in this vector in proper sequence. - */ - @Override - public IntIterator iterator(); - - /** - * Returns an iterator over the elements in this vector in proper sequence, - * starting fromIndex<\tt>, inclusive, and ending at toIndex<\tt>, - * exclusive. If fromIndex<\tt> is less than toIndex<\tt>, then the - * iterator will return the elements in the descending order. - * - * @return an iterator over the elements in this vector in proper sequence, - * starting at fromIndex<\tt>, inclusive, and ending at - * toIndex<\tt>. - * @throws IndexOutOfBoundsException fromIndex !in [0..this.length) || toIndex - * !in [-1..this.length] - */ - public IntIterator iterator(int fromIndex, int toIndex); - - /** - * Replaces the element at the specified position in this vector with the - * specified element, and returns the previous element (optional operation). - * - * @ensures this.elements' = this.elements' ++ index -> element - * @return this.elements[index] - * @throws UnsupportedOperationException if the set method is not - * supported by this vector. - * @throws IllegalArgumentException if some aspect of the specified element - * prevents it from being added to this vector. - * @throws IndexOutOfBoundsException if the index is out of range (index < 0 - * || index >= length()). - */ - public int set(int index, int element); - - /** - * Removes all of the elements from this vector (optional operation). This - * vector will be empty after this call returns (unless it throws an exception). - * - * @ensures this.length' = 0 && no this.elements' - * @throws UnsupportedOperationException if the clear method is not - * supported by this vector. - */ - @Override - public void clear(); - - /** - * Returns the index in this vector of the first occurrence of the specified - * element, or -1 if this vector does not contain this element. - * - * @return element in this.elements[int] => min(this.elements.element), -1 - */ - public int indexOf(int element); - - /** - * Returns the index in this vector of the last occurrence of the specified - * element, or -1 if this vector does not contain this element. - * - * @return element in this.elements[int] => max(this.elements.element), -1 - */ - public int lastIndexOf(int element); - - /** - * Adds the specified element to the end of this vector (optional operation), - * and returns true if this vector has changed as a result of the call. - * - * @ensures this.length' = this.length + 1 && this.elements' = this.elements + - * this.length -> element - * @return this.elements != this.elements' - * @throws UnsupportedOperationException if the add method is not - * supported by this vector. - * @throws IllegalArgumentException if some aspect of this element prevents it - * from being added to this vector. - */ - @Override - public boolean add(int element); - - /** - * Inserts the specified element at the specified position in this vector - * (optional operation), and returns true if this vector has changed as a result - * of the call. Shifts the element currently at that position (if any) and any - * subsequent elements to the right (adds one to their indices). - * - * @ensures this.length' = this.length + 1 && this.elements' = { i: - * [0..this.length'), e: int | i < index => e = this.elements[i], i = - * index => e = element, e = this.elements[i-1] } - * @throws UnsupportedOperationException if the add method is not - * supported by this vector. - * @throws IllegalArgumentException if some aspect of the specified element - * prevents it from being added to this vector. - * @throws IndexOutOfBoundsException if the index is out of range (index < 0 - * || index > length()). - */ - public void add(int index, int element); - - /** - * Appends the specified elements to the end of this vector (optional - * operation), and returns true if this vector has changed as a result of the - * call. - * - * @ensures appends the specified elements to the end of this vector - * @return this.elements != this.elements' - * @throws UnsupportedOperationException if the add method is not - * supported by this vector. - * @throws IllegalArgumentException if some aspect of an element in the given - * vector prevents it from being added to this vector. - */ - @Override - public boolean addAll(IntCollection c); - - /** - * Inserts the specified elements at the specified position in this vector - * (optional operation), and returns true if this vector has changed as a result - * of the call. Shifts the element currently at that position (if any) and any - * subsequent elements to the right. - * - * @ensures inserts the specified elements at the specified position in this - * vector - * @return this.elements != this.elements - * @throws UnsupportedOperationException if the add method is not - * supported by this vector. - * @throws IllegalArgumentException if some aspect of an element in the - * specified collection prevents it from being added to this vector. - * @throws IndexOutOfBoundsException if the index is out of range (index < 0 - * || index > length()). - */ - public boolean addAll(int index, IntCollection c); - - /** - * Removes the first occurrence of the given integer from this vector, and - * returns true if this vector has changed as a result of the call. - * - * @ensures removes the first occurrence of the given integer from this vector - * @return this.elements != this.elements' - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - @Override - public abstract boolean remove(int i); - - /** - * Removes the element at the specified position in this vector (optional - * operation). Shifts any subsequent elements to the left (subtracts one from - * their indices). Returns the element that was removed from the vector. - * - * @return this.elements[index] - * @ensures this.length' = this.length - 1 && this.elements' = { i: - * [0..this.length'), e: int | i < index => e = this.elements[i], e = - * this.elements[i+1] } - * @throws UnsupportedOperationException if the remove method is not - * supported by this vector. - * @throws IndexOutOfBoundsException if the index is out of range (index < 0 - * || index >= length()). - */ - public int removeAt(int index); - - /** - * Removes all of this vector's elements that are also contained in the - * specified collection. After this call returns, this collection will contain - * no elements in common with the specified collection. Returns true if this - * collection has changed as a result of the call. - * - * @ensures removes all of this vector's elements that are also contained in the - * specified collection - * @return this.elements != this.elements' - * @throws NullPointerException c = null - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - @Override - public abstract boolean removeAll(IntCollection c); - - /** - * Retains only the elements in this vector that are contained in the specified - * collection. In other words, removes from this collection all of its elements - * that are not contained in the specified collection. Returns true if this - * collection has changed as a result of the call. - * - * @ensures retains only the elements in this vector that are contained in the - * specified collection - * @return this.elements != this.elements' - * @throws NullPointerException c = null - * @throws UnsupportedOperationException this is an unmodifiable collection - */ - @Override - public abstract boolean retainAll(IntCollection c); - - /** - * Compares the specified object with this vector for equality. Returns - * true if and only if the specified object is also an int vector, both - * vectors have the same size, and all corresponding pairs of elements in the - * two vectors are equal. - * - * @return true if the specified object is equal to this vector. - */ - @Override - public boolean equals(Object o); - - /** - * Returns the hash code value for this vector. The hash code of an int vector - * is defined to be the {@link Ints#superFastHash(int[])} of the elements in the - * vector, taken in the ascending order of indices. This ensures that - * v1.equals(v2) implies that v1.hashCode()==v2.hashCode() for any two - * IntVectors v1 and v2, as required by the general contract of the - * Object.hashCode method. - * - * @return Ints.superFastHash(this.toArray()) - */ - @Override - public int hashCode(); - - /** - * Returns an array containing all of the elements in this vector in proper - * sequence. - * - * @return an array containing all of the elements in this vector in proper - * sequence. - */ - @Override - public int[] toArray(); - - /** - * Copies the components of this vector into the specified array, provided that - * it is large enough, and returns it. The item at index k in this vector is - * copied into component k of the given array. If the given array is not large - * enough, the effect of this method is the same as calling - * {@linkplain #toArray()}. - * - * @ensures array.length>=this.length => all i: [0..this.length) | array'[i] = - * this.elements[i] - * @return array.length>=this.length => array' else this.toArray() - * @throws NullPointerException array = null - */ - @Override - public int[] toArray(int[] array); -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/Ints.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/Ints.java deleted file mode 100644 index 2f25f5057..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/Ints.java +++ /dev/null @@ -1,845 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import kodkod.util.collections.Containers; -import kodkod.util.ints.IntRange.OnePointRange; -import kodkod.util.ints.IntRange.TwoPointRange; - -/** - * Contains various utility methods for working with integers, - * {@link kodkod.util.ints.IntRange IntRanges}, {@link kodkod.util.ints.IntSet - * IntSets}, and {@link kodkod.util.ints.SparseSequence SparseSequences}. - *

- * The methods in this class all throw a NullPointerException if given a null - * reference unless otherwise specified. - *

- * - * @author Emina Torlak - */ -public final class Ints { - - private static final int BITSET_CUTOFF = 1024; - - /** - * An immutable empty int set. The clone method returns the empty set itself. - */ - public static final IntSet EMPTY_SET = new AbstractIntSet() { - - @Override - public boolean contains(int i) { - return false; - } - - @Override - public int min() { - throw new NoSuchElementException(); - } - - @Override - public int max() { - throw new NoSuchElementException(); - } - - @Override - public IntIterator iterator(int from, int to) { - return new IntIterator() { - - @Override - public boolean hasNext() { - return false; - } - - @Override - public int next() { - throw new NoSuchElementException(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public int size() { - return 0; - } - - @Override - public int floor(int i) { - throw new NoSuchElementException(); - } - - @Override - public int ceil(int i) { - throw new NoSuchElementException(); - } - - @Override - public IntSet clone() { - return EMPTY_SET; - } - }; - - /** - * An immutable empty sequence. The clone method returns the empty set itself. - */ - public static final SparseSequence< ? > EMPTY_SEQUENCE = new AbstractSparseSequence() { - - @Override - public int size() { - return 0; - } - - @Override - public boolean containsIndex(int idx) { - return false; - } - - @Override - public boolean contains(Object o) { - return false; - } - - @Override - public IntSet indices() { - return EMPTY_SET; - } - - @Override - public Object get(int index) { - return null; - } - - @Override - public Iterator> iterator(int from, int to) { - return Containers.emptyIterator(); - } - - @Override - public SparseSequence clone() { - return this; - } - }; - - private Ints() {} - - /*-----------SETS AND RANGES-----------*/ - - /** - * Returns an integer range from min, inclusive, to max, inclusive. - * - * @return { r: IntRange | r.min = min && r.max = max } - * @throws IllegalArgumentException min > max - */ - public static IntRange range(int min, int max) { - if (min < max) - return new TwoPointRange(min, max); - else if (min == max) - return new OnePointRange(min); - else - throw new IllegalArgumentException("min > max"); - } - - /** - * Returns the smallest IntRange r that contains both r1 and r2. - * - * @return { r: IntRange | r.contains(r1) && r.contains(r2) && no r' : IntRange - * - r | r'.contains(r1) && r'.contains(r2) && r'.size() < r.size() } - * @throws NullPointerException range = null - */ - public static IntRange merge(IntRange r1, IntRange r2) { - if (r1.contains(r2)) - return r1; - else if (r2.contains(r1)) - return r2; - else - return range(StrictMath.min(r1.min(), r2.min()), StrictMath.max(r1.max(), r2.max())); - } - - /** - * Returns an unmodifiable view of the specified set. This method allows modules - * to provide users with "read-only" access to internal int sets. Query - * operations on the returned set "read through" to the specified set, and - * attempts to modify the returned set, whether direct or via its iterator, - * result in an UnsupportedOperationException. The clone() method of the - * returned set returns the result of calling s.clone(). - * - * @return an unmodifiable view of s - * @throws NullPointerException s = null - */ - public static IntSet unmodifiableIntSet(final IntSet s) { - if (s == null) - throw new NullPointerException("s = null"); - else if (s instanceof UnmodifiableIntSet || s instanceof SingletonIntSet || s instanceof RangeIntSet) - return s; - else - return new UnmodifiableIntSet(s); - } - - /** - * Returns an unmodifiable IntSet whose sole element is the given integer. The - * clone method of the returned set returns the set itself. - * - * @return {s: IntSet | s.ints = i} - */ - public static IntSet singleton(final int i) { - return new SingletonIntSet(i); - } - - /** - * Returns an unmodifiable IntSet that contains all the elements in the given - * range. The clone method of the returned set returns the set itself. - * - * @return {s: IntSet | s.ints = [range.min()..range.max()] } - */ - public static IntSet rangeSet(IntRange range) { - if (range == null) - throw new NullPointerException(); - return new RangeIntSet(range); - } - - /** - * Returns an implementation of the int set interface that offers the best - * time/space trade-off for a set that can store all elements in the half open - * range [0..max). The returned instance may or may not admit elements out of - * the range [0..max). - * - * @return an int set that can store at least the elements in [0..max). - */ - public static IntSet bestSet(int max) { - return max > BITSET_CUTOFF ? new IntTreeSet() : new IntBitSet(max); - } - - /** - * Returns an implementation of the int set interface that offers the best - * time/space trade-off for a set that can store all elements in the closed - * range [min..max]. The returned instance may or may not admit elements out of - * the specified range. - * - * @return an int set that can store at least the elements in the given range. - * @throws IllegalArgumentException min > max - */ - public static IntSet bestSet(int min, int max) { - if (min > max) - throw new IllegalArgumentException("min > max"); - return min < 0 ? new IntTreeSet() : bestSet(max + 1); - } - - /** - * Returns an IntSet that is backed by the given array of integers. The array - * must contain no duplicates, its elements must be sorted in the ascending - * order, and its contents must not be changed while it is in use by the - * returned set. - * - * @requires all i, j: [0..ints.length) | i < j => array[i] <= Sarray[j] - * @return an unmodifiable IntSet view of the given array - */ - public static IntSet asSet(int[] ints) { - return ints.length == 0 ? EMPTY_SET : new ArrayIntSet(ints); - } - - /** - * Returns an unmodifiable IntArray backed by the given array of integers. - * - * @return an unmodifiable IntArray backed by the given array of integers. - */ - public static IntVector asIntVector(final int[] ints) { - return new AbstractIntVector() { - - @Override - public int get(int index) { - return ints[index]; - } - - @Override - public int size() { - return ints.length; - } - - @Override - public int[] toArray(int[] array) { - if (array.length < ints.length) { - array = new int[ints.length]; - } - System.arraycopy(ints, 0, array, 0, ints.length); - return array; - } - }; - } - - /** - * Returns an unmodifiable IntArray of length n which contains the given element - * at each position. - * - * @return an unmodifiable IntArray of length n which contains the given element - * at each position - */ - public static IntVector nCopies(final int n, final int elt) { - return new AbstractIntVector() { - - @Override - public int get(int index) { - if (index < 0 || index >= n) - throw new IndexOutOfBoundsException(); - return elt; - } - - @Override - public int size() { - return n; - } - - @Override - public int[] toArray(int[] array) { - if (array.length < n) { - array = new int[n]; - } - for (int i = 0; i < n; i++) { - array[i] = elt; - } - return array; - } - }; - } - - /*-----------SEQUENCES-----------*/ - - /** - * Returns {@linkplain #EMPTY_SEQUENCE} cast to a sequence of type - * SparseSequence. - * - * @return {@linkplain #EMPTY_SEQUENCE} - */ - @SuppressWarnings("unchecked" ) - public static SparseSequence emptySequence() { - return (SparseSequence) EMPTY_SEQUENCE; - } - - /** - * Returns an unmodifiable view of the specified sparse sequence. This method - * allows modules to provide users with "read-only" access to internal sparse - * sequences. Query operations on the returned sequence "read through" to the - * specified sequence, and attempts to modify the returned sequence, whether - * direct or via its iterator, result in an UnsupportedOperationException. The - * clone() method of the returned sequence returns the result of calling - * s.clone(). - * - * @return an unmodifiable view of s - * @throws NullPointerException s = null - */ - public static SparseSequence unmodifiableSequence(SparseSequence s) { - if (s == null) - throw new NullPointerException(); - if (s instanceof UnmodifiableSparseSequence) - return s; - else - return new UnmodifiableSparseSequence(s); - } - - /*-----------INTEGER MANIPULATION-----------*/ - - /** - * Returns an integer whose value is the 16 low order bits of the given key. - * - * @return key & 0x0000ffff - */ - private static int low16(int key) { - return key & 0x0000ffff; - } - - /** - * Returns an integer whose value is the 16 high order bits of the given key. - * - * @return (key >>> 16) & 0x0000ffff - */ - private static int high16(int key) { - return low16(key >>> 16); - } - - /** - * Performs the bit avalanching step of Paul Hsieh's hashing function - * (http://www.azillionmonkeys.com/qed/hash.html) - * - * @return the bit avalanched version of the given hash value - */ - public static int superFastHashAvalanche(int hash) { - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - return hash; - } - - /** - * Performs the hashing step of Paul Hsieh's hashing function, described at - * http://www.azillionmonkeys.com/qed/hash.html. The method returns a 32 bit - * hash of the given integer, starting with the given initial hash. This - * method does not perform bit avalanching. To get the full hash, call - * {@linkplain #superFastHashAvalanche(int)} on the value returned by this - * method. - * - * @return a 32 bit hash of the given integer, based on the given hash - */ - public static int superFastHashIncremental(int key, int hash) { - - hash += low16(key); - final int tmp = (high16(key) << 11) ^ hash; - hash = (hash << 16) ^ tmp; - hash += hash >> 11; - - // no end cases since the key has exactly 4 bytes - return hash; - } - - /** - * An implementation of Paul Hsieh's hashing function, described at - * http://www.azillionmonkeys.com/qed/hash.html. The method returns a 32 bit - * hash of the given integer. This function is very fast and collision - * resistent; e.g. it hashes the four million integers in the range - * [-2000000,...-1, 1,..., 2000000] to distinct values. The initial hash is - * taken to be 11. - * - * @return a 32 bit hash of the given integer - */ - public static int superFastHash(int key) { - return superFastHashAvalanche(superFastHashIncremental(key, 11)); - } - - /** - * An implementation of Paul Hsieh's hashing function, described at - * http://www.azillionmonkeys.com/qed/hash.html. The method returns a 32 bit - * hash of the given integers, or 0 if the array is empty. The initial hash is - * taken to be the number of keys. - * - * @return a 32 bit hash of the given integers - */ - public static int superFastHash(int... key) { - if (key.length == 0) - return 0; - int hash = key.length; - - for (int word : key) { - hash = superFastHashIncremental(word, hash); - } - // no end cases since key parts are ints - return superFastHashAvalanche(hash); - } - - /** - * An implementation of Paul Hsieh's hashing function, described at - * http://www.azillionmonkeys.com/qed/hash.html. The method returns a 32 bit - * hash of the given objects' hash codes, or zero if the array is empty. Any - * null references in the array are taken to have 0 as their hash code value. - * - * @return a 32 bit hash of the given objects' hashCodes - */ - public static int superFastHash(Object... key) { - if (key.length == 0) - return 0; - int hash = key.length; - - for (Object o : key) { - hash = superFastHashIncremental(o == null ? 0 : o.hashCode(), hash); - } - // no end cases since the hashcodes of key parts are ints - return superFastHashAvalanche(hash); - } - - /** - * An implementation of an IntSet wrapper for an IntRange. - */ - private static final class RangeIntSet extends AbstractIntSet { - - private final IntRange range; - - /** - * Constructs an unmodifiable IntSet wrapper for a range. - */ - RangeIntSet(IntRange range) { - this.range = range; - } - - @Override - public boolean contains(int i) { - return range.contains(i); - } - - @Override - public int min() { - return range.min(); - } - - @Override - public int max() { - return range.max(); - } - - @Override - public IntIterator iterator(final int from, final int to) { - return new IntIterator() { - - final boolean ascending = (from <= to); - long cursor = ascending ? StrictMath.max(range.min(), from) : StrictMath.min(range.max(), from); - final int end = ascending ? StrictMath.min(range.max(), to) : StrictMath.max(range.min(), to); - - @Override - public boolean hasNext() { - return ascending && cursor <= end || !ascending && cursor >= end; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - return ascending ? (int) cursor++ : (int) cursor--; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - }; - } - - @Override - public int size() { - return range.size(); - } - - @SuppressWarnings("unused" ) - public IntSet copy() { - return this; - } - - @Override - public int floor(int i) { - if (i < range.min()) - throw new NoSuchElementException(); - return StrictMath.min(i, range.max()); - } - - @Override - public int ceil(int i) { - if (i > range.max()) - throw new NoSuchElementException(); - return StrictMath.max(i, range.min()); - } - - @Override - public IntSet clone() { - return this; - } - } - - /** - * An implementation of an IntSet wrapper for a single integer. - */ - private static final class SingletonIntSet extends AbstractIntSet { - - private final int i; - - /** - * Constructs an unmodifiable intset wrapper for the given integer. - */ - SingletonIntSet(int i) { - this.i = i; - } - - @Override - public boolean contains(int j) { - return i == j; - } - - @Override - public int min() { - return i; - } - - @Override - public int max() { - return i; - } - - @Override - public IntIterator iterator(final int from, final int to) { - return new IntIterator() { - - boolean cursor = (from <= i && i <= to) || (to <= i && i <= from); - - @Override - public boolean hasNext() { - return cursor; - } - - @Override - public int next() { - if (!hasNext()) - throw new NoSuchElementException(); - cursor = false; - return i; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public int size() { - return 1; - } - - @SuppressWarnings("unused" ) - public IntSet copy() { - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - else if (o instanceof IntSet) { - final IntSet s = (IntSet) o; - return s.size() == 1 && s.min() == i; - } else - return super.equals(o); - } - - @Override - public int hashCode() { - return i; - } - - @Override - public int floor(int j) { - if (i <= j) - return i; - else - throw new NoSuchElementException(); - } - - @Override - public int ceil(int j) { - if (i >= j) - return i; - else - throw new NoSuchElementException(); - } - - @Override - public IntSet clone() { - return this; - } - } - - /** - * An implementation of an unmodifiable IntSet view. - * - * @author Emina Torlak - */ - private static final class UnmodifiableIntSet extends AbstractIntSet { - - private final IntSet s; - - /** - * Constructs an unmodifiable wrapper for the given intset. - * - * @requires set != null - */ - UnmodifiableIntSet(IntSet set) { - this.s = set; - } - - @Override - public int size() { - return s.size(); - } - - @Override - public boolean contains(int i) { - return s.contains(i); - } - - @Override - public int min() { - return s.min(); - } - - @Override - public int max() { - return s.max(); - } - - @SuppressWarnings("unused" ) - public boolean containsAll(IntSet other) { - return s.containsAll(other); - } - - @Override - public IntIterator iterator(final int from, final int to) { - return new IntIterator() { - - IntIterator iter = s.iterator(from, to); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public int next() { - return iter.next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public int floor(int i) { - return s.floor(i); - } - - @Override - public int ceil(int i) { - return s.ceil(i); - } - - @Override - public IntSet clone() throws CloneNotSupportedException { - return s.clone(); - } - } - - /** - * An implementation of an unmodifiable SparseSequence view. - * - * @author Emina Torlak - */ - private static final class UnmodifiableSparseSequence extends AbstractSparseSequence { - - private final SparseSequence s; - - UnmodifiableSparseSequence(SparseSequence s) { - this.s = s; - } - - @Override - public Iterator> iterator(final int from, final int to) { - return new Iterator>() { - - Iterator> iter = s.iterator(from, to); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public IndexedEntry next() { - return iter.next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - }; - } - - @Override - public int size() { - return s.size(); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(); - } - - @Override - public V put(int index, V value) { - throw new UnsupportedOperationException(); - } - - @Override - public V get(int index) { - return s.get(index); - } - - @Override - public V remove(int index) { - throw new UnsupportedOperationException(); - } - - @Override - public IndexedEntry first() { - return s.first(); - } - - @Override - public IndexedEntry last() { - return s.last(); - } - - @Override - public IndexedEntry ceil(int index) { - return s.ceil(index); - } - - @Override - public IndexedEntry floor(int index) { - return s.floor(index); - } - - @Override - public boolean containsIndex(int index) { - return s.containsIndex(index); - } - - @Override - public boolean contains(Object value) { - return s.contains(value); - } - - @Override - public SparseSequence clone() throws CloneNotSupportedException { - return s.clone(); - } - - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/RangeSequence.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/RangeSequence.java deleted file mode 100644 index 38dbcca8d..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/RangeSequence.java +++ /dev/null @@ -1,703 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - *

- * A tree-based sparse sequence implementation. Unlike - * {@link kodkod.util.ints.TreeSequence}, this is not a general-purpose - * sparse sequence implementation. In particular, the entries with - * consecutive indices and the same value are not stored explicitly. As a - * result, methods that return an {@link kodkod.util.ints.IndexedEntry} may - * re-use the same object. Specifically, the last assertion in the following - * code snippet may fail. - *

- * - *
- * // let s be a range sequence abstractly represented as { 0->v, 1->v, 2->v }
- * IndexedEntry e1 = s.predecessor(2);
- * assert e1.index() == 1; // this will work
- * IndexedEntry e2 = s.predecessor(1);
- * assert e1.index() == 1; // this may fail, as e1 may be == to e2
- * 
- *

- * The entries returned by this implementation's {@link #iterator()} are unique - * to that iterator (but not necessarily independent of each other). For - * example, - *

- * - *
- * // let s be a range sequence abstractly represented as { 0->v, 1->v, 2->v }
- * Iterator> iter1 = s.iterator();
- * IndexedEntry e1 = iter1.next();
- * assert e1.index() == 0; // this will work
- * iter1.next();
- * assert e1.index() == 0; // this may fail, as the previous call may have
- *                        // changed the state of e1
- * Iterator> iter2 = s.iterator();
- * IndexedEntry e2 = iter2.next();
- * iter1.next();
- * assert e2.index() == 0; // this will work
- * 
- *

- * This implementation is a good choice when the client expects the usage - * pattern with many consecutive indices mapped to the same value, and when - * there is no need for entry uniqueness. - *

- * - * @author Emina Torlak - */ -public final class RangeSequence extends AbstractSparseSequence implements Cloneable { - - /* - * The ranges are sorted by their right endpoints. All consecutive indices that - * map to the same value are represented by a single range node. - * @invariant (all n: tree.nodes | n.max = n.key && n.min <= n.max) && (no disj - * n, n': tree.nodes | n.value=n'.value && n.max = n'.min-1) - */ - private final IntTree> tree; - private final EntryView view; - private int size; - - /** - * Constructs an empty RangeSequence. - * - * @ensures no this.entries' - */ - public RangeSequence() { - view = new EntryView(Integer.MIN_VALUE, null); - tree = new IntTree>(); - size = 0; - } - - /** - * Copy constructor. - * - * @ensures creatres a deep copy of the original - */ - private RangeSequence(RangeSequence original) { - this.size = original.size; - try { - this.tree = original.tree.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code; - } - view = new EntryView(Integer.MIN_VALUE, null); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#iterator(int, int) - */ - @Override - public Iterator> iterator(int from, int to) { - return from <= to ? new AscendingIterator(from, to) : new DescendingIterator(from, to); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#size() - */ - @Override - public int size() { - return size; - } - - /** - * Removes all entries from this sequences. - * - * @ensures no this.entries' - * @see kodkod.util.ints.SparseSequence#clear() - */ - @Override - public void clear() { - tree.clear(); - size = 0; - } - - /** - * Returns true if e is the head of a contiguous homogenous sequence starting - * with the mapping e.min->e.value and ending with the mapping index->value. - * - * @return e!=null index-1 = e.key && equal(value, e.value) - */ - private boolean isHeadOf(Entry e, int index, V value) { - return e != null && e.key == index - 1 && equal(e.value, value); - } - - /** - * Returns true if e is the tail of a contiguous homogenous sequence starting - * with the mapping index->value and ending with the mapping e.max->e.value. - * - * @return e!=null && index+1 = e.min && equal(value, e.value) - */ - private boolean isTailOf(Entry e, int index, V value) { - return e != null && e.min() == index + 1 && equal(e.value, value); - } - - /** - * Merges the mapping index->value into its floor or ceiling, if possible. - * Otherwise creates a new node for index->value and inserts into the tree. - * - * @requires index !in this.nodes.key - * @requires f = searchLTE(index) && c = searchGTE(index) - * @ensures this.entries' = this.entries + index->value - */ - private void merge(int index, V value, Entry f, Entry c) { - if (isHeadOf(f, index, value)) { - if (f.isPoint()) { - if (isTailOf(c, index, value)) { - if (c.isPoint()) { // [f: 0->a][i: 1->a][c: 2->a] ---> - // [{0,1,2}->a] - tree.delete(c); - tree.replace(f, new Range(f.key, c.key, value)); - } else { // [f: 0->a][i: 1->a][c: {2,3}->a] ---> [c: - // {0,1,2,3}->a] - tree.delete(f); - ((Range) c).min = f.key; - } - } else { // [f: 0->a][i: 1->a] ---> [{0,1}->a] - tree.replace(f, new Range(f.key, index, value)); - } - } else { - if (isTailOf(c, index, value)) { // [f: {-1,0}->a][i: 1->a][c: - // 2->a] ---> [f: - // {-1,0,1,2}->a] - tree.delete(c); - f.key = c.key; - } else { // [f: {-1,0}->a][i: 1->a] ---> [f: {0,1,2}->a] - f.key = index; - } - } - } else if (isTailOf(c, index, value)) { - if (c.isPoint()) { // [i: 1->a][c: 2->a] ---> [{1,2}->a] - tree.replace(c, new Range(index, c.key, value)); - } else { // [i: 1->a][c: {2,3}->a] ---> [c: {1,2,3}->a] - ((Range) c).min = index; - } - } else { // can't merge anything - tree.insert(new Point(index, value)); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#put(int, Object) - */ - @Override - public V put(int index, V value) { - Entry c = tree.searchGTE(index); - if (c == null || c.min() > index) { // we are adding a new index - size++; - merge(index, value, tree.searchLTE(index), c); - return null; - } else { // the index already exists - if (equal(value, c.value)) { - return value; // nothing to do - } else if (c.isPoint()) { - if (isHeadOf(tree.predecessor(c), index, value) || isTailOf(tree.successor(c), index, value)) { - final V oldVal = remove(index); - put(index, value); - return oldVal; - } - return c.setValue(value); - } else { // split the range - final V oldVal = split(index, c); - tree.insert(new Point(index, value)); - return oldVal; - } - } - - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#get(int) - */ - @Override - public V get(int index) { - final Entry e = tree.searchGTE(index); - return e == null || e.min() > index ? null : e.value; - } - - /** - * Splits the z entry into the least number of entries that do not contain the - * given index. - * - * @requires z.min() <= index <= z.max() - * @requires z != NIL - * @ensures this.entries' = this.entries' - index->V - * @return z.value - */ - private V split(int index, Entry z) { - final V val = z.value; - if (z.isPoint()) - tree.delete(z); - else { // z contains a range of keys - final Range r = (Range) z; - final int min = r.min, max = r.key; - if (min == index) { - if (min + 1 < max) - r.min++; - else - tree.replace(r, new Point(max, val)); - } else if (max == index) { - if (max - 1 > min) - r.key--; - else - tree.replace(r, new Point(min, val)); - } else { // index is between min and max - if (min == index - 1) { - tree.replace(r, new Point(index - 1, val)); - if (max == index + 1) { - tree.insert(new Point(max, val)); - } else { - r.min = index + 1; - tree.insert(r); - } - } else { - r.key = index - 1; - if (max == index + 1) { - tree.insert(new Point(max, val)); - } else { - tree.insert(new Range(index + 1, max, val)); - } - } - } - } - return val; - } - - /** - * Removes the entry with the given index, if it exists, and returns the value - * previously stored at the index. If the sequence had no previous mapping for - * the index, null is returned. - * - * @ensures this.entries' = this.entries - index->E - * @return this.entries[index] - * @see kodkod.util.ints.SparseSequence#remove(int) - */ - @Override - public V remove(int index) { - final Entry z = tree.searchGTE(index); - if (z == null || index < z.min()) - return null; - size--; - return split(index, z); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#containsIndex(int) - */ - @Override - public boolean containsIndex(int index) { - final Entry e = tree.searchGTE(index); - return e != null && e.min() <= index; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#first() - */ - @Override - public IndexedEntry first() { - final Entry e = tree.min(); - return e == null ? null : view.setView(e.min(), e.value); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#last() - */ - @Override - public IndexedEntry last() { - final Entry e = tree.max(); - return e == null ? null : view.setView(e.max(), e.value); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#ceil(int) - */ - @Override - public IndexedEntry ceil(int index) { - final Entry e = tree.searchGTE(index); - return e == null ? null : view.setView(StrictMath.max(index, e.min()), e.value); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#floor(int) - */ - @Override - public IndexedEntry floor(int index) { - Entry e = tree.searchGTE(index); - if (e == null || e.min() > index) { - e = tree.searchLTE(index); - return e == null ? null : view.setView(e.max(), e.value); - } else - return view.setView(index, e.value); - } - - /** - * Returns a copy of this sparse sequence. The copy is independent of this - * sequence. - * - * @return a copy of this sparse sequence. - * @see kodkod.util.ints.SparseSequence#clone() - */ - @Override - public RangeSequence clone() { - // ok to use copy constructor to clone a final class - return new RangeSequence(this); - - } - - /** - * A mapping from range of integers in to a value - * - * @specfield min: int - * @specfield max: int - * @specfield value: V - * @invariant min <= max - * @invariant max = key - * @author Emina Torlak - */ - private static abstract class Entry extends IntTree.Node> implements Cloneable { - - V value; - - Entry(int max, V value) { - super(max); - this.value = value; - } - - V setValue(V newValue) { - final V oldValue = value; - value = newValue; - return oldValue; - } - - /** - * Returns the minimum of this. - * - * @return this.min - */ - abstract int min(); - - /** - * Returns the maximum of this. - * - * @return this.max - */ - final int max() { - return key; - } - - /** - * Return true if this.min=this.max - * - * @return this.min = this.max - */ - abstract boolean isPoint(); - - /** - * {@inheritDoc} - * - * @throws CloneNotSupportedException - * @see java.lang.Object#clone() - */ - @Override - protected Entry clone() throws CloneNotSupportedException { - return (Entry) super.clone(); - } - } - - /** - * A point entry in a range sequence. - * - * @specfield min: int - * @specfield max: int - * @specfield value: V - * @specfield index: [min..max] - * @invariant min = max - */ - private static final class Point extends Entry { - - /** - * Constructs an entry with the given index and value. - * - * @ensures this.index' = index && this.value' = value - * @ensures this.min' = this.max' = index - */ - Point(int index, V value) { - super(index, value); - } - - @Override - int min() { - return key; - } - - @Override - boolean isPoint() { - return true; - } - - @Override - protected Point clone() throws CloneNotSupportedException { - return (Point) super.clone(); - } - } - - /** - * A range entry in a range sequence. - * - * @specfield min: int - * @specfield max: int - * @specfield value: V - * @invariant min < max - */ - private static final class Range extends Entry { - - int min; - - /** - * Constructs an entry with the given min/max and value. - * - * @ensures this.index' = min && this.value' = value - * @ensures this.min' = min && this.max' = max - */ - Range(int min, int max, V value) { - super(max, value); - this.min = min; - } - - @Override - int min() { - return min; - } - - @Override - boolean isPoint() { - return false; - } - - @Override - protected Range clone() throws CloneNotSupportedException { - return (Range) super.clone(); - } - } - - /** - * An iterator over the entries in this sequence. - */ - private abstract class EntryIterator implements Iterator>, IndexedEntry { - - final int endIndex; - int endpoint, cursor, index; - boolean canRemove; - Entry next; - V value; - - /** - * @ensures this.endIndex' = endIndex && canRemove = false; - */ - EntryIterator(int endIndex) { - this.endIndex = endIndex; - this.canRemove = false; - } - - @Override - public final int index() { - return index; - } - - @Override - public final V value() { - return value; - } - - @Override - public final boolean equals(Object o) { - if (o == this) - return true; - if (!(o instanceof IndexedEntry)) - return false; - return AbstractSparseSequence.equal(this, (IndexedEntry< ? >) o); - } - - @Override - public final int hashCode() { - return AbstractSparseSequence.hashCode(this); - } - - @Override - public final String toString() { - return index + "=" + value; - } - } - - /** - * An iterator that returns the entries in this sequence in the ascending order - * of indices. - * - * @author Emina Torlak - */ - private final class AscendingIterator extends EntryIterator { - - /** - * Constructs an ascending iterator over the entries with indeces between from - * and to. - * - * @requires from <= to - */ - AscendingIterator(int from, int to) { - super(to); - next = tree.searchGTE(from); - index = Integer.MIN_VALUE; - if (next == null) { - cursor = 0; - endpoint = -1; - value = null; - } else { - cursor = StrictMath.max(next.min(), from); - endpoint = next.key; - value = next.value; - next = tree.successor(next); - } - } - - @Override - public boolean hasNext() { - if (cursor > endpoint) { - if (next == null) - return false; - this.cursor = next.min(); - this.endpoint = next.key; - this.value = next.value; - next = tree.successor(next); - } - return index < Integer.MAX_VALUE && cursor <= endIndex; - } - - @Override - public IndexedEntry next() { - if (!hasNext()) - throw new NoSuchElementException(); - index = cursor++; - canRemove = true; - return this; - } - - @Override - public void remove() { - if (!canRemove) - throw new IllegalStateException(); - RangeSequence.this.remove(index); - next = tree.searchGTE(cursor); - canRemove = false; - } - } - - /** - * An iterator that returns the entries in this sequence in the descending order - * of indices. - * - * @author Emina Torlak - */ - private final class DescendingIterator extends EntryIterator { - - /** - * Constructs a descending iterator over the entries with indeces between from - * and to. - * - * @requires from >= to - */ - DescendingIterator(int from, int to) { - super(to); - next = tree.searchGTE(from); - index = Integer.MAX_VALUE; - if (next == null || next.min() > from) { - next = tree.searchLTE(from); - if (next == null) { - cursor = -1; - endpoint = 0; - value = null; - } else { - cursor = next.key; - endpoint = next.min(); - value = next.value; - } - } else { - cursor = StrictMath.min(next.key, from); - endpoint = next.min(); - value = next.value; - next = tree.predecessor(next); - } - } - - @Override - public boolean hasNext() { - if (cursor < endpoint) { - if (next == null) - return false; - this.cursor = next.key; - this.endpoint = next.min(); - this.value = next.value; - next = tree.predecessor(next); - } - return index > Integer.MIN_VALUE && cursor >= endIndex; - } - - @Override - public IndexedEntry next() { - if (!hasNext()) - throw new NoSuchElementException(); - index = cursor--; - canRemove = true; - return this; - } - - @Override - public void remove() { - if (!canRemove) - throw new IllegalStateException(); - RangeSequence.this.remove(index); - next = tree.searchLTE(cursor); - canRemove = false; - } - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/SparseSequence.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/SparseSequence.java deleted file mode 100644 index 7d07f1a8e..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/SparseSequence.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Collection; -import java.util.Iterator; - -/** - *

- * Represents a sparse sequence -- a sequence whose indices are not necessarily - * contiguous. For example, a sparse sequence can have elements at indices 10, - * 2121, and 3000, without having any elements in between. This specification of - * sparse sequences also supports negative indeces. Formally, the following - * methods specify a partial function from integers to values of type V. - *

- *

- * Sequence implementations are not required to support mutation. All mutating - * operations are optional and may throw an UnsupportedOperationException. - *

- * - * @specfield entries: int -> lone V - * @author Emina Torlak - */ -public interface SparseSequence extends Iterable> { - - /** - * Returns the number of entries in this sequence. - * - * @return #this.entries - */ - public abstract int size(); - - /** - * Returns true if this sequence is empty; otherwise returns false. - * - * @return no this.entries - */ - public abstract boolean isEmpty(); - - /** - * Removes all entries from this sequences. - * - * @ensures no this.entries' - */ - public abstract void clear(); - - /** - * Puts the given value at the specified index. If the sequence already mapped - * the index to a value, the previous value is replaced with the new one and - * returned. - * - * @ensures this.entries' = this.entries + index->value - * @return this.entries[index] - * @throws IndexOutOfBoundsException the given index is not valid for this - * sequence. - * @throws IllegalArgumentException the given value cannot be stored in this - * sequence. - */ - public abstract V put(int index, V value); - - /** - * Copies all of the entries from the specified sparse sequence to this - * sequence. The effect of this call is equivalent to that of calling - * put(e.index, e.value) on this sequence once for each entry e in the specified - * sequence. - * - * @ensures this.entries' = this.entries ++ s.entries - * @throws IndexOutOfBoundsException s contains indeces that are not valid for - * this sequence. - * @throws IllegalArgumentException s contains a value that cannot be stored in - * this sequence. - */ - public abstract void putAll(SparseSequence< ? extends V> s); - - /** - * Returns the value to which this sequence maps the given index. If the index - * is not mapped, null is returned. - * - * @return this.entries[index] - */ - public abstract V get(int index); - - /** - * Removes the entry with the given index, if it exists, and returns the value - * previously stored at the index. If the sequence had no previous mapping for - * the index, null is returned. - * - * @ensures this.entries' = this.entries - index->E - * @return this.entries[index] - */ - public abstract V remove(int index); - - /** - * Returns true if this sparse sequence has an entry for the given index; - * otherwise returns false. - * - * @return some this.entries[index] - */ - public abstract boolean containsIndex(int index); - - /** - * Returns the set of all indices mapped by this sparse sequence. The returned - * set supports removal iff this is not an unmodifiable sparse sequence. The - * returned set may be uncloneable. - * - * @return {s: IntSet | s.ints = this.entries.V} - */ - public abstract IntSet indices(); - - /** - * Returns true if this sequence has an entry with the given value; otherwise - * returns false. - * - * @return some this.entries.value - */ - public abstract boolean contains(Object value); - - /** - * Returns a Collection view of the values stored in this sequence. The returned - * collection supports removal iff this is not an unmodifiable sparse sequence. - * - * @return {c: Collection | c.size()=this.size() && all v: V | c.contains(v) <=> - * this.contains(v) } - */ - public abstract Collection values(); - - /** - * Returns an iterator over the entries in this sequence in the ascending order - * of indeces, starting at this.first(). - * - * @return an iterator over this.entries starting at the entry with the smallest - * index - */ - @Override - public abstract Iterator> iterator(); - - /** - * Returns an iterator over the entries in this sequence, whose indeces are - * between from and to. If from < to, the entries are returned in the ascending - * order of indeces. Otherwise, they are returned in the descending order of - * indeces. - * - * @return an iterator over the entries in this sequence whose indeces are - * between from and to. Formally, if from < to, then the first and last - * entries returned by the iterator are this.ceil(from) and - * this.floor(to). Otherwise, they are this.floor(from) and - * this.ceil(to). - */ - public abstract Iterator> iterator(int from, int to); - - /** - * Returns the entry with the smallest index. If the sequence is empty, returns - * null. - * - * @return {e: IndexedEntry | e.index = min(this.entries.E) && e.value = - * this.entries[e.index] } - */ - public abstract IndexedEntry first(); - - /** - * Returns the entry with the largest index. If the sequence is empty, returns - * null. - * - * @return {e: IndexedEntry | e.index = max(this.entries.E) && e.value = - * this.entries[e.index] } - */ - public abstract IndexedEntry last(); - - /** - * If an entry for the given index exists, it is returned. Otherwise, - * successor(index) is returned. - * - * @return this.containsIndex(index) => {e: IndexedEntry | e.index = index && - * e.value = this.entries[index] }, successor(index) - */ - public abstract IndexedEntry ceil(int index); - - /** - * If an entry for the given index exists, it is returned. Otherwise, - * predecessor(index) is returned. - * - * @return this.containsIndex(index) => {e: IndexedEntry | e.index = index && - * e.value = this.entries[index] }, predecessor(index) - */ - public abstract IndexedEntry floor(int index); - - /** - * Compares the specified object with this sequence for equality. Returns true - * if the given object is also a sparse sequence and the two sequences have the - * same entries. More formally, two sequences t1 and t2 have the the same - * entries if they represent the same function from integers to values: i.e. - * t1.entries = t2.entries. This ensures that the equals method works properly - * across different implementations of the SparseSequence interface. - * - * @return o in SparseSequence && o.entries = this.entries - */ - @Override - public abstract boolean equals(Object o); - - /** - * Returns the hash code value for this sparse sequence. A hash function for a - * sparse sequence must ensure that t1.equals(t2) implies that - * t1.hashCode()==t2.hashCode() for any two sequences t1 and t2, as required by - * the general contract of Object.hashCode. - * - * @return hash code for this sparse sequence - */ - @Override - public abstract int hashCode(); - - /** - * Returns a copy of this sparse sequence. The copy is independent of this - * sequence unless this is a singleton or immutable, in which case clone() may - * return this. An implementing class that does not support cloning may throw a - * CloneNotSupportedException. - * - * @return a copy of this sparse sequence. - * @throws CloneNotSupportedException this is not cloneable - */ - public abstract SparseSequence clone() throws CloneNotSupportedException; - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/TreeSequence.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/TreeSequence.java deleted file mode 100644 index 5d683e0d8..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/TreeSequence.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.ints; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * An implementation of a sparse sequence based on a balanced binary search - * tree. - * - * @author Emina Torlak - */ -public final class TreeSequence extends AbstractSparseSequence implements Cloneable { - - private final IntTree> tree; - private int size; - - /** - * Constructs an empty tree sequence. - * - * @ensures no this.entries' - */ - public TreeSequence() { - tree = new IntTree>(); - size = 0; - } - - /** - * Copy constructor. - * - * @ensures creatres a deep copy of the original - */ - private TreeSequence(TreeSequence original) { - this.size = original.size; - try { - this.tree = original.tree.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(); // unreachable code; - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#iterator(int, int) - */ - @Override - public Iterator> iterator(int from, int to) { - return from <= to ? new AscendingIterator(from, to) : new DescendingIterator(from, to); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#size() - */ - @Override - public int size() { - return size; - } - - /** - * Removes all entries from this sequences. - * - * @ensures no this.entries' - * @see kodkod.util.ints.SparseSequence#clear() - */ - @Override - public void clear() { - tree.clear(); - size = 0; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#put(int, Object) - */ - @Override - public V put(int index, V value) { - final Entry e = tree.search(index); - if (e == null) { - size++; - tree.insert(new Entry(index, value)); - return null; - } else { - return e.setValue(value); - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#get(int) - */ - @Override - public V get(int index) { - final Entry e = tree.search(index); - return e == null ? null : e.value; - } - - /** - * Removes the entry with the given index, if it exists, and returns the value - * previously stored at the index. If the sequence had no previous mapping for - * the index, null is returned. - * - * @ensures this.entries' = this.entries - index->E - * @return this.entries[index] - * @see kodkod.util.ints.SparseSequence#remove(int) - */ - @Override - public V remove(int index) { - final Entry e = tree.search(index); - if (e == null) - return null; - else { - size--; - tree.delete(e); - return e.value; - } - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#containsIndex(int) - */ - @Override - public boolean containsIndex(int index) { - return tree.search(index) != null; - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#first() - */ - @Override - public IndexedEntry first() { - return tree.min(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#last() - */ - @Override - public IndexedEntry last() { - return tree.max(); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#ceil(int) - */ - @Override - public IndexedEntry ceil(int index) { - return tree.searchGTE(index); - } - - /** - * {@inheritDoc} - * - * @see kodkod.util.ints.SparseSequence#floor(int) - */ - @Override - public IndexedEntry floor(int index) { - return tree.searchLTE(index); - } - - /** - * Returns a copy of this sparse sequence. The copy is independent of this - * sequence. - * - * @return a copy of this sparse sequence. - * @see kodkod.util.ints.SparseSequence#clone() - */ - @Override - public TreeSequence clone() { - // ok to use copy constructor to clone a final class - return new TreeSequence(this); - - } - - // public String toString() { - // return tree.toString(); - // } - - private static final class Entry extends IntTree.Node> implements IndexedEntry, Cloneable { - - V value; - - Entry(int key, V value) { - super(key); - this.value = value; - } - - @Override - public int index() { - return key; - } - - @Override - public V value() { - return value; - } - - /** - * Sets this.value to the given value and returns the previous value. - * - * @ensures this.value' = value - * @requires this.value - */ - V setValue(V value) { - V oldValue = this.value; - this.value = value; - return oldValue; - } - - @Override - public boolean equals(Object o) { - if (o == this) - return true; - if (!(o instanceof IndexedEntry)) - return false; - return AbstractSparseSequence.equal(this, (IndexedEntry< ? >) o); - } - - @Override - public int hashCode() { - return AbstractSparseSequence.hashCode(this); - } - - @Override - public String toString() { - return key + "=" + value; - } - - @Override - protected Entry clone() throws CloneNotSupportedException { - return (Entry) super.clone(); - } - } - - private abstract class EntryIterator implements Iterator> { - - final int endIndex; - Entry lastReturned; - Entry next; - - /** - * Constructs a tree iterator which traverses the tree starting at the given - * Entry in either descending or ascending order, depending on whether - * start.index is greater than endIndex. - */ - EntryIterator(Entry start, int endIndex) { - this.next = start; - this.lastReturned = null; - this.endIndex = endIndex; - } - - /** - * Advances the next pointer to its successor, if this is an ascending iterator - * or to its predecessor, if this is a descending iterator. - * - * @requires next != NIL - */ - abstract void advance(); - - @Override - public abstract boolean hasNext(); - - @Override - public IndexedEntry next() { - if (!hasNext()) - throw new NoSuchElementException(); - lastReturned = next; - advance(); - return lastReturned; - } - - @Override - public final void remove() { - if (lastReturned == null) - throw new IllegalStateException(); - if (next == null) { - TreeSequence.this.remove(lastReturned.key); - } else { - final int nextIndex = next.key; - TreeSequence.this.remove(lastReturned.key); - // necessary since the structural modifications made by the - // delete - // procedure may affect the next pointer - next = tree.search(nextIndex); - } - lastReturned = null; - } - } - - private final class AscendingIterator extends EntryIterator { - - /** - * Constructs an ascending iterator over the entries with indeces between from - * and to. - * - * @requires from <= to - */ - AscendingIterator(int from, int to) { - super(tree.searchGTE(from), to); - } - - /** - * Sets next to its successor. - */ - @Override - final void advance() { - next = tree.successor(next); - } - - /** - * Returns true if next != NIL and its index is less than or equal to the ending - * index. - */ - @Override - public boolean hasNext() { - return next != null && next.key <= endIndex; - } - } - - private final class DescendingIterator extends EntryIterator { - - /** - * Constructs a descending iterator over the entries with indeces between from - * and to. - * - * @requires from >= to - */ - DescendingIterator(int from, int to) { - super(tree.searchLTE(from), to); - } - - /** - * Sets next to its predecessor. - */ - @Override - final void advance() { - next = tree.predecessor(next); - } - - /** - * Returns true if next != NIL and its index is greater than or equal to the - * ending index. - */ - @Override - public boolean hasNext() { - return next != null && next.key >= endIndex; - } - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/package.html deleted file mode 100644 index 6202e7840..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/package.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - -Provides implementations of ordered collections for storing integer primitives. - -

Package Specification

- -

Provides several implementations of ordered collections for storing integer primitives.

- -

Related Documentation

- -@see kodkod.util.ints.IntSet -@see kodkod.util.ints.IntVector -@see kodkod.util.ints.SparseSequence - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/ints/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/AnnotatedNode.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/AnnotatedNode.java deleted file mode 100644 index 6fc52c1e4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/AnnotatedNode.java +++ /dev/null @@ -1,899 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.nodes; - -import static kodkod.ast.RelationPredicate.Name.ACYCLIC; -import static kodkod.ast.RelationPredicate.Name.FUNCTION; -import static kodkod.ast.RelationPredicate.Name.TOTAL_ORDERING; -import static kodkod.ast.operator.FormulaOperator.AND; -import static kodkod.ast.operator.FormulaOperator.IMPLIES; -import static kodkod.ast.operator.FormulaOperator.OR; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.EnumMap; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.ExprCastOperator; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.AbstractDetector; -import kodkod.ast.visitor.AbstractVoidVisitor; -import kodkod.ast.visitor.ReturnVisitor; -import kodkod.util.collections.ArrayStack; -import kodkod.util.collections.IdentityHashSet; -import kodkod.util.collections.Stack; - -/** - * A node annotated with information about structural sharing in its ast/dag. - * The class also provides utility methods for collecting various information - * about annotated nodes. - * - * @specfield node: N // annotated node - * @specfield source: node.*components ->one Node // maps the subnodes of - * this.node to nodes from // which they were derived by some - * transformation process // (e.g. skolemization, predicate inlining) - * @author Emina Torlak - */ -public final class AnnotatedNode { - - private final N node; - private final Set sharedNodes; - private final Map< ? extends Node, ? extends Node> source; - private Map< ? extends Node,Boolean> holAnnotations; - - /** - * Constructs a new annotator for the given node. - * - * @ensures this.node' = node && this.source' = node.*components<:iden - */ - private AnnotatedNode(N node) { - this.node = node; - final SharingDetector detector = new SharingDetector(); - node.accept(detector); - this.sharedNodes = Collections.unmodifiableSet(detector.sharedNodes()); - this.source = Collections.emptyMap(); - } - - /** - * Constructs a new annotator for the given node and source map. - * - * @ensures this.node' = node && this.source' = node.*components<:iden ++ source - */ - private AnnotatedNode(N node, Map< ? extends Node, ? extends Node> source) { - this.node = node; - final SharingDetector detector = new SharingDetector(); - node.accept(detector); - this.sharedNodes = Collections.unmodifiableSet(detector.sharedNodes()); - this.source = source; - } - - public boolean hasHOLannotations() { - return holAnnotations != null; - } - - public void annotateHOL() { - HOLAnnotator a = new HOLAnnotator(); - this.node.accept(a); - holAnnotations = a.holAnnotations; - } - - public boolean isHOLNode(Node n) { - assert holAnnotations != null : "not annotated for HOL"; - Boolean ans = holAnnotations != null ? holAnnotations.get(n) : null; - // assert ans != null : "node " + n + " not found in holAnnotations"; - return !Boolean.FALSE.equals(ans); - } - - public boolean isFOLNode(Node n) { - return !isHOLNode(n); - } - - /** - * Returns an annotation for the given node. The source map of the returned - * annotation object maps each descendant of the node to itself. - * - * @return { a: AnnotatedNode | a.node = node && a.source = - * node.*components<:iden } - */ - public static AnnotatedNode annotate(N node) { - return new AnnotatedNode(node); - } - - /** - * Returns an annotation for the given node. The source map of the returned - * annotation object maps each descendant of the node to its value in the given - * source map, or to itself if the given source map has no value for that - * descendant. - * - * @return { a: AnnotatedNode | a.node = node && a.source = - * (node.*components<:iden) ++ source } - */ - public static AnnotatedNode annotate(N node, Map< ? extends Node, ? extends Node> source) { - return new AnnotatedNode(node, source); - } - - /** - * Returns an annotation for an n-ary conjunctions of - * {@linkplain Nodes#roots(Formula) roots} of the given formula. The source map - * of the returned annotation object maps each descendant of the node to itself. - * The root conjunction itself is mapped to the input formula. - * - * @return { a: AnnotatedNode | a.node = - * Formula.and(Nodes.roots(formula)) && a.source = - * (node.^components<:iden) + a.node->formula } - */ - public static AnnotatedNode annotateRoots(Formula formula) { - final Formula flat = Formula.and(Nodes.roots(formula)); - return new AnnotatedNode(flat, Collections.singletonMap(flat, formula)); - } - - /** - * Returns this.node. - * - * @return this.node - */ - public final N node() { - return node; - } - - /** - * Returns the source of the the given descendant of this.node. - * - * @requires n in this.node.*components - * @return this.source[n] - */ - public final Node sourceOf(Node n) { - final Node d = source.get(n); - return d == null ? n : d; - } - - /** - * Returns the set of all non-leaf descendants of this.node that have more than - * one parent. - * - * @return {n: Node | some n.children && #(n.~components & - * this.node.*components) > 1 } - */ - public final Set sharedNodes() { - return sharedNodes; - } - - /** - * Returns the set of all relations at the leaves of this annotated node. - * - * @return Relation & this.node.*components - */ - public final Set relations() { - final Set relations = new IdentityHashSet(); - final AbstractVoidVisitor visitor = new AbstractVoidVisitor() { - - private final Set visited = new IdentityHashSet(sharedNodes.size()); - - @Override - protected boolean visited(Node n) { - return sharedNodes.contains(n) && !visited.add(n); - } - - @Override - public void visit(Relation relation) { - relations.add(relation); - } - }; - node.accept(visitor); - return relations; - } - - public final Set atomRelations() { - final Set ans = new IdentityHashSet(); - for (Relation r : relations()) - if (r.isAtom()) - ans.add(r); - return ans; - } - - public final Set skolemRelations() { - final Set ans = new IdentityHashSet(); - for (Relation r : relations()) - if (r.isSkolem()) - ans.add(r); - return ans; - } - - /** - * Returns true if this.node contains a child whose meaning depends on integer - * bounds (i.e. an ExprToIntCast node with SUM operator or an IntToExprCast node - * or Expression.INTS constant). - * - * @return true if this.node contains a child whose meaning depends on integer - * bounds (i.e. an ExprToIntCast node with SUM operator or an - * IntToExprCast node or Expression.INTS constant). - */ - public final boolean usesInts() { - final AbstractDetector detector = new AbstractDetector(sharedNodes) { - - @Override - public Boolean visit(IntToExprCast expr) { - return cache(expr, Boolean.TRUE); - } - - @Override - public Boolean visit(ExprToIntCast intExpr) { - if (intExpr.op() == ExprCastOperator.CARDINALITY) - super.visit(intExpr); - return cache(intExpr, Boolean.TRUE); - } - - @Override - public Boolean visit(ConstantExpression expr) { - return expr == Expression.INTS ? Boolean.TRUE : Boolean.FALSE; - } - }; - return (Boolean) node.accept(detector); - } - - /** - * Returns a map of RelationPredicate names to sets of top-level relation - * predicates with the corresponding names in this.node. - * - * @return a map of RelationPredicate names to sets of top-level relation - * predicates with the corresponding names in this.node. A predicate is - * considered 'top-level' if it is a component of the top-level - * conjunction, if any, of this.node. - */ - public final Map> predicates() { - final PredicateCollector collector = new PredicateCollector(sharedNodes); - node.accept(collector); - return collector.preds; - } - - /** - * Returns a Detector that will return TRUE when applied to a descendent of - * this.node iff the descendent contains a quantified formula. - * - * @return a Detector that will return TRUE when applied to a descendent of - * this.node iff the descendent contains a quantified formula. - */ - public final AbstractDetector quantifiedFormulaDetector() { - return new AbstractDetector(sharedNodes) { - - @Override - public Boolean visit(QuantifiedFormula quantFormula) { - return cache(quantFormula, true); - } - }; - } - - /** - * Returns a Detector that will return TRUE when applied to a descendent of - * this.node iff the descendent contains a free variable. - * - * @return a Detector that will return TRUE when applied to a descendent of - * this.node iff the descendent contains a free variable. - */ - public final AbstractDetector freeVariableDetector() { - return new FreeVariableDetector(sharedNodes); - } - - /** - * Returns a string representation of this annotated node. - * - * @return string representation of this annotated node. - */ - @Override - public String toString() { - final StringBuilder ret = new StringBuilder(); - ret.append("node: "); - ret.append(node); - ret.append("\nshared nodes: "); - ret.append(sharedNodes); - ret.append("\nsources: "); - ret.append(source); - return ret.toString(); - } - - /** - * Detects shared non-leaf descendents of a given node. - * - * @specfield node: Node // node to which the analyzer is applied - */ - private static final class SharingDetector extends AbstractVoidVisitor { - - /* - * maps each internal node with more than one parent to TRUE and all other - * internal nodes to FALSE - */ - final IdentityHashMap sharingStatus; - /* @invariant numShareNodes = #sharingStatus.TRUE */ - int numSharedNodes; - - SharingDetector() { - sharingStatus = new IdentityHashMap(); - } - - /** - * Returns the shared internal nodes of this.node. This method should be called - * only after this visitor has been applied to this.node. - * - * @return {n: Node | #(n.~children & node.*children) > 1 } - */ - IdentityHashSet sharedNodes() { - final IdentityHashSet shared = new IdentityHashSet(numSharedNodes); - for (Map.Entry entry : sharingStatus.entrySet()) { - if (entry.getValue() == Boolean.TRUE) - shared.add(entry.getKey()); - } - return shared; - } - - /** - * Records the visit to the given node in the status map. If the node has not - * been visited before, it is mapped to Boolean.FALSE and false is returned. - * Otherwise, it is mapped to Boolean.TRUE and true is returned. The first time - * a Node is mapped to true, numSharedNodes is incremented by one. - * - * @ensures no this.shared[node] => this.shared' = this.shared + node->FALSE, - * this.shared[node] = FALSE => this.shared' = this.shared + - * node->TRUE, this.shared' = this.shared - * @return this.shared'[node] - */ - @Override - protected final boolean visited(Node node) { - Boolean status = sharingStatus.get(node); - if (!Boolean.TRUE.equals(status)) { - if (status == null) { - status = Boolean.FALSE; - } else { // status == Boolean.FALSE - status = Boolean.TRUE; - numSharedNodes++; - } - sharingStatus.put(node, status); - } - return status; - } - } - - /** - * A visitor that detects free variables of a node. - * - * @author Emina Torlak - */ - private static final class FreeVariableDetector extends AbstractDetector { - /* - * Holds the variables that are currently in scope, with the variable at the top - * of the stack being the last declared variable. - */ - - private final Stack varsInScope = new ArrayStack(); - - /** - * Constructs a new free variable detector. - */ - FreeVariableDetector(Set sharedNodes) { - super(sharedNodes); - } - - /** - * Visits the given comprehension, quantified formula, or sum expression. The - * method returns TRUE if the creator body contains any variable not bound by - * the decls; otherwise returns FALSE. - */ - private Boolean visit(Node creator, Decls decls, Node body) { - Boolean ret = lookup(creator); - if (ret != null) - return ret; - boolean retVal = false; - for (Decl decl : decls) { - retVal = decl.expression().accept(this) || retVal; - varsInScope.push(decl.variable()); - } - retVal = ((Boolean) body.accept(this)) || retVal; - for (int i = decls.size(); i > 0; i--) { - varsInScope.pop(); - } - return cache(creator, retVal); - } - - /** - * Returns TRUE if the given variable is free in its parent, otherwise returns - * FALSE. - * - * @return TRUE if the given variable is free in its parent, otherwise returns - * FALSE. - */ - @Override - public Boolean visit(Variable variable) { - return Boolean.valueOf(varsInScope.search(variable) < 0); - } - - @Override - public Boolean visit(Decl decl) { - Boolean ret = lookup(decl); - if (ret != null) - return ret; - return cache(decl, decl.expression().accept(this)); - } - - @Override - public Boolean visit(Comprehension comprehension) { - return visit(comprehension, comprehension.decls(), comprehension.formula()); - } - - @Override - public Boolean visit(SumExpression intExpr) { - return visit(intExpr, intExpr.decls(), intExpr.intExpr()); - } - - @Override - public Boolean visit(QuantifiedFormula qformula) { - return visit(qformula, qformula.decls(), qformula.formula()); - } - } - - /** - * A visitor that detects and collects top-level relation predicates; i.e. - * predicates that are components in the top-level conjunction, if any, on ANY - * path starting at the root. - */ - private static final class PredicateCollector extends AbstractVoidVisitor { - - protected boolean negated; - private final Set sharedNodes; - /* - * if a given node is not mapped at all, it means that it has not been visited; - * if it is mapped to FALSE, it has been visited with negated=FALSE, if it is - * mapped to TRUE, it has been visited with negated=TRUE, if it is mapped to - * null, it has been visited with both values of negated. - */ - private final Map visited; - /* - * holds the top level predicates at the the end of the visit - */ - final EnumMap> preds; - - /** - * Constructs a new collector. - * - * @ensures this.negated' = false - */ - PredicateCollector(Set sharedNodes) { - this.sharedNodes = sharedNodes; - this.visited = new IdentityHashMap(); - this.negated = false; - preds = new EnumMap>(RelationPredicate.Name.class); - preds.put(ACYCLIC, new IdentityHashSet(4)); - preds.put(TOTAL_ORDERING, new IdentityHashSet(4)); - preds.put(FUNCTION, new IdentityHashSet(8)); - } - - /** - * Returns true if n has already been visited with the current value of the - * negated flag; otherwise returns false. - * - * @ensures records that n is being visited with the current value of the - * negated flag - * @return true if n has already been visited with the current value of the - * negated flag; otherwise returns false. - */ - @Override - protected final boolean visited(Node n) { - if (sharedNodes.contains(n)) { - if (!visited.containsKey(n)) { // first visit - visited.put(n, Boolean.valueOf(negated)); - return false; - } else { - final Boolean visit = visited.get(n); - if (visit == null || visit == negated) { // already visited - // with same - // negated value - return true; - } else { // already visited with different negated value - visited.put(n, null); - return false; - } - } - } - return false; - } - - /** - * Calls visited(comp); comp's children are not top-level formulas so they are - * not visited. - */ - @Override - public void visit(Comprehension comp) { - visited(comp); - } - - /** - * Calls visited(ifexpr); ifexpr's children are not top-level formulas so they - * are not visited. - */ - @Override - public void visit(IfExpression ifexpr) { - visited(ifexpr); - } - - /** - * Calls visited(ifexpr); ifexpr's children are not top-level formulas so they - * are not visited. - */ - @Override - public void visit(IfIntExpression ifexpr) { - visited(ifexpr); - } - - /** - * Calls visited(intComp); intComp's children are not top-level formulas so they - * are not visited. - */ - @Override - public void visit(IntComparisonFormula intComp) { - visited(intComp); - } - - /** - * Calls visited(quantFormula); quantFormula's children are not top-level - * formulas so they are not visited. - */ - @Override - public void visit(QuantifiedFormula quantFormula) { - visited(quantFormula); - } - - /** - * Visits the children of the given formula if it has not been visited already - * with the given value of the negated flag and if binFormula.op==IMPLIES && - * negated or binFormula.op==AND && !negated or binFormula.op==OR && negated. - * Otherwise does nothing. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.BinaryFormula) - */ - @Override - public void visit(BinaryFormula binFormula) { - if (visited(binFormula)) - return; - final FormulaOperator op = binFormula.op(); - - if ((!negated && op == AND) || (negated && op == OR)) { // op==AND - // || op==OR - binFormula.left().accept(this); - binFormula.right().accept(this); - } else if (negated && op == IMPLIES) { // !(a => b) = !(!a || b) = a - // && !b - negated = !negated; - binFormula.left().accept(this); - negated = !negated; - binFormula.right().accept(this); - } - } - - /** - * Visits the children of the given formula if it has not been visited already - * with the given value of the negated flag and if formula.op==OR && negated or - * formula.op==AND && !negated. Otherwise does nothing. - * - * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.NaryFormula) - */ - @Override - public void visit(NaryFormula formula) { - if (visited(formula)) - return; - final FormulaOperator op = formula.op(); - if ((!negated && op == AND) || (negated && op == OR)) { // op==AND - // || op==OR - for (Formula child : formula) { - child.accept(this); - } - } - } - - /** - * Visits the children of the child of the child formula, with the negation of - * the current value of the negated flag, if it has not already been visited - * with the current value of this.negated; otherwise does nothing. - */ - @Override - public void visit(NotFormula not) { - if (visited(not)) - return; - negated = !negated; - not.formula().accept(this); - negated = !negated; - } - - /** - * Calls visited(compFormula); compFormula's children are not top-level formulas - * so they are not visited. - */ - @Override - public void visit(ComparisonFormula compFormula) { - visited(compFormula); - } - - /** - * Calls visited(multFormula); multFormula's child is not top-level formulas so - * it is not visited. - */ - @Override - public void visit(MultiplicityFormula multFormula) { - visited(multFormula); - } - - /** - * Records the visit to this predicate if it is not negated. - */ - @Override - public void visit(RelationPredicate pred) { - if (visited(pred)) - return; - if (!negated) { - preds.get(pred.name()).add(pred); - } - } - } - - static class HOLAnnotator implements ReturnVisitor { - - private Map holAnnotations = new IdentityHashMap(); - - private Boolean get(Node n) { - return holAnnotations.get(n); - } - - private Boolean place(Node n, Boolean b) { - holAnnotations.put(n, b); - return b; - } - - private Boolean noHOL(Node n) { - return place(n, Boolean.FALSE); - } - - private Boolean checkVisitedThenAccumA(Node n, Boolean acc, E... subs) { - return checkVisitedThenAccum(n, acc, Arrays.asList(subs)); - } - - private Boolean checkVisitedThenAccum(Node n, Boolean acc, Iterable subs) { - Boolean ans = get(n); - if (ans != null) - return ans; - return accum(n, acc, subs); - } - - private Boolean accum(Node n, Boolean acc, Iterable subs) { - for (Node child : subs) { - Boolean res = (Boolean) child.accept(this); - acc = acc || res; - } - return place(n, acc); - } - - @Override - public Boolean visit(Decls decls) { - return checkVisitedThenAccum(decls, Boolean.FALSE, decls); - } - - @Override - public Boolean visit(Decl decl) { - return checkVisitedThenAccumA(decl, decl.multiplicity() != Multiplicity.ONE, decl.variable(), decl.expression()); - } - - @Override - public Boolean visit(Relation relation) { - return noHOL(relation); - } - - @Override - public Boolean visit(Variable variable) { - return noHOL(variable); - } - - @Override - public Boolean visit(ConstantExpression constExpr) { - return noHOL(constExpr); - } - - @Override - public Boolean visit(NaryExpression expr) { - return checkVisitedThenAccum(expr, Boolean.FALSE, expr); - } - - @Override - public Boolean visit(BinaryExpression expr) { - return checkVisitedThenAccumA(expr, Boolean.FALSE, expr.left(), expr.right()); - } - - @Override - public Boolean visit(UnaryExpression expr) { - return checkVisitedThenAccumA(expr, Boolean.FALSE, expr.expression()); - } - - @Override - public Boolean visit(Comprehension cph) { - return checkVisitedThenAccumA(cph, Boolean.FALSE, cph.decls(), cph.formula()); - } - - @Override - public Boolean visit(IfExpression ife) { - return checkVisitedThenAccumA(ife, Boolean.FALSE, ife.condition(), ife.thenExpr(), ife.elseExpr()); - } - - @Override - public Boolean visit(ProjectExpression project) { - Boolean ans = get(project); - if (ans != null) - return ans; - List cols = new ArrayList(project.arity()); - for (int i = 0, arity = project.arity(); i < arity; i++) { - cols.add(project.column(i)); - } - return accum(project, project.expression().accept(this), cols); - } - - @Override - public Boolean visit(IntToExprCast castExpr) { - return checkVisitedThenAccumA(castExpr, Boolean.FALSE, castExpr.intExpr()); - } - - @Override - public Boolean visit(IntConstant intConst) { - return noHOL(intConst); - } - - @Override - public Boolean visit(IfIntExpression e) { - return checkVisitedThenAccumA(e, Boolean.FALSE, e.condition(), e.thenExpr(), e.elseExpr()); - } - - @Override - public Boolean visit(ExprToIntCast e) { - return checkVisitedThenAccumA(e, Boolean.FALSE, e.expression()); - } - - @Override - public Boolean visit(NaryIntExpression e) { - return checkVisitedThenAccum(e, Boolean.FALSE, e); - } - - @Override - public Boolean visit(BinaryIntExpression e) { - return checkVisitedThenAccumA(e, Boolean.FALSE, e.left(), e.right()); - } - - @Override - public Boolean visit(UnaryIntExpression e) { - return checkVisitedThenAccumA(e, Boolean.FALSE, e.intExpr()); - } - - @Override - public Boolean visit(SumExpression e) { - return checkVisitedThenAccumA(e, Boolean.FALSE, e.decls(), e.intExpr()); - } - - @Override - public Boolean visit(IntComparisonFormula f) { - return checkVisitedThenAccumA(f, Boolean.FALSE, f.left(), f.right()); - } - - @Override - public Boolean visit(QuantifiedFormula f) { - return checkVisitedThenAccumA(f, Boolean.FALSE, f.decls(), f.formula()); - } - - @Override - public Boolean visit(NaryFormula f) { - return checkVisitedThenAccum(f, Boolean.FALSE, f); - } - - @Override - public Boolean visit(BinaryFormula f) { - return checkVisitedThenAccumA(f, Boolean.FALSE, f.left(), f.right()); - } - - @Override - public Boolean visit(NotFormula f) { - return checkVisitedThenAccumA(f, Boolean.FALSE, f.formula()); - } - - @Override - public Boolean visit(ConstantFormula cnst) { - return noHOL(cnst); - } - - @Override - public Boolean visit(ComparisonFormula f) { - return checkVisitedThenAccumA(f, Boolean.FALSE, f.left(), f.right()); - } - - @Override - public Boolean visit(MultiplicityFormula f) { - return checkVisitedThenAccumA(f, Boolean.FALSE, f.expression()); - } - - @Override - public Boolean visit(RelationPredicate pred) { - Boolean ans = get(pred); - if (ans != null) - return ans; - pred.relation().accept(this); - if (pred.name() == RelationPredicate.Name.FUNCTION) { - final RelationPredicate.Function fp = (RelationPredicate.Function) pred; - fp.domain().accept(this); - fp.range().accept(this); - } else if (pred.name() == RelationPredicate.Name.TOTAL_ORDERING) { - final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; - tp.ordered().accept(this); - tp.first().accept(this); - tp.last().accept(this); - } - return noHOL(pred); - } - - @Override - public Boolean visit(FixFormula f) { - return checkVisitedThenAccumA(f, Boolean.TRUE, f.formula(), f.condition()); - } - - } - - public Map< ? extends Node, ? extends Node> sources() { - return Collections.unmodifiableMap(this.source); - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/Nodes.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/Nodes.java deleted file mode 100644 index c932af71a..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/Nodes.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.nodes; - -import java.util.AbstractSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Set; - -import kodkod.ast.BinaryFormula; -import kodkod.ast.Formula; -import kodkod.ast.NaryFormula; -import kodkod.ast.Node; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.visitor.AbstractDetector; -import kodkod.ast.visitor.AbstractVoidVisitor; -import kodkod.ast.visitor.VoidVisitor; -import kodkod.util.collections.Containers; -import kodkod.util.collections.IdentityHashSet; - -/** - * Provides utility methods for extracting roots (top-level) conjuncts of Kodkod - * formulas - * - * @author Emina Torlak - */ -public final class Nodes { - - private Nodes() {} - - /** - * Returns the roots of the given formula. In other words, breaks up the given - * formula into its conjunctive components, {f0, ..., fk}, such that, for all - * 0<=i<=k, fi is not a conjunction and [[f0 && ... && fk]] <=> - * [[formula]]. - * - * @return subformulas, {f0, ..., fk}, of the given formula such that, for all - * 0<=i<=k, fi is not a conjuction and [[f0 && ... && fk]] - * <=> [[formula]]. - */ - public static Set roots(Formula formula) { - - final List formulas = new LinkedList(); - formulas.add(formula); - - final ListIterator itr = formulas.listIterator(); - while (itr.hasNext()) { - final Formula f = itr.next(); - if (f instanceof BinaryFormula) { - final BinaryFormula bin = (BinaryFormula) f; - if (bin.op() == FormulaOperator.AND) { - itr.remove(); - itr.add(bin.left()); - itr.add(bin.right()); - itr.previous(); - itr.previous(); - } - } else if (f instanceof NaryFormula) { - final NaryFormula nf = (NaryFormula) f; - if (nf.op() == FormulaOperator.AND) { - itr.remove(); - for (Formula child : nf) { - itr.add(child); - } - for (int i = nf.size(); i > 0; i--) { - itr.previous(); - } - } - } - } - - return new LinkedHashSet(formulas); - } - - /** - * Returns an unmodifiable set consisting of the children of the given formula, - * if the formula is a binary or an nary conjunction. Otherwise returns a - * singleton set containing the formula itself. - * - * @return an unmodifiable set consisting of children of the given formula, if - * the formula is a binary or an nary conjunction. Otherwise returns a - * singleton set containing the formula itself. - */ - public static Set conjuncts(Formula formula) { - if (formula instanceof BinaryFormula) { - final BinaryFormula bin = (BinaryFormula) formula; - if (bin.op() == FormulaOperator.AND) { - final Formula left = bin.left(), right = bin.right(); - if (left == right) - return Collections.singleton(left); - else - return new AbstractSet() { - - @Override - public boolean contains(Object o) { - return left == o || right == o; - } - - @Override - public Iterator iterator() { - return Containers.iterate(left, right); - } - - @Override - public int size() { - return 2; - } - - }; - } - } else if (formula instanceof NaryFormula) { - final NaryFormula nf = (NaryFormula) formula; - if (nf.op() == FormulaOperator.AND) { - final LinkedHashSet children = new LinkedHashSet(1 + (nf.size() * 4) / 3); - for (Formula child : nf) { - children.add(child); - } - return Collections.unmodifiableSet(children); - } - } - - return Collections.singleton(formula); - - } - - public static List allConjuncts(Formula formula, List acc) { - List ans = acc != null ? acc : new ArrayList(); - if (formula instanceof BinaryFormula) { - final BinaryFormula bin = (BinaryFormula) formula; - if (bin.op() == FormulaOperator.AND) { - allConjuncts(bin.left(), ans); - allConjuncts(bin.right(), ans); - return ans; - } - } - if (formula instanceof NaryFormula) { - final NaryFormula nf = (NaryFormula) formula; - if (nf.op() == FormulaOperator.AND) { - for (Formula child : nf) { - allConjuncts(child, ans); - } - return ans; - } - } - ans.add(formula); - return ans; - } - - /** - * Returns a minimal subset of {@linkplain #roots(Formula) roots} of the given - * formula such that all nodes in the given collection are reachable from those - * roots. The returned subset is a local minimum in that none of its members can - * be removed without leaving some node in the descendants set unreachable from - * the remaining roots. - * - * @requires descendants in formula.*components - * @return { s: Set | s.elements in roots(formula) and descendants in - * s.elements.*components and no s': Set | s.containsAll(s') - * and s'.size() minRoots(Formula formula, Collection< ? extends Node> descendants) { - - final Set desc = new IdentityHashSet(descendants); - final VoidVisitor visitor = new AbstractVoidVisitor() { - - final Set visited = new IdentityHashSet(); - - @Override - protected boolean visited(Node n) { - if (visited.add(n)) { - desc.remove(n); - return false; - } - return true; - } - }; - - final Set roots = new LinkedHashSet(); - for (Formula root : roots(formula)) { - final int size = desc.size(); - root.accept(visitor); - if (desc.size() < size) { - roots.add(root); - } - if (desc.isEmpty()) { - break; - } - } - - if (!desc.isEmpty()) - throw new IllegalArgumentException("descendants !in formula.*components: formula=" + formula + " ; descendants=" + descendants); - - return roots; - } - - /** - * Returns all {@linkplain #roots(Formula) roots} of the given formula such that - * a node in the given collection is reachable from that root. - * - * @return { r: roots(formula) | some r.*components & descendants.elements } - */ - @SuppressWarnings("unchecked" ) - public static Set allRoots(Formula formula, Collection< ? extends Node> descendants) { - final Set desc = new IdentityHashSet(descendants); - final AbstractDetector detector = new AbstractDetector(Collections.EMPTY_SET) { - - @Override - protected Boolean lookup(Node n) { - return desc.contains(n) ? Boolean.TRUE : cache.get(n); - } - - @Override - protected Boolean cache(Node n, boolean val) { - final Boolean ret = Boolean.valueOf(val); - cache.put(n, ret); - return ret; - } - }; - - final Set roots = new LinkedHashSet(); - for (Formula root : roots(formula)) { - if (root.accept(detector)) { - roots.add(root); - } - } - - return roots; - } - -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/PrettyPrinter.java b/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/PrettyPrinter.java deleted file mode 100644 index a63f15ab4..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/PrettyPrinter.java +++ /dev/null @@ -1,1015 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.nodes; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.BinaryExpression; -import kodkod.ast.BinaryFormula; -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.ComparisonFormula; -import kodkod.ast.Comprehension; -import kodkod.ast.ConstantExpression; -import kodkod.ast.ConstantFormula; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.ExprToIntCast; -import kodkod.ast.Expression; -import kodkod.ast.FixFormula; -import kodkod.ast.Formula; -import kodkod.ast.IfExpression; -import kodkod.ast.IfIntExpression; -import kodkod.ast.IntComparisonFormula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.IntToExprCast; -import kodkod.ast.LeafExpression; -import kodkod.ast.MultiplicityFormula; -import kodkod.ast.NaryExpression; -import kodkod.ast.NaryFormula; -import kodkod.ast.NaryIntExpression; -import kodkod.ast.Node; -import kodkod.ast.NotFormula; -import kodkod.ast.ProjectExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.RelationPredicate; -import kodkod.ast.SumExpression; -import kodkod.ast.UnaryExpression; -import kodkod.ast.UnaryIntExpression; -import kodkod.ast.Variable; -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.IntOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.visitor.VoidVisitor; - -/** - * Pretty-prints Kodkod nodes. - * - * @author Emina Torlak - */ -public final class PrettyPrinter { - - /** - * Returns a dot representation of the given node that can be visualized with - * GraphViz. - * - * @return a dot representation of the given node that can be visualized with - * GraphViz. - */ - public static String dotify(Node node) { - return Dotifier.apply(node); - } - - /** - * Returns a pretty-printed string representation of the given node, with each - * line offset by at least the given number of whitespaces. The line parameter - * determines the length of each pretty-printed line, including the offset. - * - * @requires 0 <= offset < line - * @return a pretty-printed string representation of the given node - */ - public static String print(Node node, int offset, int line) { - final Formatter formatter = new Formatter(offset, line); - node.accept(formatter); - return formatter.tokens.toString(); - } - - /** - * Returns a pretty-printed string representation of the given node, with each - * line offset by at least the given number of whitespaces. - * - * @requires 0 <= offset < 80 - * @return a pretty-printed string representation of the given node - */ - public static String print(Node node, int offset) { - return print(node, offset, 80); - } - - /** - * Returns a pretty-printed string representation of the given formulas, with - * each line offset by at least the given number of whitespaces. - * - * @requires 0 <= offset < 80 - * @return a pretty-printed string representation of the given formulas - */ - public static String print(Set formulas, int offset) { - return print(formulas, offset, 80); - } - - /** - * Returns a pretty-printed string representation of the given formulas, with - * each line offset by at least the given number of whitespaces. The line - * parameter determines the length of each pretty-printed line, including the - * offset. - * - * @requires 0 <= offset < line - * @return a pretty-printed string representation of the given formulas - */ - public static String print(Set formulas, int offset, int line) { - final Formatter formatter = new Formatter(offset, line); - for (Formula f : formulas) { - f.accept(formatter); - formatter.newline(); - } - return formatter.tokens.toString(); - } - - /** - * Generates a buffer of tokens comprising the string representation of a given - * node. The buffer contains at least the parentheses needed to correctly - * represent the node's tree structure. - * - * @specfield tokens: seq - * @author Emina Torlak - */ - private static class Formatter implements VoidVisitor { - - final StringBuilder tokens; - // final int offset; - private final int lineLength; - private int indent, lineStart; - - /** - * Constructs a new tokenizer. - * - * @ensures no this.tokens - */ - Formatter(int offset, int line) { - assert offset >= 0 && offset < line; - this.tokens = new StringBuilder(); - // this.offset = offset; - this.lineLength = line; - this.lineStart = 0; - this.indent = offset; - indent(); - } - - /*--------------FORMATTERS---------------*/ - - /** - * @ensures this.tokens' = concat [ this.tokens, " ", token, " " ] - */ - private void infix(Object token) { - space(); - tokens.append(token); - space(); - } - - /** - * @ensures this.tokens' = concat [ this.tokens, token, " " ] - */ - private void keyword(Object token) { - append(token); - space(); - } - - /** @ensures this.tokens' = concat [ this.tokens, ", " ] */ - private void comma() { - tokens.append(","); - space(); - } - - /** @ensures this.tokens' = concat [ this.tokens, ": " ] */ - private void colon() { - tokens.append(":"); - space(); - } - - /** @ensures adds this.indent spaces to this.tokens */ - private void indent() { - for (int i = 0; i < indent; i++) { - space(); - } - } - - /** - * @ensures adds newline plus this.indent spaces to this.tokens - */ - private void newline() { - tokens.append("\n"); - lineStart = tokens.length(); - indent(); - } - - /** @ensures this.tokens' = concat[ this.tokens, " " ] **/ - private void space() { - tokens.append(" "); - } - - /** @ensures this.tokens' = concat [ this.tokens, token ] */ - private void append(Object token) { - final String str = String.valueOf(token); - if ((tokens.length() - lineStart + str.length()) > lineLength) { - newline(); - } - tokens.append(str); - } - - /*--------------LEAVES---------------*/ - /** @ensures this.tokens' = concat[ this.tokens, node ] */ - @Override - public void visit(Relation node) { - append(node); - } - - /** @ensures this.tokens' = concat[ this.tokens, node ] */ - @Override - public void visit(Variable node) { - append(node); - } - - /** @ensures this.tokens' = concat[ this.tokens, node ] */ - @Override - public void visit(ConstantExpression node) { - append(node); - } - - /** @ensures this.tokens' = concat[ this.tokens, node ] */ - @Override - public void visit(IntConstant node) { - append(node); - } - - /** @ensures this.tokens' = concat[ this.tokens, node ] */ - @Override - public void visit(ConstantFormula node) { - append(node); - } - - /*--------------DECLARATIONS---------------*/ - /** - * @ensures this.tokens' = concat[ this.tokens, tokenize[ node.variable ], ":", - * tokenize[ node.expression ] - **/ - @Override - public void visit(Decl node) { - node.variable().accept(this); - colon(); - if (node.multiplicity() != Multiplicity.ONE) { - append(node.multiplicity()); - space(); - } - node.expression().accept(this); - } - - /** - * @ensures this.tokens' = concat[ this.tokens, tokenize[ node.declarations[0] - * ], ",", ..., tokenize[ node.declarations[ node.size() - 1 ] ] ] - **/ - @Override - public void visit(Decls node) { - Iterator decls = node.iterator(); - decls.next().accept(this); - while (decls.hasNext()) { - comma(); - decls.next().accept(this); - } - } - - /*--------------UNARY NODES---------------*/ - - /** - * @ensures this.tokenize' = (parenthesize => concat [ this.tokens, "(", - * tokenize[child], ")" ] else concat [ this.tokens, tokenize[child] ] - */ - private void visitChild(Node child, boolean parenthesize) { - if (parenthesize) { - append("("); - } - child.accept(this); - if (parenthesize) { - append(")"); - } - } - - /** - * @return true if the given expression should be parenthesized when a child of - * a compound parent - */ - private boolean parenthesize(Expression child) { - return child instanceof BinaryExpression || child instanceof IfExpression; - } - - /** - * @return true if the given expression should be parenthesized when a child of - * a compound parent - */ - private boolean parenthesize(IntExpression child) { - return !(child instanceof UnaryIntExpression || child instanceof IntConstant || child instanceof ExprToIntCast); - } - - /** - * @return true if the given formula should be parenthesized when a child of a - * compound parent - */ - private boolean parenthesize(Formula child) { - return !(child instanceof NotFormula || child instanceof ConstantFormula || child instanceof RelationPredicate); - } - - /** - * @ensures appends the given op and child to this.tokens; the child is - * parenthesized if it's an instance of binary expression or an if - * expression. - **/ - @Override - public void visit(UnaryExpression node) { - append(node.op()); - visitChild(node.expression(), parenthesize(node.expression())); - } - - /** - * @ensures appends the given op and child to this.tokens; the child is - * parenthesized if it's not an instance of unary int expression or int - * constant. - **/ - @Override - public void visit(UnaryIntExpression node) { - final IntExpression child = node.intExpr(); - final IntOperator op = node.op(); - final boolean parens = (op == IntOperator.ABS) || (op == IntOperator.SGN) || parenthesize(child); - append(node.op()); - visitChild(child, parens); - } - - /** - * @ensures appends the given op and child to this.tokens; the child is - * parenthesized if it's not an instance of not formula, constant - * formula, or relation predicate. - **/ - @Override - public void visit(NotFormula node) { - append("!"); - final boolean pchild = parenthesize(node.formula()); - indent += pchild ? 2 : 1; - visitChild(node.formula(), parenthesize(node.formula())); - indent -= pchild ? 2 : 1; - } - - /** - * @ensures appends the given op and child to this.tokens; the child is - * parenthesized if it's an instance of binary expression or an if - * expression. - **/ - @Override - public void visit(MultiplicityFormula node) { - keyword(node.multiplicity()); - visitChild(node.expression(), parenthesize(node.expression())); - } - - /*--------------BINARY NODES---------------*/ - - /** - * @return true if the given expression needs to be parenthesized if a child of - * a binary expression with the given operator - */ - private boolean parenthesize(ExprOperator op, Expression child) { - return child instanceof IfExpression || child instanceof NaryExpression || (child instanceof BinaryExpression && (op == ExprOperator.JOIN || ((BinaryExpression) child).op() != op)); - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(BinaryExpression node) { - final ExprOperator op = node.op(); - visitChild(node.left(), parenthesize(op, node.left())); - infix(op); - visitChild(node.right(), parenthesize(op, node.right())); - } - - /** @return true if the given operator is assocative */ - private boolean associative(IntOperator op) { - switch (op) { - case DIVIDE : - case MODULO : - case SHA : - case SHL : - case SHR : - return false; - default : - return true; - } - } - - /** - * @return true if the given int expression needs to be parenthesized if a child - * of a binary int expression with the given operator - */ - private boolean parenthesize(IntOperator op, IntExpression child) { - return child instanceof SumExpression || child instanceof IfIntExpression || child instanceof NaryIntExpression || (child instanceof BinaryIntExpression && (!associative(op) || ((BinaryIntExpression) child).op() != op)); - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(BinaryIntExpression node) { - final IntOperator op = node.op(); - visitChild(node.left(), parenthesize(op, node.left())); - infix(op); - visitChild(node.right(), parenthesize(op, node.right())); - } - - /** - * @return true if the given formula needs to be parenthesized if a child of a - * binary formula with the given operator - */ - private boolean parenthesize(FormulaOperator op, Formula child) { - return child instanceof QuantifiedFormula || - // child instanceof NaryFormula || - (child instanceof BinaryFormula && (op == FormulaOperator.IMPLIES || ((BinaryFormula) child).op() != op)); - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(BinaryFormula node) { - final FormulaOperator op = node.op(); - final boolean pleft = parenthesize(op, node.left()); - if (pleft) - indent++; - visitChild(node.left(), pleft); - if (pleft) - indent--; - infix(op); - newline(); - final boolean pright = parenthesize(op, node.right()); - if (pright) - indent++; - visitChild(node.right(), pright); - if (pright) - indent--; - } - - /** - * @ensures this.tokens' = concat[ this.tokens, tokenize[node.left], node.op, - * tokenize[node.right] - */ - @Override - public void visit(ComparisonFormula node) { - visitChild(node.left(), parenthesize(node.left())); - infix(node.op()); - visitChild(node.right(), parenthesize(node.right())); - } - - /** - * @ensures this.tokens' = concat[ this.tokens, tokenize[node.left], node.op, - * tokenize[node.right] - */ - @Override - public void visit(IntComparisonFormula node) { - visitChild(node.left(), parenthesize(node.left())); - infix(node.op()); - visitChild(node.right(), parenthesize(node.right())); - } - - /*--------------TERNARY NODES---------------*/ - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(IfExpression node) { - visitChild(node.condition(), parenthesize(node.condition())); - infix("=>"); - indent++; - newline(); - visitChild(node.thenExpr(), parenthesize(node.thenExpr())); - infix("else"); - newline(); - visitChild(node.elseExpr(), parenthesize(node.elseExpr())); - indent--; - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(IfIntExpression node) { - visitChild(node.condition(), parenthesize(node.condition())); - infix("=>"); - indent++; - newline(); - visitChild(node.thenExpr(), parenthesize(node.thenExpr())); - infix("else"); - newline(); - visitChild(node.elseExpr(), parenthesize(node.elseExpr())); - indent--; - } - - /*--------------VARIABLE CREATOR NODES---------------*/ - /** - * @ensures this.tokens' = concat[ this.tokens, "{", tokenize[node.decls], "|", - * tokenize[ node.formula ], "}" ] - */ - @Override - public void visit(Comprehension node) { - append("{"); - node.decls().accept(this); - infix("|"); - node.formula().accept(this); - append("}"); - } - - /** - * @ensures this.tokens' = concat[ this.tokens, "sum", tokenize[node.decls], - * "|", tokenize[ node.intExpr ], ] - */ - @Override - public void visit(SumExpression node) { - keyword("sum"); - node.decls().accept(this); - infix("|"); - node.intExpr().accept(this); - } - - /** - * @ensures this.tokens' = concat[ this.tokens, node.quantifier, - * tokenize[node.decls], "|", tokenize[ node.formula ] ] - */ - @Override - public void visit(QuantifiedFormula node) { - keyword(node.quantifier()); - node.decls().accept(this); - if (node.domain() != Formula.TRUE) { - infix("| domain{"); - indent++; - newline(); - node.domain().accept(this); - indent--; - newline(); - infix("}"); - infix("| body{"); - indent++; - newline(); - node.body().accept(this); - indent--; - newline(); - infix("}"); - } else { - infix("|"); - indent++; - newline(); - node.body().accept(this); - indent--; - } - } - - @Override - public void visit(FixFormula node) { - keyword("fix {"); - newline(); - indent++; - node.formula().accept(this); - newline(); - indent--; - append("} until {"); - newline(); - indent++; - node.condition().accept(this); - newline(); - indent--; - append("}"); - } - - /*--------------NARY NODES---------------*/ - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(NaryExpression node) { - final ExprOperator op = node.op(); - visitChild(node.child(0), parenthesize(op, node.child(0))); - for (int i = 1, size = node.size(); i < size; i++) { - infix(op); - visitChild(node.child(i), parenthesize(op, node.child(i))); - } - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(NaryIntExpression node) { - final IntOperator op = node.op(); - visitChild(node.child(0), parenthesize(op, node.child(0))); - for (int i = 1, size = node.size(); i < size; i++) { - infix(op); - visitChild(node.child(i), parenthesize(op, node.child(i))); - } - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(NaryFormula node) { - final FormulaOperator op = node.op(); - boolean parens = parenthesize(op, node.child(0)); - if (parens) - indent++; - visitChild(node.child(0), parens); - if (parens) - indent--; - for (int i = 1, size = node.size(); i < size; i++) { - infix(op); - newline(); - parens = parenthesize(op, node.child(i)); - if (parens) - indent++; - visitChild(node.child(i), parens); - if (parens) - indent--; - } - } - /*--------------OTHER NODES---------------*/ - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(ProjectExpression node) { - append("project"); - append("["); - node.expression().accept(this); - comma(); - append("<"); - final Iterator cols = node.columns(); - cols.next().accept(this); - while (cols.hasNext()) { - comma(); - cols.next().accept(this); - } - append(">"); - append("]"); - } - - /** - * @ensures this.tokens' = concat[ this.tokens, "Int","[", - * tokenize[node.intExpr], "]" ] - **/ - @Override - public void visit(IntToExprCast node) { - append("Int"); - append("["); - node.intExpr().accept(this); - append("]"); - } - - /** - * @ensures this.tokens' = concat[ this.tokens, "int","[", - * tokenize[node.expression], "]" ] - **/ - @Override - public void visit(ExprToIntCast node) { - switch (node.op()) { - case SUM : - append("int"); - append("["); - node.expression().accept(this); - append("]"); - break; - case CARDINALITY : - append("#"); - append("("); - node.expression().accept(this); - append(")"); - break; - default : - throw new IllegalArgumentException("unknown operator: " + node.op()); - } - - } - - /** - * @ensures appends the tokenization of the given node to this.tokens - */ - @Override - public void visit(RelationPredicate node) { - switch (node.name()) { - case ACYCLIC : - append("acyclic"); - append("["); - node.relation().accept(this); - append("]"); - break; - case FUNCTION : - RelationPredicate.Function func = (RelationPredicate.Function) node; - append("function"); - append("["); - func.relation().accept(this); - colon(); - func.domain().accept(this); - infix("->"); - keyword(func.targetMult()); - func.range().accept(this); - append("]"); - break; - case TOTAL_ORDERING : - RelationPredicate.TotalOrdering ord = (RelationPredicate.TotalOrdering) node; - append("ord"); - append("["); - ord.relation().accept(this); - comma(); - ord.ordered().accept(this); - comma(); - ord.first().accept(this); - comma(); - ord.last().accept(this); - append("]"); - break; - default : - throw new AssertionError("unreachable"); - } - - } - - } - - private static class Dotifier implements VoidVisitor { - - private final StringBuilder graph = new StringBuilder(); - private final Map ids = new LinkedHashMap(); - - static String apply(Node node) { - final Dotifier dot = new Dotifier(); - dot.graph.append("digraph {\n"); - node.accept(dot); - dot.graph.append("}"); - return dot.graph.toString(); - } - - private boolean visited(Node n) { - if (ids.containsKey(n)) - return true; - ids.put(n, ids.size()); - return false; - } - - private String id(Node n) { - return "N" + ids.get(n); - } - - private void node(Node n, String label) { - graph.append(id(n)); - graph.append("[ label=\""); - graph.append(ids.get(n)); - graph.append("("); - graph.append(label); - graph.append(")\"];\n"); - } - - private void edge(Node n1, Node n2) { - if (n2 instanceof LeafExpression || n2 instanceof ConstantFormula || n2 instanceof IntConstant) { - - } - graph.append(id(n1)); - graph.append("->"); - graph.append(id(n2)); - graph.append(";\n"); - } - - private void visit(Node parent, Object label) { - if (visited(parent)) - return; - node(parent, label.toString()); - } - - private void visit(Node parent, Object label, Node child) { - if (visited(parent)) - return; - node(parent, label.toString()); - child.accept(this); - edge(parent, child); - } - - private void visit(Node parent, Object label, Node left, Node right) { - if (visited(parent)) - return; - node(parent, label.toString()); - left.accept(this); - right.accept(this); - edge(parent, left); - edge(parent, right); - } - - private void visit(Node parent, Object label, Node left, Node middle, Node right) { - if (visited(parent)) - return; - node(parent, label.toString()); - left.accept(this); - middle.accept(this); - right.accept(this); - edge(parent, left); - edge(parent, middle); - edge(parent, right); - } - - private void visit(Node parent, Object label, Iterator< ? extends Node> children) { - if (visited(parent)) - return; - node(parent, label.toString()); - while (children.hasNext()) { - Node child = children.next(); - child.accept(this); - edge(parent, child); - } - } - - private void visit(Node parent, Object label, Node child, Iterator< ? extends Node> children) { - if (visited(parent)) - return; - node(parent, label.toString()); - child.accept(this); - edge(parent, child); - while (children.hasNext()) { - Node other = children.next(); - other.accept(this); - edge(parent, other); - } - } - - @Override - public void visit(Decls decls) { - visit(decls, "decls", decls.iterator()); - } - - @Override - public void visit(Decl decl) { - visit(decl, "decl", decl.variable(), decl.expression()); - } - - @Override - public void visit(Relation relation) { - visit(relation, relation.name()); - } - - @Override - public void visit(Variable variable) { - visit(variable, variable.name()); - } - - @Override - public void visit(ConstantExpression constExpr) { - visit(constExpr, constExpr.name()); - } - - @Override - public void visit(NaryExpression expr) { - visit(expr, expr.op(), expr.iterator()); - } - - @Override - public void visit(BinaryExpression binExpr) { - visit(binExpr, binExpr.op(), binExpr.left(), binExpr.right()); - } - - @Override - public void visit(UnaryExpression unaryExpr) { - visit(unaryExpr, unaryExpr.op(), unaryExpr.expression()); - } - - @Override - public void visit(Comprehension comprehension) { - visit(comprehension, "setcomp", comprehension.decls(), comprehension.formula()); - } - - @Override - public void visit(IfExpression ifExpr) { - visit(ifExpr, "ite", ifExpr.condition(), ifExpr.thenExpr(), ifExpr.elseExpr()); - } - - @Override - public void visit(ProjectExpression project) { - visit(project, "proj", project.expression(), project.columns()); - } - - @Override - public void visit(IntToExprCast castExpr) { - visit(castExpr, castExpr.op(), castExpr.intExpr()); - } - - @Override - public void visit(IntConstant intConst) { - visit(intConst, intConst.value()); - } - - @Override - public void visit(IfIntExpression intExpr) { - visit(intExpr, "ite", intExpr.condition(), intExpr.thenExpr(), intExpr.elseExpr()); - } - - @Override - public void visit(ExprToIntCast intExpr) { - visit(intExpr, intExpr.op(), intExpr.expression()); - } - - @Override - public void visit(NaryIntExpression intExpr) { - visit(intExpr, intExpr.op(), intExpr.iterator()); - } - - @Override - public void visit(BinaryIntExpression intExpr) { - visit(intExpr, intExpr.op(), intExpr.left(), intExpr.right()); - } - - @Override - public void visit(UnaryIntExpression intExpr) { - visit(intExpr, intExpr.op(), intExpr.intExpr()); - } - - @Override - public void visit(SumExpression intExpr) { - visit(intExpr, "sum", intExpr.decls(), intExpr.intExpr()); - } - - @Override - public void visit(IntComparisonFormula intComp) { - visit(intComp, intComp.op(), intComp.left(), intComp.right()); - } - - @Override - public void visit(QuantifiedFormula quantFormula) { - visit(quantFormula, quantFormula.quantifier(), quantFormula.decls(), quantFormula.formula()); - } - - @Override - public void visit(FixFormula fixFormula) { - visit(fixFormula, "fix", fixFormula.formula(), fixFormula.condition()); - } - - @Override - public void visit(NaryFormula formula) { - visit(formula, formula.op(), formula.iterator()); - } - - @Override - public void visit(BinaryFormula binFormula) { - visit(binFormula, binFormula.op(), binFormula.left(), binFormula.right()); - } - - @Override - public void visit(NotFormula not) { - visit(not, "not", not.formula()); - } - - @Override - public void visit(ConstantFormula constant) { - visit(constant, constant.booleanValue()); - } - - @Override - public void visit(ComparisonFormula compFormula) { - visit(compFormula, compFormula.op(), compFormula.left(), compFormula.right()); - } - - @Override - public void visit(MultiplicityFormula multFormula) { - visit(multFormula, multFormula.multiplicity(), multFormula.expression()); - } - - @Override - public void visit(RelationPredicate pred) { - if (visited(pred)) - return; - - if (pred.name() == RelationPredicate.Name.FUNCTION) { - final RelationPredicate.Function fp = (RelationPredicate.Function) pred; - visit(fp, fp.name(), fp.domain(), fp.range()); - } else if (pred.name() == RelationPredicate.Name.TOTAL_ORDERING) { - final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred; - visit(tp, tp.name(), tp.ordered(), tp.first(), tp.last()); - } else { - throw new IllegalArgumentException("Unknown predicate: " + pred); - } - } - - } -} diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/package.html b/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/package.html deleted file mode 100644 index 03fd26ae9..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/package.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - -Provides utility methods for constructing, analyzing, and pretty printing Kodkod nodes. - -

Package Specification

- -

Provides utility methods for constructing, analyzing, and pretty printing Kodkod nodes.

- -

Related Documentation

- -@see kodkod.util.nodes.Nodes -@see kodkod.util.nodes.AnnotatedNode -@see kodkod.util.nodes.PrettyPrinter - - - diff --git a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/packageinfo b/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/packageinfo deleted file mode 100644 index 9ad81f6fa..000000000 --- a/org.alloytools.kodkod.core/src/main/java/kodkod/util/nodes/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0.0 diff --git a/org.alloytools.kodkod.core/src/test/java/Test.java b/org.alloytools.kodkod.core/src/test/java/Test.java deleted file mode 100644 index 66202fe0a..000000000 --- a/org.alloytools.kodkod.core/src/test/java/Test.java +++ /dev/null @@ -1,451 +0,0 @@ -import java.util.Arrays; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.FormulaOperator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -public final class Test { - - public static void main(String[] args) throws Exception { - - Relation x0 = Relation.unary("Int/min"); - Relation x1 = Relation.unary("Int/zero"); - Relation x2 = Relation.unary("Int/max"); - Relation x3 = Relation.nary("Int/next", 2); - Relation x4 = Relation.unary("seq/Int"); - Relation x5 = Relation.unary("String"); - Relation x6 = Relation.unary("this/Null"); - Relation x7 = Relation.unary("this/Str"); - Relation x8 = Relation.unary("this/N0"); - Relation x9 = Relation.unary("this/N1"); - Relation x10 = Relation.unary("this/N2"); - Relation x11 = Relation.unary("this/Node remainder"); - Relation x12 = Relation.unary("this/This"); - Relation x13 = Relation.unary("this/List remainder"); - Relation x14 = Relation.unary("this/far0"); - Relation x15 = Relation.unary("this/far1"); - Relation x16 = Relation.unary("this/mid0"); - Relation x17 = Relation.unary("this/mid1"); - Relation x18 = Relation.unary("this/near0"); - Relation x19 = Relation.unary("this/near1"); - Relation x20 = Relation.nary("this/Node.data", 2); - Relation x21 = Relation.nary("this/Node.next", 2); - Relation x22 = Relation.nary("this/Node.next0", 2); - Relation x23 = Relation.nary("this/Node.next1", 2); - Relation x24 = Relation.nary("this/Node.next3", 2); - Relation x25 = Relation.nary("this/List.head", 2); - Relation x26 = Relation.nary("this/List.head0", 2); - - List atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7", "N0$0", "N1$0", "N2$0", "Null$0", "Str$0", "Str$1", "Str$2", "This$0"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("-8")); - bounds.boundExactly(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("0")); - bounds.boundExactly(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("7")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(2); - x3_upper.add(factory.tuple("-8").product(factory.tuple("-7"))); - x3_upper.add(factory.tuple("-7").product(factory.tuple("-6"))); - x3_upper.add(factory.tuple("-6").product(factory.tuple("-5"))); - x3_upper.add(factory.tuple("-5").product(factory.tuple("-4"))); - x3_upper.add(factory.tuple("-4").product(factory.tuple("-3"))); - x3_upper.add(factory.tuple("-3").product(factory.tuple("-2"))); - x3_upper.add(factory.tuple("-2").product(factory.tuple("-1"))); - x3_upper.add(factory.tuple("-1").product(factory.tuple("0"))); - x3_upper.add(factory.tuple("0").product(factory.tuple("1"))); - x3_upper.add(factory.tuple("1").product(factory.tuple("2"))); - x3_upper.add(factory.tuple("2").product(factory.tuple("3"))); - x3_upper.add(factory.tuple("3").product(factory.tuple("4"))); - x3_upper.add(factory.tuple("4").product(factory.tuple("5"))); - x3_upper.add(factory.tuple("5").product(factory.tuple("6"))); - x3_upper.add(factory.tuple("6").product(factory.tuple("7"))); - bounds.boundExactly(x3, x3_upper); - - TupleSet x4_upper = factory.noneOf(1); - x4_upper.add(factory.tuple("0")); - x4_upper.add(factory.tuple("1")); - x4_upper.add(factory.tuple("2")); - x4_upper.add(factory.tuple("3")); - bounds.boundExactly(x4, x4_upper); - - TupleSet x5_upper = factory.noneOf(1); - bounds.boundExactly(x5, x5_upper); - - TupleSet x6_upper = factory.noneOf(1); - x6_upper.add(factory.tuple("Null$0")); - bounds.boundExactly(x6, x6_upper); - - TupleSet x7_upper = factory.noneOf(1); - x7_upper.add(factory.tuple("Str$0")); - x7_upper.add(factory.tuple("Str$1")); - x7_upper.add(factory.tuple("Str$2")); - bounds.bound(x7, x7_upper); - - TupleSet x8_upper = factory.noneOf(1); - x8_upper.add(factory.tuple("N0$0")); - bounds.boundExactly(x8, x8_upper); - - TupleSet x9_upper = factory.noneOf(1); - x9_upper.add(factory.tuple("N1$0")); - bounds.boundExactly(x9, x9_upper); - - TupleSet x10_upper = factory.noneOf(1); - x10_upper.add(factory.tuple("N2$0")); - bounds.boundExactly(x10, x10_upper); - - TupleSet x11_upper = factory.noneOf(1); - bounds.boundExactly(x11, x11_upper); - - TupleSet x12_upper = factory.noneOf(1); - x12_upper.add(factory.tuple("This$0")); - bounds.boundExactly(x12, x12_upper); - - TupleSet x13_upper = factory.noneOf(1); - bounds.boundExactly(x13, x13_upper); - - TupleSet x14_upper = factory.noneOf(1); - x14_upper.add(factory.tuple("N2$0")); - bounds.bound(x14, x14_upper); - - TupleSet x15_upper = factory.noneOf(1); - x15_upper.add(factory.tuple("Null$0")); - bounds.bound(x15, x15_upper); - - TupleSet x16_upper = factory.noneOf(1); - x16_upper.add(factory.tuple("N1$0")); - bounds.bound(x16, x16_upper); - - TupleSet x17_upper = factory.noneOf(1); - x17_upper.add(factory.tuple("N2$0")); - bounds.bound(x17, x17_upper); - - TupleSet x18_upper = factory.noneOf(1); - x18_upper.add(factory.tuple("N0$0")); - bounds.bound(x18, x18_upper); - - TupleSet x19_upper = factory.noneOf(1); - x19_upper.add(factory.tuple("N1$0")); - bounds.bound(x19, x19_upper); - - TupleSet x20_upper = factory.noneOf(2); - x20_upper.add(factory.tuple("N0$0").product(factory.tuple("Null$0"))); - x20_upper.add(factory.tuple("N0$0").product(factory.tuple("Str$0"))); - x20_upper.add(factory.tuple("N0$0").product(factory.tuple("Str$1"))); - x20_upper.add(factory.tuple("N0$0").product(factory.tuple("Str$2"))); - x20_upper.add(factory.tuple("N1$0").product(factory.tuple("Null$0"))); - x20_upper.add(factory.tuple("N1$0").product(factory.tuple("Str$0"))); - x20_upper.add(factory.tuple("N1$0").product(factory.tuple("Str$1"))); - x20_upper.add(factory.tuple("N1$0").product(factory.tuple("Str$2"))); - x20_upper.add(factory.tuple("N2$0").product(factory.tuple("Null$0"))); - x20_upper.add(factory.tuple("N2$0").product(factory.tuple("Str$0"))); - x20_upper.add(factory.tuple("N2$0").product(factory.tuple("Str$1"))); - x20_upper.add(factory.tuple("N2$0").product(factory.tuple("Str$2"))); - bounds.bound(x20, x20_upper); - - TupleSet x21_upper = factory.noneOf(2); - x21_upper.add(factory.tuple("N0$0").product(factory.tuple("N1$0"))); - x21_upper.add(factory.tuple("N1$0").product(factory.tuple("N2$0"))); - x21_upper.add(factory.tuple("N2$0").product(factory.tuple("Null$0"))); - bounds.bound(x21, x21_upper); - - TupleSet x22_upper = factory.noneOf(2); - x22_upper.add(factory.tuple("N0$0").product(factory.tuple("N1$0"))); - x22_upper.add(factory.tuple("N0$0").product(factory.tuple("N2$0"))); - x22_upper.add(factory.tuple("N1$0").product(factory.tuple("N2$0"))); - x22_upper.add(factory.tuple("N2$0").product(factory.tuple("Null$0"))); - bounds.bound(x22, x22_upper); - - TupleSet x23_upper = factory.noneOf(2); - x23_upper.add(factory.tuple("N0$0").product(factory.tuple("N1$0"))); - x23_upper.add(factory.tuple("N0$0").product(factory.tuple("N2$0"))); - x23_upper.add(factory.tuple("N1$0").product(factory.tuple("N0$0"))); - x23_upper.add(factory.tuple("N1$0").product(factory.tuple("N2$0"))); - x23_upper.add(factory.tuple("N2$0").product(factory.tuple("Null$0"))); - bounds.bound(x23, x23_upper); - - TupleSet x24_upper = factory.noneOf(2); - x24_upper.add(factory.tuple("N0$0").product(factory.tuple("N1$0"))); - x24_upper.add(factory.tuple("N1$0").product(factory.tuple("N0$0"))); - x24_upper.add(factory.tuple("N1$0").product(factory.tuple("N2$0"))); - x24_upper.add(factory.tuple("N2$0").product(factory.tuple("Null$0"))); - x24_upper.add(factory.tuple("N2$0").product(factory.tuple("N1$0"))); - bounds.bound(x24, x24_upper); - - TupleSet x25_upper = factory.noneOf(2); - x25_upper.add(factory.tuple("This$0").product(factory.tuple("N0$0"))); - bounds.bound(x25, x25_upper); - - TupleSet x26_upper = factory.noneOf(2); - x26_upper.add(factory.tuple("This$0").product(factory.tuple("N0$0"))); - x26_upper.add(factory.tuple("This$0").product(factory.tuple("N1$0"))); - x26_upper.add(factory.tuple("This$0").product(factory.tuple("N2$0"))); - bounds.bound(x26, x26_upper); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Expression x29 = x8.intersection(x9); - Formula x28 = x29.no(); - Expression x32 = x8.union(x9); - Expression x31 = x32.intersection(x10); - Formula x30 = x31.no(); - Expression x36 = x32.union(x10); - Expression x35 = x36.union(x11); - Expression x34 = x35.union(x6); - Formula x33 = x14.in(x34); - Expression x38 = x35.union(x6); - Formula x37 = x15.in(x38); - Expression x40 = x35.union(x6); - Formula x39 = x16.in(x40); - Expression x42 = x35.union(x6); - Formula x41 = x17.in(x42); - Expression x44 = x35.union(x6); - Formula x43 = x18.in(x44); - Expression x46 = x35.union(x6); - Formula x45 = x19.in(x46); - Formula x47 = x14.one(); - Formula x48 = x15.one(); - Formula x49 = x16.one(); - Formula x50 = x17.one(); - Formula x51 = x18.one(); - Formula x52 = x19.one(); - Variable x55 = Variable.unary("this"); - Decls x54 = x55.oneOf(x35); - Expression x58 = x55.join(x20); - Formula x57 = x58.one(); - Expression x60 = x7.union(x6); - Formula x59 = x58.in(x60); - Formula x56 = x57.and(x59); - Formula x53 = x56.forAll(x54); - Expression x62 = x20.join(Expression.UNIV); - Formula x61 = x62.in(x35); - Variable x66 = Variable.unary("this"); - Decls x65 = x66.oneOf(x35); - Expression x69 = x66.join(x21); - Formula x68 = x69.one(); - Expression x71 = x35.union(x6); - Formula x70 = x69.in(x71); - Formula x67 = x68.and(x70); - Formula x64 = x67.forAll(x65); - Expression x73 = x21.join(Expression.UNIV); - Formula x72 = x73.in(x35); - Variable x76 = Variable.unary("this"); - Decls x75 = x76.oneOf(x35); - Expression x79 = x76.join(x22); - Formula x78 = x79.one(); - Expression x81 = x35.union(x6); - Formula x80 = x79.in(x81); - Formula x77 = x78.and(x80); - Formula x74 = x77.forAll(x75); - Expression x83 = x22.join(Expression.UNIV); - Formula x82 = x83.in(x35); - Variable x86 = Variable.unary("this"); - Decls x85 = x86.oneOf(x35); - Expression x89 = x86.join(x23); - Formula x88 = x89.one(); - Expression x91 = x35.union(x6); - Formula x90 = x89.in(x91); - Formula x87 = x88.and(x90); - Formula x84 = x87.forAll(x85); - Expression x93 = x23.join(Expression.UNIV); - Formula x92 = x93.in(x35); - Variable x96 = Variable.unary("this"); - Decls x95 = x96.oneOf(x35); - Expression x99 = x96.join(x24); - Formula x98 = x99.one(); - Expression x101 = x35.union(x6); - Formula x100 = x99.in(x101); - Formula x97 = x98.and(x100); - Formula x94 = x97.forAll(x95); - Expression x103 = x24.join(Expression.UNIV); - Formula x102 = x103.in(x35); - Variable x106 = Variable.unary("this"); - Expression x107 = x12.union(x13); - Decls x105 = x106.oneOf(x107); - Expression x110 = x106.join(x25); - Formula x109 = x110.one(); - Expression x112 = x35.union(x6); - Formula x111 = x110.in(x112); - Formula x108 = x109.and(x111); - Formula x104 = x108.forAll(x105); - Expression x114 = x25.join(Expression.UNIV); - Formula x113 = x114.in(x107); - Variable x117 = Variable.unary("this"); - Decls x116 = x117.oneOf(x107); - Expression x120 = x117.join(x26); - Formula x119 = x120.one(); - Expression x122 = x35.union(x6); - Formula x121 = x120.in(x122); - Formula x118 = x119.and(x121); - Formula x115 = x118.forAll(x116); - Expression x124 = x26.join(Expression.UNIV); - Formula x123 = x124.in(x107); - Expression x126 = x12.product(x8); - Formula x125 = x25.eq(x126); - Expression x130 = x8.product(x9); - Expression x131 = x9.product(x10); - Expression x129 = x130.union(x131); - Expression x132 = x10.product(x6); - Expression x128 = x129.union(x132); - Formula x127 = x21.eq(x128); - Expression x134 = x12.join(x25); - Formula x133 = x18.eq(x134); - Expression x136 = x18.join(x21); - Formula x135 = x16.eq(x136); - Expression x138 = x16.join(x21); - Formula x137 = x14.eq(x138); - Expression x141 = x18.product(x14); - Expression x140 = x21.override(x141); - Formula x139 = x22.eq(x140); - Expression x144 = x16.product(x18); - Expression x143 = x22.override(x144); - Formula x142 = x23.eq(x143); - Formula x145 = x19.eq(x16); - Formula x146 = x17.eq(x14); - Expression x148 = x14.join(x23); - Formula x147 = x15.eq(x148); - Formula x153 = x14.eq(x6); - Formula x152 = x153.not(); - Expression x151 = x152.thenElse(x23, x22); - Expression x155 = x152.thenElse(x17, x16); - Expression x156 = x152.thenElse(x19, x18); - Expression x154 = x155.product(x156); - Expression x150 = x151.override(x154); - Formula x149 = x24.eq(x150); - Expression x159 = x12.product(x155); - Expression x158 = x25.override(x159); - Formula x157 = x26.eq(x158); - Expression x161 = x152.thenElse(x15, x14); - Formula x160 = x161.eq(x6); - Expression x164 = x21.closure(); - Expression x172 = Expression.INTS.union(x5); - Expression x171 = x172.union(x6); - Expression x170 = x171.union(x7); - Expression x169 = x170.union(x35); - Expression x168 = x169.union(x107); - Expression x167 = x168.product(Expression.UNIV); - Expression x165 = Expression.IDEN.intersection(x167); - Expression x163 = x164.intersection(x165); - Formula x162 = x163.no(); - Expression x177 = x12.join(x25); - Formula x176 = x177.eq(x6); - Formula x175 = x176.not(); - Expression x181 = x12.join(x25); - Expression x180 = x181.join(x21); - Formula x179 = x180.eq(x6); - Formula x178 = x179.not(); - Formula x174 = x175.and(x178); - Expression x184 = x24.closure(); - Expression x186 = x168.product(Expression.UNIV); - Expression x185 = Expression.IDEN.intersection(x186); - Expression x183 = x184.intersection(x185); - Formula x182 = x183.no(); - Expression x190 = x12.join(x26); - Expression x192 = x24.closure(); - Expression x194 = x168.product(Expression.UNIV); - Expression x193 = Expression.IDEN.intersection(x194); - Expression x191 = x192.union(x193); - Expression x189 = x190.join(x191); - Expression x196 = x12.join(x25); - Expression x198 = x21.closure(); - Expression x200 = x168.product(Expression.UNIV); - Expression x199 = Expression.IDEN.intersection(x200); - Expression x197 = x198.union(x199); - Expression x195 = x196.join(x197); - Formula x188 = x189.eq(x195); - Expression x209 = x12.join(x25); - Expression x211 = x21.closure(); - Expression x213 = x168.product(Expression.UNIV); - Expression x212 = Expression.IDEN.intersection(x213); - Expression x210 = x211.union(x212); - Expression x208 = x209.join(x210); - Expression x207 = x208.difference(x6); - Expression x206 = x207.product(x207); - Expression x205 = x21.intersection(x206); - Expression x204 = x205.transpose(); - Expression x203 = x21.override(x204); - Expression x215 = x12.join(x25); - Expression x214 = x215.product(x6); - Expression x202 = x203.override(x214); - Formula x201 = x24.eq(x202); - Formula x187 = x188.and(x201); - Formula x216 = x0.eq(x0); - Formula x217 = x1.eq(x1); - Formula x218 = x2.eq(x2); - Formula x219 = x3.eq(x3); - Formula x220 = x4.eq(x4); - Formula x221 = x5.eq(x5); - Formula x222 = x6.eq(x6); - Formula x223 = x7.eq(x7); - Formula x224 = x8.eq(x8); - Formula x225 = x9.eq(x9); - Formula x226 = x10.eq(x10); - Formula x227 = x11.eq(x11); - Formula x228 = x12.eq(x12); - Formula x229 = x13.eq(x13); - Formula x230 = x14.eq(x14); - Formula x231 = x15.eq(x15); - Formula x232 = x16.eq(x16); - Formula x233 = x17.eq(x17); - Formula x234 = x18.eq(x18); - Formula x235 = x19.eq(x19); - Formula x236 = x20.eq(x20); - Formula x237 = x21.eq(x21); - Formula x238 = x22.eq(x22); - Formula x239 = x23.eq(x23); - Formula x240 = x24.eq(x24); - Formula x241 = x25.eq(x25); - Formula x242 = x26.eq(x26); - Formula x27 = Formula.compose(FormulaOperator.AND, x28, x30, x33, x37, x39, x41, x43, x45, x47, x48, x49, x50, x51, x52, x53, x61, x64, x72, x74, x82, x84, x92, x94, x102, x104, x113, x115, x123, x125, x127, x133, x135, x137, x139, x142, x145, x146, x147, x149, x157, x160, x162, x174, x182, x187, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225, x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236, x237, x238, x239, x240, x241, x242); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - System.out.println("Solving..."); - System.out.flush(); - System.out.println(bounds); - Solution sol = solver.solve(x27, bounds); - System.out.println(sol.toString()); - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/AbstractWorldDefinitions.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/AbstractWorldDefinitions.class deleted file mode 100644 index e062c8c7e..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/AbstractWorldDefinitions.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/AbstractWorldDefinitions.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/AbstractWorldDefinitions.java deleted file mode 100644 index f00509ef9..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/AbstractWorldDefinitions.java +++ /dev/null @@ -1,485 +0,0 @@ -package examples.alloy; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.LinkedList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.ConsoleReporter; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * KK encoding of mondex/a.als together with mondex/common.als. - * - * @author Emina Torlak - */ -public final class AbstractWorldDefinitions { - - // relations declared in common.als - private final Relation Coin, Purse, TransferDetails; - private final Relation from, to, value; - - // relations declared in a.als - private final Relation AbWorld, AbPurse, aNullIn, AIN, AOUT, aNullOut; - private final Relation abAuthPurse, abBalance, abLost; - - /** - * Constructs an instance of AbstractWorldDefinitions. - */ - public AbstractWorldDefinitions() { - Coin = Relation.unary("Coin"); - Purse = Relation.unary("Purse"); - TransferDetails = Relation.unary("TransferDetails"); - from = Relation.binary("from"); - to = Relation.binary("to"); - value = Relation.binary("value"); - - AbWorld = Relation.unary("AbWorld"); - AbPurse = Relation.unary("AbPurse"); - aNullIn = Relation.unary("aNullIn"); - AIN = Relation.unary("AIN"); - AOUT = Relation.unary("AOUT"); - aNullOut = Relation.unary("aNullOut"); - abAuthPurse = Relation.binary("abAuthPurse"); - abBalance = Relation.ternary("abBalance"); - abLost = Relation.ternary("abLost"); - } - - /** - * Returns the declaration constraints for mondex/common.als - * - * @return declaration constraints for mondex/common.als - */ - public Formula decls() { - - final Formula f0 = from.function(TransferDetails, Purse); - final Formula f1 = to.function(TransferDetails, Purse); - final Formula f2 = value.in(TransferDetails.product(Coin)); - - final Formula f3 = AbPurse.in(Purse); - final Formula f4 = abAuthPurse.in(AbWorld.product(AbPurse)); - final Formula f5 = abBalance.in(AbPurse.product(Coin).product(AbWorld)); - final Formula f6 = abLost.in(AbPurse.product(Coin).product(AbWorld)); - final Formula f7 = AIN.in(aNullIn.union(TransferDetails)); - final Formula f8 = aNullOut.in(AOUT); - - // final List fs = Arrays.asList(f0, f1, f2, f3, f4, f5, f6, - // f7, f8); - // Collections.shuffle(fs); - - return Formula.and(f0, f1, f2, f3, f4, f5, f6, f7, f8);// Formula.and(fs); - - } - - /** - * Applies the XiTransfer predicate to the arguments. - * - * @return application of the XiTransfer predicate to the arguments. - */ - public final Formula XiTransfer(Expression p, Expression pprime) { - final Formula f0 = p.join(from).eq(pprime.join(from)); - final Formula f1 = p.join(to).eq(pprime.join(to)); - final Formula f2 = p.join(value).eq(pprime.join(value)); - return Formula.and(f0, f1, f2); - } - - /** - * Returns the application of the Abstract predicate. - * - * @return application of the Abstract predicate. - */ - public Formula Abstract(Expression s) { - final Expression e0 = s.join(abAuthPurse).join(abBalance).join(s).intersection(s.join(abAuthPurse).join(abLost).join(s)); - final Formula f0 = e0.no(); - - final Expression e1 = s.join(abAuthPurse).product(Expression.UNIV); - final Expression e2 = e1.intersection((abBalance.union(abLost)).join(s)); - final Formula f1 = e2.in(AbPurse.product(Coin)); - final Variable c = Variable.unary("c"); - final Formula f2 = e2.join(c).lone().forAll(c.oneOf(Coin)); - - return Formula.and(f0, f1, f2); - } - - /** - * Returns the application of the XiAbPurse predicate. - * - * @return application of the XiAbPurse predicate. - */ - public Formula XiAbPurse(Expression s, Expression sprime, Expression a) { - final Expression aRestrict = a.product(Expression.UNIV); - final Formula f0 = aRestrict.intersection(abBalance.join(s)).eq(aRestrict.intersection(abBalance.join(sprime))); - final Formula f1 = aRestrict.intersection(abLost.join(s)).eq(aRestrict.intersection(abLost.join(sprime))); - return f0.and(f1); - } - - /** - * Returns the application of the totalBalance function. - * - * @return application of the totalBalance function. - */ - public Expression totalBalance(Expression s) { - return s.join(abAuthPurse).join(abBalance).join(s); - } - - /** - * Returns the application of the totalLost function. - * - * @return application of the totalLost function. - */ - public Expression totalLost(Expression s) { - return s.join(abAuthPurse).join(abLost).join(s); - } - - /** - * Returns the application of the NoValueCreation predicate. - * - * @return application of the NoValueCreation predicate. - */ - public Formula NoValueCreation(Expression s, Expression sprime) { - return totalBalance(sprime).in(totalBalance(s)); - } - - /** - * Returns the application of the AllValueAccounted predicate. - * - * @return application of the AllValueAccounted predicate. - */ - public Formula AllValueAccounted(Expression s, Expression sprime) { - return totalBalance(sprime).union(totalLost(sprime)).in(totalBalance(s).union(totalLost(s))); - } - - /** - * Returns the application of the Authentic predicate. - * - * @return application of the Authentic predicate. - */ - public Formula Authentic(Expression s, Expression p) { - return p.in(s.join(abAuthPurse)); - } - - /** - * Returns the application of the Authentic predicate. - * - * @return application of the Authentic predicate. - */ - public Formula SufficientFundsProperty(Expression s, Expression t) { - return t.join(value).in(t.join(from).join(abBalance).join(s)); - } - - /** - * Returns the application of the AbOp predicate. - * - * @return application of the AbOp predicate. - */ - public Formula AbOp(Expression a_out) { - return a_out.eq(aNullOut); - } - - /** - * Returns the application of the AbIgnore predicate. - * - * @return application of the AbIgnore predicate. - */ - public Formula AbIgnore(Expression s, Expression sprime, Expression a_out) { - final Formula f0 = AbOp(a_out); - final Formula f1 = s.join(abAuthPurse).eq(sprime.join(abAuthPurse)); - final Formula f2 = XiAbPurse(s, sprime, s.join(abAuthPurse)); - return f0.and(f1).and(f2); - } - - /** - * Returns the application of the AbWorldSecureOp predicate. - * - * @return application of the AbWorldSecureOp predicate. - */ - public Formula AbWorldSecureOp(Expression s, Expression sprime, Expression a_in, Expression a_out) { - final Formula f0 = AbOp(a_out); - final Formula f1 = a_in.in(TransferDetails); - - final Expression e0 = a_in.join(from); - final Expression e1 = a_in.join(to); - final Expression e2 = s.join(abAuthPurse).difference(e0).difference(e1); - final Expression e3 = sprime.join(abAuthPurse).difference(e0).difference(e1); - final Formula f2 = e2.eq(e3); - - final Formula f3 = XiAbPurse(s, sprime, e2); - - return Formula.and(f0, f1, f2, f3); - } - - /** - * Returns the application of the AbTransferOkay predicate. - * - * @return application of the AbTransferOkay predicate. - */ - public Formula AbTransferOkay(Expression s, Expression sprime, Expression a_in, Expression a_out) { - final Expression e0 = a_in.join(from); - final Expression e1 = a_in.join(to); - - final Formula f0 = AbWorldSecureOp(s, sprime, a_in, a_out); - final Formula f1 = Authentic(s, e0); - final Formula f2 = Authentic(s, e1); - final Formula f3 = SufficientFundsProperty(s, a_in); - final Formula f4 = e0.intersection(e1).no(); - - final Formula f5 = e0.join(abBalance).join(sprime).eq(e0.join(abBalance).join(s).difference(a_in.join(value))); - final Formula f6 = e0.join(abLost).join(sprime).eq(e0.join(abLost).join(s)); - final Formula f7 = e1.join(abBalance).join(sprime).eq(e1.join(abBalance).join(s).union(a_in.join(value))); - final Formula f8 = e1.join(abLost).join(sprime).eq(e1.join(abLost).join(s)); - - final Formula f9 = Authentic(sprime, e0); - final Formula f10 = Authentic(sprime, e1); - - return Formula.and(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10); - - } - - /** - * Returns the application of the AbTransferLost predicate. - * - * @return application of the AbTransferOkay predicate. - */ - public Formula AbTransferLost(Expression s, Expression sprime, Expression a_in, Expression a_out) { - final Expression e0 = a_in.join(from); - final Expression e1 = a_in.join(to); - - final Formula f0 = AbWorldSecureOp(s, sprime, a_in, a_out); - final Formula f1 = Authentic(s, e0); - final Formula f2 = Authentic(s, e1); - final Formula f3 = SufficientFundsProperty(s, a_in); - final Formula f4 = e0.intersection(e1).no(); - - final Formula f5 = e0.join(abBalance).join(sprime).eq(e0.join(abBalance).join(s).difference(a_in.join(value))); - final Formula f6 = e0.join(abLost).join(sprime).eq(e0.join(abLost).join(s).union(a_in.join(value))); - - final Formula f7 = XiAbPurse(s, sprime, e1); - - final Formula f8 = Authentic(sprime, e0); - final Formula f9 = Authentic(sprime, e1); - - return Formula.and(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9); - } - - /** - * Returns the application of the AbTransfer predicate. - * - * @return application of the AbTransfer predicate. - */ - public Formula AbTransfer(Expression s, Expression sprime, Expression a_in, Expression a_out) { - return AbTransferOkay(s, sprime, a_in, a_out).or(AbTransferLost(s, sprime, a_in, a_out)).or(AbIgnore(s, sprime, a_out)); - } - - /** - * Returns decls() && !A241() - * - * @return decls() && !A241() - */ - public Formula checkA241() { - return decls().and(A241().not()); - } - - /** - * Returns decls() && !AbOp_total() - * - * @return decls() && !AbOp_total() - */ - public Formula checkAbOp_total() { - return decls().and(AbOp_total().not()); - } - - /** - * Returns decls() && !AbIgnore_inv() - * - * @return decls() && !AbIgnore_inv() - */ - public Formula checkAbIgnore_inv() { - return decls().and(AbIgnore_inv().not()); - } - - /** - * Returns decls() && !AbTransfer_inv() - * - * @return decls() && !AbTransfer_inv() - */ - public Formula checkAbTransfer_inv() { - return decls().and(AbTransfer_inv().not()); - } - - /** - * Returns the A241 assertion. - * - * @return A241 assertion - */ - public Formula A241() { - final Variable s = Variable.unary("s"); - final Variable sprime = Variable.unary("s'"); - final Variable a_in = Variable.unary("a_in"); - final Variable a_out = Variable.unary("a_out"); - - final Formula f0 = Abstract(s).and(Abstract(sprime)).and(AbTransfer(s, sprime, a_in, a_out)); - final Formula f1 = NoValueCreation(s, sprime).and(AllValueAccounted(s, sprime)); - final Formula f2 = f0.implies(f1).forAll(s.oneOf(AbWorld).and(sprime.oneOf(AbWorld)).and(a_in.oneOf(AIN)).and(a_out.oneOf(AOUT))); - - return f2; - } - - /** - * Returns the AbOp_total assertion. - * - * @return AbOp_total assertion - */ - public Formula AbOp_total() { - final Variable a = Variable.unary("a"); - final Variable a_in = Variable.unary("a_in"); - - final Formula f0 = Abstract(a).implies(AbIgnore(a, a, aNullOut).and(AbTransfer(a, a, a_in, aNullOut))); - final Formula f1 = f0.forAll(a.oneOf(AbWorld).and(a_in.oneOf(AIN))); - - return f1; - } - - /** - * Returns the AbIgnore_inv assertion. - * - * @return AbIgnore_inv assertion - */ - public Formula AbIgnore_inv() { - final Variable a = Variable.unary("a"); - final Variable aprime = Variable.unary("a'"); - final Variable a_out = Variable.unary("a_out"); - - final Formula f0 = (Abstract(a).and(AbIgnore(a, aprime, a_out))).implies(Abstract(aprime)); - final Formula f1 = f0.forAll(a.oneOf(AbWorld).and(aprime.oneOf(AbWorld)).and(a_out.oneOf(AOUT))); - - return f1; - } - - /** - * Returns the AbTransfer_inv assertion. - * - * @return AbTransfer_inv assertion - */ - public Formula AbTransfer_inv() { - final Variable a = Variable.unary("a"); - final Variable aprime = Variable.unary("a'"); - final Variable a_in = Variable.unary("a_in"); - final Variable a_out = Variable.unary("a_out"); - - final Formula f0 = (Abstract(a).and(AbTransfer(a, aprime, a_in, a_out))).implies(Abstract(aprime)); - final Formula f1 = f0.forAll(a.oneOf(AbWorld).and(aprime.oneOf(AbWorld)).and(a_in.oneOf(AIN)).and(a_out.oneOf(AOUT))); - - return f1; - } - - /** - * Returns the bounds for the given scope. - * - * @return bounds for the given scope - */ - public final Bounds bounds(int scope) { - final List atoms = new LinkedList(); - - final int max = scope - 1; - for (int i = 0; i < scope; i++) { - atoms.add("Coin" + i); - } - for (int i = 0; i < scope; i++) { - atoms.add("Purse" + i); - } - for (int i = 0; i < scope; i++) { - atoms.add("TransferDetails" + i); - } - atoms.add("aNullIn"); - for (int i = 0; i < scope; i++) { - atoms.add("AbWorld" + i); - } - for (int i = 0; i < max; i++) { - atoms.add("AOUT" + i); - } - atoms.add("aNullOut"); - - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - b.bound(Coin, f.range(f.tuple("Coin0"), f.tuple("Coin" + max))); - b.bound(Purse, f.range(f.tuple("Purse0"), f.tuple("Purse" + max))); - b.bound(TransferDetails, f.range(f.tuple("TransferDetails0"), f.tuple("TransferDetails" + max))); - b.bound(AbWorld, f.range(f.tuple("AbWorld0"), f.tuple("AbWorld" + max))); - b.bound(AbPurse, b.upperBound(Purse)); - b.bound(AOUT, f.range(f.tuple("AOUT0"), f.tuple("aNullOut"))); - b.bound(AIN, f.range(f.tuple("TransferDetails0"), f.tuple("aNullIn"))); - - b.boundExactly(aNullIn, f.setOf("aNullIn")); - b.boundExactly(aNullOut, f.setOf("aNullOut")); - - b.bound(from, b.upperBound(TransferDetails).product(b.upperBound(Purse))); - b.bound(to, b.upperBound(TransferDetails).product(b.upperBound(Purse))); - b.bound(value, b.upperBound(TransferDetails).product(b.upperBound(Coin))); - b.bound(abAuthPurse, b.upperBound(AbWorld).product(b.upperBound(AbPurse))); - - b.bound(abBalance, b.upperBound(AbPurse).product(b.upperBound(Coin)).product(b.upperBound(AbWorld))); - b.bound(abLost, b.upperBound(AbPurse).product(b.upperBound(Coin)).product(b.upperBound(AbWorld))); - - return b; - } - - private static void usage() { - System.out.println("java examples.AbstractWorldDefinitions [A241 | AbOp_total | AbIgnore_inv | AbTransfer_inv] [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.AbstractWorldDefinitions [A241 | AbOp_total | - * AbIgnore_inv | AbTransfer_inv] [univ size] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - - try { - final String assertion = args[0]; - final int n = Integer.parseInt(args[1]); - if (n < 1) - usage(); - final AbstractWorldDefinitions model = new AbstractWorldDefinitions(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setReporter(new ConsoleReporter()); - // solver.options().setFlatten(true); - final Method method = model.getClass().getMethod(assertion); - final Formula f = model.decls().and(((Formula) method.invoke(model)).not()); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchMethodException e) { - usage(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/CeilingsAndFloors.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/CeilingsAndFloors.class deleted file mode 100644 index eeffa8a8a..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/CeilingsAndFloors.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/CeilingsAndFloors.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/CeilingsAndFloors.java deleted file mode 100644 index 3dd0ab8da..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/CeilingsAndFloors.java +++ /dev/null @@ -1,203 +0,0 @@ -package examples.alloy; - -import java.util.LinkedList; -import java.util.List; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A kodkod encoding of ceilingsAndFloors.als - * - *
- * In his 1973 song, Paul Simon said "One Man's Ceiling Is Another Man's Floor".
- * Does it follow that "One Man's Floor Is Another Man's Ceiling"?
- *
- * To see why not, check the assertion BelowToo.
- *
- * Perhaps simply preventing man's own floor from being his ceiling is enough,
- * as is done in the Geometry constraint.  BelowToo' shows that there are still
- * cases where Geometry holds but the implication does not, although now
- * the smallest solution has 3 Men and 3 Platforms instead of just 2 of each.
- *
- * What if we instead prevent floors and ceilings from being shared,
- * as is done in the NoSharing constraint?  The assertion BelowToo''
- * has no counterexamples, demonstrating that the implication now
- * holds for all small examples.
- *
- * model author: Daniel Jackson (11/2001)
- * modified by Robert Seater (11/2004)
- *
- * sig Platform {}
- * sig Man {ceiling, floor: Platform}
- * fact PaulSimon {all m: Man | some n: Man | Above (n,m)}
- * pred Above(m, n: Man) {m.floor = n.ceiling}
- *
- * assert BelowToo {all m: Man | some n: Man | Above (m,n)}
- * check BelowToo for 2 expect 1
- *
- * pred Geometry (){no m: Man | m.floor = m.ceiling}
- *  assert BelowToo' {Geometry() => all m: Man | some n: Man | Above (m,n)}
- * check BelowToo' for 2 expect 0
- * check BelowToo' for 3 expect 1
- *
- * pred NoSharing() {no disj m,n: Man | m.floor = n.floor || m.ceiling = n.ceiling}
- * assert BelowToo'' {NoSharing() => all m: Man | some n: Man | Above (m,n)}
- * check BelowToo'' for 5 expect 0
- * check BelowToo'' for 10 expect 0
- * 
- * - * @author Emina Torlak - */ -public final class CeilingsAndFloors { - - private final Relation Platform, Man, ceiling, floor; - - /** - * Creates an instance of the ceilings and floors class. - */ - public CeilingsAndFloors() { - Platform = Relation.unary("Platform"); - Man = Relation.unary("Man"); - ceiling = Relation.binary("ceiling"); - floor = Relation.binary("floor"); - } - - /** - * Returns a formula that constrains the ceiling and floor relations to be - * functions from Man to Platform. - * - * @return FUNCTION(ceiling, Man, Platform) && FUNCTION(floor, Man, Platform) - */ - public Formula declarations() { - // ceiling and floor are functions from Man to Platform - return ceiling.function(Man, Platform).and(floor.function(Man, Platform)); - } - - /** - * Returns the belowToo constraint - * - * @return all m: Man | some n: Man | m.floor = n.ceiling - */ - public Formula belowToo() { - final Variable m = Variable.unary("m0"), n = Variable.unary("n0"); - // all m: Man | some n: Man | m.floor = n.ceiling - return ((m.join(floor).eq(n.join(ceiling))).forSome(n.oneOf(Man)).forAll(m.oneOf(Man))); - - } - - /** - * Returns the noSharing constraint. - * - * @return all m, n: Man | !(m = n) => !(m.floor = n.floor || m.ceiling = - * n.ceiling) - */ - public Formula noSharing() { - final Variable m = Variable.unary("m1"), n = Variable.unary("n1"); - // all m, n: Man | !(m = n) => !(m.floor = n.floor || m.ceiling = - // n.ceiling) - final Formula body = (m.join(floor).eq(n.join(floor))).or(m.join(ceiling).eq(n.join(ceiling))); - return (m.eq(n).not().implies(body.not())).forAll(m.oneOf(Man).and(n.oneOf(Man))); - } - - /** - * Returns the paulSimon constraint. - * - * @return all m: Man | some n: Man | n.floor = m.ceiling - */ - public Formula paulSimon() { - final Variable m = Variable.unary("m2"), n = Variable.unary("n2"); - // all m: Man | some n: Man | n.floor = m.ceiling - return ((n.join(floor).eq(m.join(ceiling))).forSome(n.oneOf(Man)).forAll(m.oneOf(Man))); - - } - - /** - * Returns the belowToo'' constraint. - * - * @return declarations() && paulSimon() && noSharing() && !belowToo() - */ - public Formula checkBelowTooDoublePrime() { - return declarations().and(paulSimon()).and(noSharing()).and(belowToo().not()); - } - - /** - * Returns the belowToo assertion. - * - * @return declarations() && paulSimon() && !belowToo() - */ - public Formula checkBelowTooAssertion() { - return declarations().and(paulSimon()).and(belowToo().not()); - } - - /** - * Creates bounds for the problem using the given number of platforms and men. - * - * @return bounds for the problem using the given number of platforms and men. - */ - public Bounds bounds(int scope) { - return bounds(scope, scope); - } - - /** - * Creates bounds for the problem using the given number of platforms and men. - * - * @return bounds for the problem using the given number of platforms and men. - */ - public Bounds bounds(int platforms, int men) { - final List atoms = new LinkedList(); - for (int i = 0; i < men; i++) { - atoms.add("Man" + i); - } - for (int i = 0; i < platforms; i++) { - atoms.add("Platform" + i); - } - final Universe universe = new Universe(atoms); - final TupleFactory factory = universe.factory(); - final Bounds bounds = new Bounds(universe); - final String manMax = "Man" + (men - 1), platformMax = "Platform" + (platforms - 1); - - bounds.bound(Platform, factory.range(factory.tuple("Platform0"), factory.tuple(platformMax))); - bounds.bound(Man, factory.range(factory.tuple("Man0"), factory.tuple(manMax))); - bounds.bound(ceiling, factory.area(factory.tuple("Man0", "Platform0"), factory.tuple(manMax, platformMax))); - bounds.bound(floor, factory.area(factory.tuple("Man0", "Platform0"), factory.tuple(manMax, platformMax))); - - return bounds; - } - - private static void usage() { - System.out.println("Usage: java examples.CeilingsAndFloors [# men] [# platforms]"); - System.exit(1); - } - - /** - * Usage: java examples.CeilingsAndFloors [# men] [# platforms] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - - final CeilingsAndFloors model = new CeilingsAndFloors(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - try { - final int m = Integer.parseInt(args[0]); - final int p = Integer.parseInt(args[1]); - final Formula show = model.checkBelowTooDoublePrime(); - final Solution sol = solver.solve(show, model.bounds(m, p)); - System.out.println(show); - System.out.println(sol); - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DNACuts.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/DNACuts.class deleted file mode 100644 index 1df3470c2..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DNACuts.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DNACuts.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/DNACuts.java deleted file mode 100644 index 6c750e770..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DNACuts.java +++ /dev/null @@ -1,240 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Kodkod encoding of the DNA cuts model: - * - *
- * module s2
- *
- * open util/ordering[Link]
- *
- * abstract sig Base { partner: one Base }
- * one sig A, T, G, C extends Base {}
- *
- * fact partners {
- *  A.partner = T
- *  T.partner = A
- *  G.partner = C
- *  C.partner = G }
- *
- * abstract sig Link { base: one Base }
- *
- * sig CutLink, JoinLink extends Link {}
- *
- * fact CutChainsAtMost6BasesLong {
- *  all c: CutLink |
- *   next(c) in JoinLink || next(next(c)) in JoinLink ||
- *   next(next(next(c))) in JoinLink ||
- *   next(next(next(next(c)))) in JoinLink ||
- *   next(next(next(next(next(c))))) in JoinLink }
- *
- * pred noMatch(l1, l2: Link) {
- *   l1 in JoinLink || l2 in JoinLink ||
- *   l1.base !in (l1.base + l2.base.partner) }
- *
- * fact CutLinkUniqueness {
- *  all c1, c2 : CutLink |
- *   c1 != c2 && prev(c1) in JoinLink && prev(c2) in JoinLink => {
- *    c1.base != (c2.base + c2.base.partner) ||
- *    noMatch(next(c1), next(c2)) || noMatch(next(next(c1)), next(next(c2))) ||
- *    noMatch(next(next(next(c1))), next(next(next(c2)))) ||
- *    noMatch(next(next(next(next(c1)))), next(next(next(next(c2))))) ||
- *    noMatch(next(next(next(next(next(c1))))), next(next(next(next(next(c2)))))) } }
- *
- *
- * pred show () {
- *  Base in Link.base
- *  some JoinLink
- *  some disj c1, c2, c3, c4, c5: CutLink |
- *   prev(c1) in JoinLink &&
- *   next(c1) = c2 && next(c2) = c3 &&
- *   next(c3) in JoinLink && next(c4) = c5 &&
- *   next(c5) in JoinLink }
- *
- * run show for exactly 11 Link
- * 
- * - * @author Emina Torlak - */ -public final class DNACuts { - - private final Relation next, Link, CutLink, JoinLink, Base, base, partner; - private final Expression[] neighbor; - - /** - * Constructs an instance of the DNACuts example for the given cut link length. - */ - public DNACuts(int cutLinkLength) { - assert cutLinkLength > 0; - Base = Relation.unary("Base"); - Link = Relation.unary("Link"); - CutLink = Relation.unary("CutLink"); - JoinLink = Relation.unary("JoinLink"); - base = Relation.binary("base"); - next = Relation.binary("next"); - partner = Relation.binary("partner"); - neighbor = new Expression[cutLinkLength - 1]; - if (cutLinkLength > 1) { - neighbor[0] = next; - for (int i = 1; i < cutLinkLength - 1; i++) { - neighbor[i] = next.join(neighbor[i - 1]); - } - } - - } - - /** - * Returns declarations constraints. - * - * @return declarations constraints. - */ - public Formula declarations() { - final Variable l = Variable.unary("l"); - final Formula f0 = l.join(base).one().forAll(l.oneOf(Link)); - final Formula f1 = CutLink.union(JoinLink).eq(Link); - final Formula f2 = CutLink.intersection(JoinLink).no(); - return f0.and(f1).and(f2); - } - - /** - * Returns the cutChainLength constraint. (Similar to CutChainsAtMost6BasesLong - * fact, but with the cut chain length as specified during construction.) - * - * @return the cutChainLength constraint - */ - public Formula cutChainLength() { - Formula ret = Formula.FALSE; - final Variable c = Variable.unary("c"); - for (int i = 0; i < neighbor.length; i++) { - ret = ret.or(c.join(neighbor[i]).in(JoinLink)); - } - return ret.forAll(c.oneOf(CutLink)); - } - - /** - * Returns the cutLinkUniqueness constraint. - * - * @return the cutLinkUniqueness constraint. - */ - public Formula cutLinkUniqueness() { - final Variable c1 = Variable.unary("c1"); - final Variable c2 = Variable.unary("c2"); - final Formula f0 = c1.eq(c2).not().and(next.join(c1).in(JoinLink)).and(next.join(c2).in(JoinLink)); - Formula f = c1.join(base).in(c2.join(base).union(c2.join(base).join(partner))).not(); - for (int i = 0; i < neighbor.length; i++) { - Expression c1n = c1.join(neighbor[i]), c2n = c2.join(neighbor[i]); - f = f.or(c1n.in(JoinLink)).or(c2n.in(JoinLink)); - f = f.or(c1n.join(base).in(c2n.join(base).union(c2n.join(base).join(partner))).not()); - } - return f0.implies(f).forAll(c1.oneOf(CutLink).and(c2.oneOf(CutLink))); - } - - /** - * Returns the show predicate. - * - * @return the show predicate. - */ - public Formula show() { - final Formula f0 = Base.in(Link.join(base)); - final Formula f1 = JoinLink.some(); - final Formula f2 = CutLink.some(); - return declarations().and(cutChainLength()).and(cutLinkUniqueness()).and(f0).and(f1).and(f2); - } - - /** - * Returns the bounds for n links. - * - * @return bounds for n links. - */ - public Bounds bounds(int n) { - assert n >= 0; - final List atoms = new ArrayList(n + 4); - atoms.add("A"); - atoms.add("T"); - atoms.add("G"); - atoms.add("C"); - for (int i = 0; i < n; i++) { - atoms.add("Link" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final TupleSet bases = f.range(f.tuple("A"), f.tuple("C")); - final TupleSet links = f.range(f.tuple("Link0"), f.tuple("Link" + (n - 1))); - - b.boundExactly(Base, bases); - b.boundExactly(Link, links); - b.bound(CutLink, links); - b.bound(JoinLink, links); - - final TupleSet randomSequence = f.noneOf(2); - final Random r = new Random(); - for (int i = 0; i < n; i++) { - randomSequence.add(f.tuple("Link" + i, u.atom(r.nextInt(4)))); - } - b.boundExactly(base, randomSequence); - - final TupleSet partners = f.noneOf(2); - partners.add(f.tuple("A", "T")); - partners.add(f.tuple("T", "A")); - partners.add(f.tuple("G", "C")); - partners.add(f.tuple("C", "G")); - - b.boundExactly(partner, partners); - - final TupleSet linkOrd = f.noneOf(2); - for (int i = 1; i < n; i++) { - linkOrd.add(f.tuple("Link" + (i - 1), "Link" + i)); - } - - b.boundExactly(next, linkOrd); - - return b; - } - - private static void usage() { - System.out.println("Usage: java examples.alloy.DNACuts [cut chain length] [# links]"); - System.exit(1); - } - - /** - * Usage: java examples.alloy.DNACuts [cut chain length] [# links] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - - try { - final DNACuts model = new DNACuts(Integer.parseInt(args[0])); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - Formula f = model.show(); - Bounds b = model.bounds(Integer.parseInt(args[1])); - System.out.println("solving..."); - Solution sol = solver.solve(f, b); - // System.out.println(f); - // System.out.println(b); - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DiffEg.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/DiffEg.class deleted file mode 100644 index a26a47121..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DiffEg.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DiffEg.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/DiffEg.java deleted file mode 100644 index 707c0d1ac..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/DiffEg.java +++ /dev/null @@ -1,209 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/* --- A simple access control policy framework - -sig Subject {} -sig Resource {} -sig Action {} -one sig Request {s : Subject, r : Resource, a : Action } - --- predicates from policies -sig Conflicted {s : Subject, r : Resource} - --- An access rule -pred RevPaperNoConflict (req : Request) { - no conf : Conflicted | req.s in conf.s && req.r in conf.r -} - --- A Policy (would normally be disjunction of rules) -pred pol (req: Request) { - RevPaperNoConflict(req) -} - -run pol for 2 -*/ -public final class DiffEg { - // sigs - - private final Relation Subject, Resource, Action, Request, Conflicted; - private final Relation sRequest, rRequest, action, sConflicted, rConflicted; - - public DiffEg() { - Subject = Relation.unary("Subject"); - Resource = Relation.unary("Resource"); - Action = Relation.unary("Action"); - Request = Relation.unary("Request"); - Conflicted = Relation.unary("Conflicted"); - sRequest = Relation.binary("s"); - rRequest = Relation.binary("r"); - action = Relation.binary("a"); - sConflicted = Relation.binary("s"); - rConflicted = Relation.binary("r"); - } - - /** - * Returns the formulas implicit in the declarations. - * - * @return formulas implicit in: - * - *
-     * sig Subject {}
-     * sig Resource {}
-     * sig Action {}
-     * one sig Request {s : Subject,  r : Resource, a : Action }
-     * sig Conflicted {s : Subject, r : Resource}
-     *         
- */ - public final Formula decls() { - final Formula f0 = Request.one(); // one Request - // s is a function from Request to Subject - final Formula f1 = sRequest.function(Request, Subject); - // r is a function from Request to Resource - final Formula f2 = rRequest.function(Request, Resource); - // a is a function from Request to Action - final Formula f3 = action.function(Request, Action); - // s is a function from Conflicted to Subject - final Formula f4 = sConflicted.function(Conflicted, Subject); - // r is a function from Conflicted to Resource - final Formula f5 = rConflicted.function(Conflicted, Resource); - return f0.and(f1).and(f2).and(f3).and(f4).and(f5); - } - - /** - * Returns the RevPaperNoConflict access rule. - * - * @return - * - *
-     * pred RevPaperNoConflict (req : Request) {
-     *  no conf : Conflicted | req.s in conf.s && req.r in conf.r
-     * }
-     *         
- */ - public final Formula revPaperNoConflict(Expression req) { - final Variable conf = Variable.unary("conf"); - // req.s in conf.s - final Formula f0 = req.join(sRequest).in(conf.join(sConflicted)); - // req.r in conf.r - final Formula f1 = req.join(rRequest).in(conf.join(rConflicted)); - // (no conf : Conflicted | req.s in conf.s && req.r in conf.r) <=> - // all conf : Conflicted | !(req.s in conf.s && req.r in conf.r) - return (f0.and(f1)).not().forAll(conf.oneOf(Conflicted)); - } - - /** - * Returns the pol predicate - * - * @return - * - *
-     * pred pol (req: Request) {
-     *  RevPaperNoConflict(req)
-     * }
-     *         
- */ - public final Formula pol(Expression req) { - return revPaperNoConflict(req); - } - - /** - * Returns a formula that 'runs' the pol predicate. - * - * @return - * - *
-     * some req: Request | pol(req)
-     *         
- */ - public final Formula runPol() { - final Variable req = Variable.unary("req"); - return pol(req).forSome(req.oneOf(Request)); - } - - /** - * Returns the bounds for the given alloy scope. - * - * @return bounds for the given alloy scope - */ - public final Bounds bounds(int scope) { - assert scope > 0; - final List atoms = new ArrayList(4 * scope + 1); - // Subject, Resource, Action, Conflicted - for (int i = 0; i < scope; i++) - atoms.add("Subject" + i); - for (int i = 0; i < scope; i++) - atoms.add("Resource" + i); - for (int i = 0; i < scope; i++) - atoms.add("Action" + i); - for (int i = 0; i < scope; i++) - atoms.add("Conflicted" + i); - for (int i = 0; i < scope; i++) - atoms.add("Request" + i); - - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final int max = scope - 1; - - b.bound(Subject, f.range(f.tuple("Subject0"), f.tuple("Subject" + max))); - b.bound(Resource, f.range(f.tuple("Resource0"), f.tuple("Resource" + max))); - b.bound(Action, f.range(f.tuple("Action0"), f.tuple("Action" + max))); - b.bound(Conflicted, f.range(f.tuple("Conflicted0"), f.tuple("Conflicted" + max))); - b.bound(Request, f.range(f.tuple("Request0"), f.tuple("Request" + max))); - - // sRequest, rRequest, action, sConflicted, rConflicted; - b.bound(sRequest, b.upperBound(Request).product(b.upperBound(Subject))); - b.bound(rRequest, b.upperBound(Request).product(b.upperBound(Resource))); - b.bound(action, b.upperBound(Request).product(b.upperBound(Action))); - b.bound(sConflicted, b.upperBound(Conflicted).product(b.upperBound(Subject))); - b.bound(rConflicted, b.upperBound(Conflicted).product(b.upperBound(Resource))); - return b; - } - - private static void usage() { - System.out.println("java examples.DiffEq [scope]"); - System.exit(1); - } - - /** - * Usage: java examples.DiffEq [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final DiffEg model = new DiffEg(); - final Solver solver = new Solver(); - - final Formula f = model.runPol(); - final Bounds b = model.bounds(n); - - System.out.println(f); - - final Solution sol = solver.solve(f, b); - System.out.println(sol); - - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Dijkstra.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Dijkstra.class deleted file mode 100644 index 6495cba3a..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Dijkstra.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Dijkstra.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Dijkstra.java deleted file mode 100644 index 6c2ab76a6..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Dijkstra.java +++ /dev/null @@ -1,389 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Kodkod encoding of models/examples/algorithms/dijkstra.als. - * - * @author Emina Torlak - */ -public final class Dijkstra { - - private final Relation Process, Mutex, State, holds, waits; - private final Relation sfirst, slast, sord, mfirst, mlast, mord; - - /** - * Creates an instance of Dijkstra example. - */ - public Dijkstra() { - Process = Relation.unary("Process"); - Mutex = Relation.unary("Mutex"); - State = Relation.unary("State"); - holds = Relation.ternary("holds"); - waits = Relation.ternary("waits"); - sfirst = Relation.unary("sfirst"); - slast = Relation.unary("slast"); - sord = Relation.binary("sord"); - mfirst = Relation.unary("mfirst"); - mlast = Relation.unary("mlast"); - mord = Relation.binary("mord"); - } - - /** - * Returns the declaration constraints. - * - * @return - * - *
-     * sig Process {}
-     * sig Mutex {}
-     * sig State { holds, waits: Process -> Mutex }
-     *         
- */ - public Formula declarations() { - final Formula f1 = sord.totalOrder(State, sfirst, slast); - final Formula f2 = mord.totalOrder(Mutex, mfirst, mlast); - final Formula f3 = holds.in(State.product(Process).product(Mutex)); - final Formula f4 = waits.in(State.product(Process).product(Mutex)); - return Formula.and(f1, f2, f3, f4); - } - - /** - * Returns the initial predicate for state s. - * - * @return - * - *
-     * pred State.Initial () { no this.holds + this.waits }
-     *         
- */ - public Formula initial(Expression s) { - return s.join(holds).union(s.join(waits)).no(); - } - - /** - * Returns the free predicate for state s and mutex m. - * - * @return - * - *
-     * pred State.IsFree (m: Mutex) {
-     * // no process holds this mutex
-     * no m.~(this.holds)
-     * }
-     *         
- */ - public Formula isFree(Expression s, Expression m) { - return m.join((s.join(holds)).transpose()).no(); - } - - /** - * Returns the isStalled predicate for state s and process p. - * - * @return - * - *
-     * pred State.IsStalled (p: Process) { some p.(this.waits) }
-     *         
- */ - public Formula isStalled(Expression s, Expression p) { - return p.join(s.join(waits)).some(); - } - - /** - * Returns the GrabMutex predicate for states s1, s2, process p and mutex m. - * - * @return - * - *
-     * pred State.GrabMutex (p: Process, m: Mutex, s': State) {
-     *  // a process can only act if it is not
-     *  // waiting for a mutex
-     * !this::IsStalled(p)
-     * // can only grab a mutex we do not yet hold
-     * 	m !in p.(this.holds)
-     * this::IsFree (m) => {
-     *    // if the mutex is free, we now hold it,
-     *    // and do not become stalled
-     *    p.(s'.holds) = p.(this.holds) + m
-     *    no p.(s'.waits)
-     *  } else {
-     *   // if the mutex was not free,
-     *   // we still hold the same mutexes we held,
-     *   // and are now waiting on the mutex
-     *   // that we tried to grab.
-     *   p.(s'.holds) = p.(this.holds)
-     *   p.(s'.waits) = m
-     * }
-     * all otherProc: Process - p | {
-     *    otherProc.(s'.holds) = otherProc.(this.holds)
-     *    otherProc.(s'.waits) = otherProc.(this.waits)
-     * }
-     * }
-     *         
- */ - public Formula grabMutex(Expression s1, Expression s2, Expression p, Expression m) { - final Formula f1 = isStalled(s1, p).not().and(m.in(p.join(s1.join(holds))).not()); - final Formula isFree = isFree(s1, m); - final Formula f2 = p.join(s2.join(holds)).eq(p.join(s1.join(holds)).union(m)); - final Formula f3 = p.join(s2.join(waits)).no(); - final Formula f4 = isFree.implies(f2.and(f3)); - final Formula f5 = p.join(s2.join(holds)).eq(p.join(s1.join(holds))); - final Formula f6 = p.join(s2.join(waits)).eq(m); - final Formula f7 = isFree.not().implies(f5.and(f6)); - final Variable otherProc = Variable.unary("otherProc"); - final Formula f8 = otherProc.join(s2.join(holds)).eq(otherProc.join(s1.join(holds))); - final Formula f9 = otherProc.join(s2.join(waits)).eq(otherProc.join(s1.join(waits))); - final Formula f10 = f8.and(f9).forAll(otherProc.oneOf(Process.difference(p))); - return Formula.and(f1, f4, f7, f10); - } - - /** - * Returns the GrabMutex predicate for states s1, s2, process p and mutex m. - * - * @return - * - *
-     * pred State.ReleaseMutex (p: Process, m: Mutex, s': State) {
-     *   !this::IsStalled(p)
-     *   m in p.(this.holds)
-     *   p.(s'.holds) = p.(this.holds) - m
-     *   no p.(s'.waits)
-     *   no m.~(this.waits) => {
-     *       no m.~(s'.holds)
-     *       no m.~(s'.waits)
-     *    } else {
-     *       some lucky: m.~(this.waits) | {
-     *       m.~(s'.waits) = m.~(this.waits) - lucky
-     *     m.~(s'.holds) = lucky
-     *    }
-     *   }
-     *   all mu: Mutex - m {
-     *     mu.~(s'.waits) = mu.~(this.waits)
-     *     mu.~(s'.holds)= mu.~(this.holds)
-     *   }
-     * }
-     *         
- */ - public Formula releaseMutex(Expression s1, Expression s2, Expression p, Expression m) { - final Formula f1 = isStalled(s1, p).not().and(m.in(p.join(s1.join(holds)))); - final Formula f2 = p.join(s2.join(holds)).eq(p.join(s1.join(holds)).difference(m)); - final Formula f3 = p.join(s2.join(waits)).no(); - final Expression cexpr = m.join((s1.join(waits)).transpose()); - final Formula f4 = m.join(s2.join(holds).transpose()).no(); - final Formula f5 = m.join(s2.join(waits).transpose()).no(); - final Formula f6 = cexpr.no().implies(f4.and(f5)); - final Variable lucky = Variable.unary("lucky"); - final Formula f7 = m.join(s2.join(waits).transpose()).eq(m.join(s1.join(waits).transpose()).difference(lucky)); - final Formula f8 = m.join(s2.join(holds).transpose()).eq(lucky); - final Formula f9 = f7.and(f8).forSome(lucky.oneOf(m.join(s1.join(waits).transpose()))); - final Formula f10 = cexpr.some().implies(f9); - final Variable mu = Variable.unary("mu"); - final Formula f11 = mu.join(s2.join(waits).transpose()).eq(mu.join(s1.join(waits).transpose())); - final Formula f12 = mu.join(s2.join(holds).transpose()).eq(mu.join(s1.join(holds).transpose())); - final Formula f13 = f11.and(f12).forAll(mu.oneOf(Mutex.difference(m))); - return Formula.and(f1, f2, f3, f6, f10, f13); - } - - /** - * Returns the GrabOrRelease predicate. - * - * @return - * - *
-     * pred GrabOrRelease () {
-     *    Initial(so/first()) &&
-     *    (
-     *    all pre: State - so/last () | let post = so/next (pre) |
-     *       (post.holds = pre.holds && post.waits = pre.waits)
-     *        ||
-     *       (some p: Process, m: Mutex | pre::GrabMutex (p, m, post))
-     *        ||
-     *       (some p: Process, m: Mutex | pre::ReleaseMutex (p, m, post))
-     *
-     *    )
-     * }
-     *         
- */ - public Formula grabOrRelease() { - final Variable pre = Variable.unary("pre"); - final Expression post = pre.join(sord); - final Formula f1 = post.join(holds).eq(pre.join(holds)); - final Formula f2 = post.join(waits).eq(pre.join(waits)); - final Variable p = Variable.unary("p"); - final Variable m = Variable.unary("m"); - final Decls d = p.oneOf(Process).and(m.oneOf(Mutex)); - final Formula f3 = grabMutex(pre, post, p, m).forSome(d); - final Formula f4 = releaseMutex(pre, post, p, m).forSome(d); - return initial(sfirst).and(((f1.and(f2)).or(f3).or(f4)).forAll(pre.oneOf(State.difference(slast)))); - } - - /** - * Returns the Deadlock predicate. - * - * @return - * - *
-     *
-     * pred Deadlock () {
-     *  some s: State | all p: Process | some p.(s.waits)
-     * }
-     *         
- */ - public Formula deadlock() { - final Variable s = Variable.unary("s"); - final Variable p = Variable.unary("p"); - return p.join(s.join(waits)).some().forAll(p.oneOf(Process)).forSome(s.oneOf(State)); - } - - /** - * Returns the GrabbedInOrder predicate. - * - * @return - * - *
-     * pred GrabbedInOrder ( ) {
-     * all pre: State - so/last() |
-     *  let post = so/next(pre) |
-     *     let had = Process.(pre.holds), have = Process.(post.holds) |
-     *     let grabbed = have - had |
-     *        some grabbed => grabbed in mo/nexts(had)
-     * }
-     *         
- */ - public Formula grabbedInOrder() { - final Variable pre = Variable.unary("pre"); - final Expression post = pre.join(sord); - final Expression had = Process.join(pre.join(holds)); - final Expression have = Process.join(post.join(holds)); - final Expression grabbed = have.difference(had); - return grabbed.some().implies(grabbed.in(had.join(mord.closure()))).forAll(pre.oneOf(State.difference(slast))); - } - - /** - * Returns the DijkstraPreventsDeadlocks assertion. - * - * @return - * - *
-     *
-     * assert DijkstraPreventsDeadlocks {
-     *  some Process && GrabOrRelease() && GrabbedInOrder() => ! Deadlock()
-     * }
-     *         
- */ - public Formula checkDijkstraPreventsDeadlocks() { - return Formula.and(declarations(), Process.some(), grabOrRelease(), grabbedInOrder(), deadlock()); - } - - /** - * Returns the showDijkstra predicate. - * - * @return he showDijkstra predicate - */ - public Formula showDijkstra() { - return declarations().and(grabOrRelease()).and(deadlock()).and(waits.some()); - } - - /** - * Returns the bounds that allocate the given number of atoms to each type. - * - * @return bounds - */ - public Bounds bounds(int scope) { - return bounds(scope, scope, scope); - } - - /** - * Returns the bounds corresponding to the given scopes. - * - * @return bounds - */ - public Bounds bounds(int states, int processes, int mutexes) { - final List atoms = new ArrayList(states + processes + mutexes); - for (int i = 0; i < states; i++) { - atoms.add("State" + i); - } - for (int i = 0; i < processes; i++) { - atoms.add("Process" + i); - } - for (int i = 0; i < mutexes; i++) { - atoms.add("Mutex" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final TupleSet sb = f.range(f.tuple("State0"), f.tuple("State" + (states - 1))); - final TupleSet pb = f.range(f.tuple("Process0"), f.tuple("Process" + (processes - 1))); - final TupleSet mb = f.range(f.tuple("Mutex0"), f.tuple("Mutex" + (mutexes - 1))); - - b.bound(State, sb); - b.bound(holds, sb.product(pb).product(mb)); - b.bound(waits, sb.product(pb).product(mb)); - - b.bound(sfirst, sb); - b.bound(slast, sb); - b.bound(sord, sb.product(sb)); - - b.bound(Process, pb); - - b.bound(Mutex, mb); - b.bound(mfirst, mb); - b.bound(mlast, mb); - b.bound(mord, mb.product(mb)); - - return b; - } - - private static void usage() { - System.out.println("Usage: java examples.Dijkstra [# states] [# processes] [# mutexes]"); - System.exit(1); - } - - /** - * Usage: java examples.Dijkstra [# states] [# processes] [# mutexes] - */ - public static void main(String[] args) { - if (args.length < 3) - usage(); - - final Dijkstra model = new Dijkstra(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - try { - final Formula noDeadlocks = model.checkDijkstraPreventsDeadlocks(); - final int states = Integer.parseInt(args[0]); - final int processes = Integer.parseInt(args[1]); - final int mutexes = Integer.parseInt(args[2]); - final Bounds bounds = model.bounds(states, processes, mutexes); - System.out.println("*****check DijkstraPreventsDeadlocks for " + states + " State, " + processes + " Process, " + mutexes + " Mutex*****"); - - System.out.println(noDeadlocks); - // System.out.println(bounds); - Solution sol1 = solver.solve(noDeadlocks, bounds); - System.out.println(sol1); - // System.out.println(solver.solve(model.grabOrRelease().and(model.declarations()). - // and(model.waits.some()).and(model.deadlock()), bounds)); - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/FileSystem.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/FileSystem.class deleted file mode 100644 index 2ebbde92c..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/FileSystem.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/FileSystem.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/FileSystem.java deleted file mode 100644 index d5285d746..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/FileSystem.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * - */ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of file_system.als - * - * @author Emina Torlak - */ -public final class FileSystem { - - private final Relation Obj, Name, File, Dir, Root, Cur, DirEntry; - private final Relation entries, parent, name, contents; - - /** - * Constructs a new instance of the file system problem. - */ - public FileSystem() { - Obj = Relation.unary("Object"); - Name = Relation.unary("Name"); - File = Relation.unary("File"); - Dir = Relation.unary("Dir"); - Root = Relation.unary("Root"); - Cur = Relation.unary("Cur"); - DirEntry = Relation.unary("DirEntry"); - entries = Relation.binary("entries"); - parent = Relation.binary("parent"); - name = Relation.binary("name"); - contents = Relation.binary("contents"); - } - - /** - * Returns the declaration constraints. - * - * @return declaration constraints - */ - public final Formula decls() { - // File and Dir partition object - final Formula f0 = Obj.eq(File.union(Dir)).and(File.intersection(Dir).no()); - // Root and Cur are in Dir and do not intersect - final Formula f1 = Root.in(Dir).and(Cur.in(Dir)).and(Root.intersection(Cur).no()); - // don't need to specify that Dir, Name, and DirEntry are disjoint; - // implied by bounds - final Formula f2 = entries.in(Dir.product(DirEntry)); - final Formula f3 = parent.partialFunction(Dir, Dir); - final Formula f4 = name.function(DirEntry, Name); - final Formula f5 = contents.function(DirEntry, Obj); - return f0.and(f1).and(f2).and(f3).and(f4).and(f5); - } - - /** - * Returns all facts in the model. - * - * @return the facts. - */ - public final Formula facts() { - // sig File extends Object {} { some d: Dir | this in d.entries.contents - // } - final Variable file = Variable.unary("this"); - final Variable d = Variable.unary("d"); - final Formula f0 = file.in(d.join(entries).join(contents)).forSome(d.oneOf(Dir)).forAll(file.oneOf(File)); - - // sig Dir extends Object { - // entries: set DirEntry, - // parent: lone Dir - // } { - // parent = this.~@contents.~@entries - // all e1, e2 : entries | e1.name = e2.name => e1 = e2 - // this !in this.^@parent - // this != Root => Root in this.^@parent - // } - - final Variable dir = Variable.unary("this"); - final Variable e1 = Variable.unary("e1"), e2 = Variable.unary("e2"); - - final Formula f1 = (dir.join(parent)).eq(dir.join(contents.transpose()).join(entries.transpose())); - final Expression e0 = dir.join(entries); - final Formula f2 = e1.join(name).eq(e2.join(name)).implies(e1.eq(e2)).forAll(e1.oneOf(e0).and(e2.oneOf(e0))); - final Formula f3 = dir.in(dir.join(parent.closure())).not(); - final Formula f4 = dir.eq(Root).not().implies(Root.in(dir.join(parent.closure()))); - final Formula f5 = f1.and(f2).and(f3).and(f4).forAll(dir.oneOf(Dir)); - - // one sig Root extends Dir {} { no parent } - final Formula f6 = Root.join(parent).no(); - - // sig DirEntry { - // name: Name, - // contents: Object - // } { one this.~entries } - - final Variable entry = Variable.unary("this"); - final Formula f7 = entry.join(entries.transpose()).one().forAll(entry.oneOf(DirEntry)); - - // fact OneParent { - // // all directories besides root xhave one parent - // all d: Dir - Root | one d.parent - // } - - final Formula f8 = d.join(parent).one().forAll(d.oneOf(Dir.difference(Root))); - - return f0.and(f5).and(f6).and(f7).and(f8); - } - - /** - * Returns the no aliases assertion. - * - * @return the no aliases assertion. - */ - public final Formula noDirAliases() { - // all o: Dir | lone o.~contents - final Variable o = Variable.unary("o"); - return o.join(contents.transpose()).lone().forAll(o.oneOf(Dir)); - } - - /** - * Returns the formula that 'checks' the noDirAliases assertion. - * - * @return decls() and facts() and noDirAliases().not() - */ - public final Formula checkNoDirAliases() { - return decls().and(facts()).and(noDirAliases().not()); - } - - /** - * Returns the bounds for the given scope. - * - * @return the bounds for the given scope. - */ - public final Bounds bounds(int scope) { - assert scope > 0; - final int n = scope * 3; - final List atoms = new ArrayList(n); - for (int i = 0; i < scope; i++) - atoms.add("Object" + i); - for (int i = 0; i < scope; i++) - atoms.add("Name" + i); - for (int i = 0; i < scope; i++) - atoms.add("DirEntry" + i); - - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final int max = scope - 1; - - b.bound(Obj, f.range(f.tuple("Object0"), f.tuple("Object" + max))); - b.boundExactly(Root, f.setOf("Object0")); - b.bound(Cur, b.upperBound(Obj)); - b.bound(File, b.upperBound(Obj)); - b.bound(Dir, b.upperBound(Obj)); - b.bound(Name, f.range(f.tuple("Name0"), f.tuple("Name" + max))); - b.bound(DirEntry, f.range(f.tuple("DirEntry0"), f.tuple("DirEntry" + max))); - - b.bound(entries, b.upperBound(Dir).product(b.upperBound(DirEntry))); - b.bound(parent, b.upperBound(Dir).product(b.upperBound(Dir))); - b.bound(name, b.upperBound(DirEntry).product(b.upperBound(Name))); - b.bound(contents, b.upperBound(DirEntry).product(b.upperBound(Obj))); - - return b; - } - - private static void usage() { - System.out.println("java examples.FileSystem [scope]"); - System.exit(1); - } - - /** - * Usage: java examples.alloy.FileSystem [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - try { - final int n = Integer.parseInt(args[0]); - final FileSystem model = new FileSystem(); - final Formula f = model.checkNoDirAliases(); - System.out.println(f); - final Bounds b = model.bounds(n); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final Solution s = solver.solve(f, b); - System.out.println(s); - - } catch (NumberFormatException nfe) { - usage(); - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Handshake.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Handshake.class deleted file mode 100644 index 2235841bf..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Handshake.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Handshake.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Handshake.java deleted file mode 100644 index e63d4b881..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Handshake.java +++ /dev/null @@ -1,196 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.ConsoleReporter; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * KodKod encoding of shakehands.als. - * - * @author Emina Torlak - */ -public final class Handshake { - - private final Relation Person, Hilary, Jocelyn, shaken, spouse; - - public Handshake() { - Person = Relation.unary("Person"); - Hilary = Relation.unary("Hilary"); - Jocelyn = Relation.unary("Jocelyn"); - shaken = Relation.binary("shaken"); - spouse = Relation.binary("spouse"); - } - - /** - * Returns the declarations - * - * @return - * - *
-     * sig Person {spouse: Person, shaken: set Person}
-     * one sig Jocelyn, Hilary extends Person {}
-     *         
- */ - public Formula declarations() { - final Formula f0 = spouse.function(Person, Person); - final Formula f1 = shaken.in(Person.product(Person)); - final Formula f2 = Hilary.one().and(Jocelyn.one()); - return f0.and(f1).and(f2); - } - - /** - * Returns the ShakingProtocol fact. - * - * @return - * - *
-     * fact ShakingProtocol {
-     *  // nobody shakes own or spouse's hand
-     *  all p: Person | no (p + p.spouse) & p.shaken
-     *  // if p shakes q, q shakes p
-     *  all p, q: Person | p in q.shaken => q in p.shaken
-     * }
-     *         
- */ - public Formula shakingProtocol() { - final Variable p = Variable.unary("p"); - final Variable q = Variable.unary("q"); - final Formula f1 = p.union(p.join(spouse)).intersection(p.join(shaken)).no().forAll(p.oneOf(Person)); - final Formula f2 = p.in(q.join(shaken)).implies(q.in(p.join(shaken))).forAll(p.oneOf(Person).and(q.oneOf(Person))); - return f1.and(f2); - } - - /** - * Returns the Spouses fact. - * - * @return - * - *
-     * fact Spouses {
-     *  all disj p, q: Person {
-     *   // if q is p's spouse, p is q's spouse
-     *   p.spouse = q => q.spouse = p
-     *   // no spouse sharing
-     *	 p.spouse != q.spouse
-     *  }
-     *  all p: Person {
-     * 	 // a person is his or her spouse's spouse
-     *	 p.spouse.spouse = p
-     *	 // nobody is his or her own spouse
-     *	 p != p.spouse
-     *	}
-     * }
-     *         
- */ - public Formula spouses() { - final Variable p = Variable.unary("p"); - final Variable q = Variable.unary("q"); - final Formula f1 = p.join(spouse).eq(q).implies(q.join(spouse).eq(p)); - final Formula f2 = p.join(spouse).eq(q.join(spouse)).not(); - final Formula f3 = p.intersection(q).no().implies(f1.and(f2)).forAll(p.oneOf(Person).and(q.oneOf(Person))); - final Formula f4 = p.join(spouse).join(spouse).eq(p).and(p.eq(p.join(spouse)).not()).forAll(p.oneOf(Person)); - return f3.and(f4); - } - - /** - * Returns the Puzzle predicate - * - * @return - * - *
-     * pred Puzzle() {
-     *  // everyone but Jocelyn has shaken a different number of hands
-     *  all disj p,q: Person - Jocelyn | #p.shaken != #q.shaken
-     *  // Hilary's spouse is Jocelyn
-     *  Hilary.spouse = Jocelyn
-     * }
-     *         
- */ - public Formula puzzle() { - final Variable p = Variable.unary("p"); - final Variable q = Variable.unary("q"); - final Formula f = p.eq(q).not().implies(p.join(shaken).count().eq(q.join(shaken).count()).not()); - final Expression e = Person.difference(Jocelyn); - return f.forAll(p.oneOf(e).and(q.oneOf(e))).and(Hilary.join(spouse).eq(Jocelyn)); - } - - /** - * Returns the conjunction of the facts and the puzzle predicate. - * - * @return declarations().and(shakingProtocol()).and(spouses()).and(puzzle()) - */ - public Formula runPuzzle() { - return declarations().and(shakingProtocol()).and(spouses()).and(puzzle()); - } - - /** - * Returns a bounds for the given number of persons. - * - * @return a bounds for the given number of persons. - */ - public Bounds bounds(int persons) { - final List atoms = new ArrayList(persons); - atoms.add("Hilary"); - atoms.add("Jocelyn"); - for (int i = 2; i < persons; i++) { - atoms.add("Person" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - b.boundExactly(Person, f.allOf(1)); - b.boundExactly(Hilary, f.setOf("Hilary")); - b.boundExactly(Jocelyn, f.setOf("Jocelyn")); - b.bound(spouse, f.allOf(2)); - b.bound(shaken, f.allOf(2)); - return b; - } - - private static void usage() { - System.out.println("Usage: java examples.Handshake [# persons, must be >= 2]"); - System.exit(1); - } - - /** - * Usage: java examples.Handshake [# persons, must be >= 2] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - final Handshake model = new Handshake(); - final Solver solver = new Solver(); - try { - final int persons = Integer.parseInt(args[0]); - if (persons < 2) - usage(); - solver.options().setBitwidth(6); - - // solver.options().setSolver(SATFactory.ZChaff); - solver.options().setSolver(SATFactory.MiniSat); - - solver.options().setSymmetryBreaking(0); - solver.options().setBitwidth(32 - Integer.numberOfLeadingZeros(persons)); - solver.options().setReporter(new ConsoleReporter()); - final Bounds b = model.bounds(persons); - final Formula f = model.runPuzzle();// .and(model.Person.count().eq(IntConstant.constant(persons))); - Solution sol = solver.solve(f, b); - System.out.println(sol); - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Hotel.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Hotel.class deleted file mode 100644 index bf780e19f..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Hotel.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Hotel.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Hotel.java deleted file mode 100644 index ed369e316..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Hotel.java +++ /dev/null @@ -1,683 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package examples.alloy; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Proof; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.engine.ucore.RCEStrategy; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; -import kodkod.util.nodes.Nodes; -import kodkod.util.nodes.PrettyPrinter; - -/** - * Encodes the hotel example. - * - * @author Emina Torlak - */ -public final class Hotel { - - private final Relation Time, Event, first, last; - private final Relation pre, post, next; - - private final Relation Key, Card, Room, Guest, HotelEvent, RoomCardEvent, Checkin, Enter, NormalEnter, RecodeEnter, - Checkout; - - private final Relation guest, room, card, k1, k2; - private final Relation key, prev, occ, holds; - - /** - * Constructs a new instance of the hotel problem. - */ - public Hotel() { - this.Time = Relation.unary("Time"); - this.Event = Relation.unary("Event"); - this.first = Relation.unary("first"); - this.last = Relation.unary("last"); - this.pre = Relation.binary("pre"); - this.post = Relation.binary("post"); - this.next = Relation.binary("next"); - - this.Key = Relation.unary("Key"); - this.Card = Relation.unary("Card"); - this.Guest = Relation.unary("Guest"); - this.Room = Relation.unary("Room"); - this.HotelEvent = Relation.unary("HotelEvent"); - this.RoomCardEvent = Relation.unary("RoomCardEvent"); - this.Checkin = Relation.unary("Checkin"); - this.Enter = Relation.unary("Enter"); - this.NormalEnter = Relation.unary("NormalEnter"); - this.RecodeEnter = Relation.unary("RecodeEnter"); - this.Checkout = Relation.unary("Checkout"); - - this.key = Relation.ternary("key"); - this.prev = Relation.ternary("prev"); - this.occ = Relation.ternary("occ"); - this.holds = Relation.ternary("holds"); - - this.guest = Relation.binary("guest"); - this.room = Relation.binary("room"); - this.card = Relation.binary("card"); - this.k1 = Relation.binary("k1"); - this.k2 = Relation.binary("k2"); - } - - /** - * Returns the invariants for the Time and Event signatures and their fields. - * - * @return invariants for the Time and Event signatures and their fields. - */ - public Formula timeEventInvariants() { - final List invs = new ArrayList(); - - invs.add(next.totalOrder(Time, first, last)); - invs.add(pre.function(Event, Time)); - invs.add(post.function(Event, Time)); - - final Variable t = Variable.unary("t"); - final Variable e = Variable.unary("e"); - - // all t: Time - last | one e: Event | e.pre = t and e.post = t.next - final Formula f0 = e.join(pre).eq(t).and(e.join(post).eq(t.join(next))); - final Formula f1 = f0.comprehension(e.oneOf(Event)).one(); - invs.add(f1.forAll(t.oneOf(Time.difference(last)))); - - return Formula.and(invs); - } - - /** - * Returns the "unchanged" predicate for the given event expression and field. - * - * @return "unchanged" predicate for the given event expression and field. - */ - public Formula unchanged(Expression e, Expression field) { - // field.(this.pre) = field.(this.post) - return field.join(e.join(pre)).eq(field.join(e.join(post))); - } - - /** - * Returns the "modifes" predicate for the given event expression and field. - * - * @return "modifies" predicate for the given event expression and field. - */ - public Formula modifies(Expression es, Expression field) { - // all e: Event -es | field.(e.pre) = field.(e.post) - final Variable e = Variable.unary("e"); - return field.join(e.join(pre)).eq(field.join(e.join(post))).forAll(e.oneOf(Event.difference(es))); - } - - /** - * Returns the invariants for Card and its fields. - * - * @return invariants for Card and its fields. - */ - public Formula cardInvariants() { - return k1.function(Card, Key).and(k2.function(Card, Key)); - } - - /** - * Returns the invariants for Room and its fields. - * - * @return invariants for Room and its fields. - */ - public Formula roomInvariants() { - // key: Key one -> Time, - // prev: Key lone -> Time, - // occ: Guest -> Time - - final List invs = new ArrayList(); - - invs.add(key.in(Room.product(Key).product(Time))); - invs.add(prev.in(Room.product(Key).product(Time))); - invs.add(occ.in(Room.product(Guest).product(Time))); - - final Variable r = Variable.unary("r"); - final Variable t = Variable.unary("t"); - - // all r: Room, t: Time | one r.key.t - invs.add(r.join(key).join(t).one().forAll(r.oneOf(Room).and(t.oneOf(Time)))); - - // all r: Room, t: Time | lone r.prev.t - invs.add(r.join(prev).join(t).lone().forAll(r.oneOf(Room).and(t.oneOf(Time)))); - - return Formula.and(invs); - } - - /** - * Returns the invariants for Guest and its fields. - * - * @return invariants for Guest and its fields. - */ - public Formula guestInvariants() { - // holds: Card -> Time - return holds.in(Guest.product(Card).product(Time)); - } - - /** - * Returns the invariants for HotelEvent and its fields. - * - * @return invariants for HotelEvent and its fields. - */ - public Formula hotelEventInvariants() { - // abstract sig HotelEvent extends Event { - // guest: Guest - // } - final List invs = new ArrayList(); - invs.add(HotelEvent.eq(Event)); - invs.add(HotelEvent.eq(RoomCardEvent.union(Checkout))); - invs.add(RoomCardEvent.intersection(Checkout).no()); - invs.add(guest.function(HotelEvent, Guest)); - - return Formula.and(invs); - } - - /** - * Returns the invariants for RoomCardEvent and its fields. - * - * @return invariants for RoomCardEvent and its fields. - */ - public Formula roomCardInvariants() { - // abstract sig RoomCardEvent extends HotelEvent { - // room: Room, - // card: Card - // } - final List invs = new ArrayList(); - invs.add(RoomCardEvent.in(HotelEvent)); - invs.add(RoomCardEvent.eq(Checkin.union(Enter))); - invs.add(Checkin.intersection(Enter).no()); - - invs.add(room.function(RoomCardEvent, Room)); - invs.add(card.function(RoomCardEvent, Card)); - - return Formula.and(invs); - } - - /** @return e.room */ - Expression room(Expression e) { - return e.join(room); - } - - /** @return e.card */ - Expression card(Expression e) { - return e.join(card); - } - - /** @return e.pre */ - Expression pre(Expression e) { - return e.join(pre); - } - - /** @return e.post */ - Expression post(Expression e) { - return e.join(post); - } - - /** @return e.guest */ - Expression guest(Expression e) { - return e.join(guest); - } - - /** - * Returns the invariants for Checkin and its fields. - * - * @return invariants for Checkin and its fields. - */ - public Formula invsForCheckin() { - // sig Checkin extends RoomCardEvent { } - // { - // no room.occ.pre - // card.k1 = room.prev.pre - // holds.post = holds.pre + guest -> card - // prev.post = prev.pre ++ room -> card.k2 - // occ.post = occ.pre + room -> guest - // - // key.unchanged - // } - - final List invs = new ArrayList(); - - invs.add(Checkin.in(RoomCardEvent)); - - final Variable c = Variable.unary("c"); - - // no room.occ.pre - invs.add(room(c).join(occ).join(pre(c)).no().forAll(c.oneOf(Checkin))); - - // card.k1 = room.prev.pre - invs.add(card(c).join(k1).eq(room(c).join(prev).join(pre(c))).forAll(c.oneOf(Checkin))); - - // holds.post = holds.pre + guest -> card - invs.add(holds.join(post(c)).eq(holds.join(pre(c)).union(guest(c).product(card(c)))).forAll(c.oneOf(Checkin))); - - // prev.post = prev.pre ++ room -> card.k2 - invs.add(prev.join(post(c)).eq(prev.join(pre(c)).override(room(c).product(card(c).join(k2)))).forAll(c.oneOf(Checkin))); - - // occ.post = occ.pre + room -> guest - invs.add(occ.join(post(c)).eq(occ.join(pre(c)).union(room(c).product(guest(c)))).forAll(c.oneOf(Checkin))); - - invs.add(unchanged(c, key).forAll(c.oneOf(Checkin))); - return Formula.and(invs); - } - - /** - * Returns the invariants for Enter and its fields. - * - * @return invariants for Enter and its fields. - */ - public Formula enterInvariants() { - // abstract sig Enter extends RoomCardEvent { } - // { - // card in guest.holds.pre - // } - - final List invs = new ArrayList(); - invs.add(Enter.in(RoomCardEvent)); - invs.add(Enter.eq(NormalEnter.union(RecodeEnter))); - invs.add(NormalEnter.intersection(RecodeEnter).no()); - - final Variable e = Variable.unary("e"); - invs.add(card(e).in(guest(e).join(holds).join(pre(e))).forAll(e.oneOf(Enter))); - - return Formula.and(invs); - } - - /** - * Returns the invariants for NormalEnter and its fields. - * - * @return invariants for NormalEnter and its fields. - */ - public Formula normalEnterInvariants() { - // sig NormalEnter extends Enter { } - // { - // card.k2 = room.key.pre - // - // prev.unchanged - // holds.unchanged - // occ.unchanged - // key.unchanged - // } - - final List invs = new ArrayList(); - invs.add(NormalEnter.in(Enter)); - - final Variable n = Variable.unary("n"); - invs.add(card(n).join(k2).eq(room(n).join(key).join(pre(n))).forAll(n.oneOf(NormalEnter))); - invs.add(unchanged(n, prev).forAll(n.oneOf(NormalEnter))); - invs.add(unchanged(n, holds).forAll(n.oneOf(NormalEnter))); - invs.add(unchanged(n, occ).forAll(n.oneOf(NormalEnter))); - invs.add(unchanged(n, key).forAll(n.oneOf(NormalEnter))); - - return Formula.and(invs); - } - - /** - * Returns the invariants for RecodeEnter and its fields. - * - * @return invariants for RecodeEnter and its fields. - */ - public Formula recodeEnterInvariants() { - // sig RecodeEnter extends Enter { } - // { - // card.k1 = room.key.pre - // key.post = key.pre ++ room -> card.k2 - // - // prev.unchanged - // holds.unchanged - // occ.unchanged - // } - - final List invs = new ArrayList(); - invs.add(RecodeEnter.in(Enter)); - - final Variable r = Variable.unary("n"); - invs.add(card(r).join(k1).eq(room(r).join(key).join(pre(r))).forAll(r.oneOf(RecodeEnter))); - invs.add(key.join(post(r)).eq(key.join(pre(r)).override(room(r).product(card(r).join(k2)))).forAll(r.oneOf(RecodeEnter))); - - invs.add(unchanged(r, prev).forAll(r.oneOf(RecodeEnter))); - invs.add(unchanged(r, holds).forAll(r.oneOf(RecodeEnter))); - invs.add(unchanged(r, occ).forAll(r.oneOf(RecodeEnter))); - - return Formula.and(invs); - } - - /** - * Returns the invariants for Checkout and its fields. - * - * @return invariants for Checkout and its fields. - */ - public Formula invsForCheckout() { - // sig Checkout extends HotelEvent { } - // { - // some occ.pre.guest - // - // -- DNJ: can comment these out and still unsat - // occ.post = occ.pre - Room -> guest - // prev.unchanged - // holds.unchanged - // key.unchanged - // } - - final List invs = new ArrayList(); - invs.add(Checkout.in(HotelEvent)); - - final Variable c = Variable.unary("n"); - invs.add(occ.join(pre(c)).join(guest(c)).some().forAll(c.oneOf(Checkout))); - invs.add(occ.join(post(c)).eq(occ.join(pre(c)).difference(Room.product(guest(c)))).forAll(c.oneOf(Checkout))); - - invs.add(unchanged(c, prev).forAll(c.oneOf(Checkout))); - invs.add(unchanged(c, holds).forAll(c.oneOf(Checkout))); - invs.add(unchanged(c, key).forAll(c.oneOf(Checkout))); - - return Formula.and(invs); - } - - /** - * Returns FreshIssue fact. - * - * @return FressIssue fact. - */ - public Formula freshIssue() { - // -- don't issue same key twice - // all disj e1, e2: Checkin | e1.card.k2 != e2.card.k2 - // -- don't issue key initially installed in lock - // all e: Checkin | e.card.k2 !in Room.key.first - - final List invs = new ArrayList(); - - final Variable e1 = Variable.unary("e1"); - final Variable e2 = Variable.unary("e2"); - final Variable e = Variable.unary("e"); - - invs.add(e1.eq(e2).not().implies(e1.join(card).join(k2).eq(e2.join(card).join(k2)).not()).forAll(e1.oneOf(Checkin).and(e2.oneOf(Checkin)))); - invs.add(e.join(card).join(k2).in(Room.join(key).join(first)).not().forAll(e.oneOf(Checkin))); - - return Formula.and(invs); - - } - - /** - * Returns init fact. - * - * @return init fact. - */ - public Formula initInvariant() { - // pred init (t: Time) { - // prev.t = key.t - // key.t in Room lone -> Key - // no holds.t and no occ.t - // } - // fact {first.init} - - final List invs = new ArrayList(); - - invs.add(prev.join(first).eq(key.join(first))); - invs.add(key.join(first).in(Room.product(Key))); - final Variable k = Variable.unary("k"); - invs.add(key.join(first).join(k).lone().forAll(k.oneOf(Key))); - invs.add(holds.join(first).no()); - invs.add(occ.join(first).no()); - - return Formula.and(invs); - } - - /** - * Returns the noIntervening fact. - * - * @return noIntervening fact. - */ - public Formula noIntervening() { - // fact NoIntervening { - // all c: Checkin - pre.last | - // some e: Enter | e.pre = c.post and e.room = c.room and e.guest = - // c.guest - // } - final Variable c = Variable.unary("c"); - final Variable e = Variable.unary("e"); - final Formula f = e.join(pre).eq(c.join(post)).and(e.join(room).eq(c.join(room))).and(e.join(guest).eq(c.join(guest))); - return f.forSome(e.oneOf(Enter)).forAll(c.oneOf(Checkin.difference(pre.join(last)))); - } - - /** - * Returns NoBadEntry formula. - * - * @return NoBadEntry formula. - */ - public Formula noBadEntry() { - // all e: Enter | let occs = occ.(e.pre) [e.room] | - // some occs => e.guest in occs - - final Variable e = Variable.unary("e"); - final Expression occs = e.join(room).join(occ.join(e.join(pre))); - - return occs.some().implies(e.join(guest).in(occs)).forAll(e.oneOf(Enter)); - } - - /** - * Returns the conjunction of all invariants. - * - * @return conjunction of all invariants. - */ - public Formula invariants() { - final List invs = new ArrayList(); - - invs.add(timeEventInvariants()); - - invs.add(cardInvariants()); - invs.add(roomInvariants()); - invs.add(guestInvariants()); - - invs.add(initInvariant()); - - invs.add(hotelEventInvariants()); - - invs.add(roomCardInvariants()); - invs.add(invsForCheckin()); - - invs.add(enterInvariants()); - invs.add(normalEnterInvariants()); - invs.add(recodeEnterInvariants()); - - invs.add(invsForCheckout()); - - invs.add(freshIssue()); - - invs.add(noIntervening()); - return Formula.and(invs); - } - - /** - * Returns the assertion "check noBadEntry" - * - * @return invariants() && !oBadEntry() - */ - public Formula checkNoBadEntry() { - return invariants().and(noBadEntry().not()); - } - - /** - * Returns bounds for the given number of times, events, rooms, cards, keys and - * guests. - * - * @return bounds for the given scopes. - */ - public Bounds bounds(int t, int e, int r, int c, int k, int g) { - final Relation[] tops = { - Time, Event, Room, Card, Key, Guest - }; - final int[] scopes = { - t, e, r, c, k, g - }; - - final List atoms = new ArrayList(); - for (int i = 0; i < tops.length; i++) { - Relation top = tops[i]; - for (int j = 0, scope = scopes[i]; j < scope; j++) - atoms.add(top.name() + j); - } - - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - for (int i = 0; i < tops.length; i++) { - Relation top = tops[i]; - b.bound(top, f.range(f.tuple(top.name() + 0), f.tuple(top.name() + (scopes[i] - 1)))); - } - - b.bound(first, b.upperBound(Time)); - b.bound(last, b.upperBound(Time)); - b.bound(next, b.upperBound(Time).product(b.upperBound(Time))); - - b.bound(pre, b.upperBound(Event).product(b.upperBound(Time))); - b.bound(post, b.upperBound(Event).product(b.upperBound(Time))); - - b.bound(HotelEvent, b.upperBound(Event)); - b.bound(RoomCardEvent, b.upperBound(Event)); - b.bound(Enter, b.upperBound(Event)); - b.bound(NormalEnter, b.upperBound(Event)); - b.bound(RecodeEnter, b.upperBound(Event)); - b.bound(Checkin, b.upperBound(Event)); - b.bound(Checkout, b.upperBound(Event)); - - b.bound(k1, b.upperBound(Card).product(b.upperBound(Key))); - b.bound(k2, b.upperBound(Card).product(b.upperBound(Key))); - - b.bound(key, b.upperBound(Room).product(b.upperBound(Key)).product(b.upperBound(Time))); - b.bound(prev, b.upperBound(Room).product(b.upperBound(Key)).product(b.upperBound(Time))); - b.bound(occ, b.upperBound(Room).product(b.upperBound(Guest)).product(b.upperBound(Time))); - - b.bound(holds, b.upperBound(Guest).product(b.upperBound(Card)).product(b.upperBound(Time))); - - b.bound(guest, b.upperBound(HotelEvent).product(b.upperBound(Guest))); - - b.bound(room, b.upperBound(RoomCardEvent).product(b.upperBound(Room))); - b.bound(card, b.upperBound(RoomCardEvent).product(b.upperBound(Card))); - - return b; - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public Bounds bounds(int n) { - return bounds(n, n, n, n, n, n); - } - - private static void usage() { - System.out.println("java examples.Hotel [scope]"); - System.exit(1); - } - - private static void checkMinimal(Set core, Bounds bounds) { - System.out.print("checking minimality ... "); - final long start = System.currentTimeMillis(); - final Set minCore = new LinkedHashSet(core); - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - for (Iterator itr = minCore.iterator(); itr.hasNext();) { - Formula f = itr.next(); - Formula noF = Formula.TRUE; - for (Formula f1 : minCore) { - if (f != f1) - noF = noF.and(f1); - } - if (solver.solve(noF, bounds).instance() == null) { - itr.remove(); - } - } - final long end = System.currentTimeMillis(); - if (minCore.size() == core.size()) { - System.out.println("minimal (" + (end - start) + " ms)."); - } else { - System.out.println("not minimal (" + (end - start) + " ms). The minimal core has these " + minCore.size() + " formulas:"); - for (Formula f : minCore) { - System.out.println(" " + f); - } - // Solution sol = problem.solver.solve(Formula.and(minCore), - // problem.bounds); - // System.out.println(sol); - // sol.proof().highLevelCore(); - } - } - - /** - * Usage: java examples.Hotel [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final Hotel model = new Hotel(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setLogTranslation(1); - - final Formula f = model.checkNoBadEntry(); - final Bounds b = model.bounds(n); - - // System.out.println(PrettyPrinter.print(f, 2, 100)); - - final Solution sol = solver.solve(f, b); - System.out.println(sol); - - if (sol.instance() == null) { - final Proof proof = sol.proof(); - System.out.println("top-level formulas: " + proof.log().roots().size()); - System.out.println("initial core: " + proof.highLevelCore().size()); - System.out.print("\nminimizing core ... "); - final long start = System.currentTimeMillis(); - proof.minimize(new RCEStrategy(proof.log())); - final Set core = Nodes.minRoots(f, proof.highLevelCore().values()); - final long end = System.currentTimeMillis(); - System.out.println("done (" + (end - start) + " ms)."); - System.out.println("minimal core: " + core.size()); - for (Formula u : core) { - System.out.println(PrettyPrinter.print(u, 2, 100)); - } - checkMinimal(core, b); - } else { - System.out.println(sol); - } - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Lists.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Lists.class deleted file mode 100644 index f1c1948c7..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Lists.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Lists.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Lists.java deleted file mode 100644 index 22f270867..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Lists.java +++ /dev/null @@ -1,295 +0,0 @@ -/** - * - */ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of lists.als - * - * @author Emina Torlak - */ -public final class Lists { - - /* - * KK outperformed by the sequential analysis tool on the reflexive and - * symmetric assertions - */ - private final Relation Thing, List, NonEmptyList, EmptyList; - private final Relation car, cdr, equivTo, prefixes; - - /** - * Constructs a new isntance of the Lists model. - */ - public Lists() { - Thing = Relation.unary("Thing"); - List = Relation.unary("List"); - NonEmptyList = Relation.unary("NonEmptyList"); - EmptyList = Relation.unary("EmptyList"); - car = Relation.binary("car"); - cdr = Relation.binary("cdr"); - equivTo = Relation.binary("equivTo"); - prefixes = Relation.binary("prefixes"); - } - - /** - * Returns the declaration constraints. - * - * @return declaration constraints - */ - public final Formula decls() { - // abstract sig List { - // equivTo: set List, - // prefixes: set List - // } - // sig NonEmptyList extends List { - // car: one Thing, - // cdr: one List - // } - // sig EmptyList extends List {} - final Formula f0 = List.eq(EmptyList.union(NonEmptyList)); - final Formula f1 = EmptyList.intersection(NonEmptyList).no(); - final Formula f2 = equivTo.in(List.product(List)); - final Formula f3 = prefixes.in(List.product(List)); - final Formula f4 = car.function(NonEmptyList, Thing); - final Formula f5 = cdr.function(NonEmptyList, List); - return f0.and(f1).and(f2).and(f3).and(f4).and(f5); - } - - /** - * Returns all facts in the model. - * - * @return the facts. - */ - public final Formula facts() { - // fact NoStrayThings {Thing in List.car} - final Formula f0 = Thing.in(List.join(car)); - // fact finite {all L: List | isFinite(L)} - final Variable L = Variable.unary("L"); - final Formula f1 = isFinite(L).forAll(L.oneOf(List)); - // fact Equivalence { - // all a,b: List | (a in b.equivTo) <=> (a.car = b.car and b.cdr in - // a.cdr.equivTo) - // } - final Variable a = Variable.unary("a"); - final Variable b = Variable.unary("b"); - final Formula f2 = a.in(b.join(equivTo)); - final Formula f3 = a.join(car).eq(b.join(car)); - final Formula f4 = b.join(cdr).in(a.join(cdr).join(equivTo)); - final Formula f6 = f2.iff(f3.and(f4)).forAll(a.oneOf(List).and(b.oneOf(List))); - // fact prefix { //a is a prefix of b - // List->EmptyList in prefixes - // all a,b: NonEmptyList | (a in b.prefixes) <=> (a.car = b.car - // and a.cdr in b.cdr.prefixes) - // } - final Formula f7 = List.product(EmptyList).in(prefixes); - final Formula f8 = a.in(b.join(prefixes)); - final Formula f9 = a.join(cdr).in(b.join(cdr).join(prefixes)); - final Formula f11 = f8.iff(f3.and(f9)).forAll(a.oneOf(NonEmptyList).and(b.oneOf(NonEmptyList))); - - return f0.and(f1).and(f6).and(f7).and(f11); - } - - /** - * Returns the isFinite predicate. - * - * @return isFinite - */ - public final Formula isFinite(Expression/* List */ L) { - // pred isFinite (L:List) {some EmptyList & L.*cdr} - return EmptyList.intersection(L.join(cdr.reflexiveClosure())).some(); - } - - /** - * Returns the reflexive assertion. - * - * @return reflexive - */ - public final Formula reflexive() { - // assert reflexive {all L: List | L in L.equivTo} - final Variable L = Variable.unary("L"); - return L.in(L.join(equivTo)).forAll(L.oneOf(List)); - } - - /** - * Returns the symmetric assertion. - * - * @return symmetric - */ - public final Formula symmetric() { - // assert symmetric { ~equivTo in equivTo } - return equivTo.transpose().in(equivTo); - } - - /** - * Returns the empties assertion. - * - * @return empties - */ - public final Formula empties() { - // assert empties { EmptyList->EmptyList in equivTo} - return EmptyList.product(EmptyList).in(equivTo); - } - - /** - * Returns the show predicate. - * - * @return show - */ - public final Formula show() { - // pred show() { - // some disj a, b: NonEmptyList | b in a.prefixes - // } - final Variable a = Variable.unary("a"), b = Variable.unary("b"); - return a.eq(b).not().and(b.in(a.join(prefixes))).forSome(a.oneOf(NonEmptyList).and(b.oneOf(NonEmptyList))); - } - - /** - * Returns the conjunction of declaration constraints and facts. - * - * @return decls() and facts() - */ - public final Formula invariants() { - return decls().and(facts()); - } - - /** - * Returns the conjunction of invariants and the show predicate. - * - * @return invariants() and show() - */ - public final Formula runShow() { - return invariants().and(show()); - } - - /** - * Returns the conjunction of invariants and the negation of the empty - * hypothesis. - * - * @return invariants() and !empties() - */ - public final Formula checkEmpties() { - return invariants().and(empties().not()); - } - - /** - * Returns the conjunction of invariants and the negation of the reflexive - * hypothesis. - * - * @return invariants() and !reflexive() - */ - public final Formula checkReflexive() { - return invariants().and(reflexive().not()); - } - - /** - * Returns the conjunction of invariants and the negation of the symmetric - * hypothesis. - * - * @return invariants() and !symmetric() - */ - public final Formula checkSymmetric() { - return invariants().and(symmetric().not()); - } - - /** - * Returns the bounds for the given scope. - * - * @return the bounds for the given scope. - */ - public final Bounds bounds(int scope) { - assert scope > 0; - final int n = scope * 2; - final List atoms = new ArrayList(n); - for (int i = 0; i < scope; i++) - atoms.add("Thing" + i); - for (int i = 0; i < scope; i++) - atoms.add("List" + i); - - // private final Relation Thing, List, NonEmptyList, EmptyList; - // private final Relation car, cdr, equivTo, prefixes; - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final int max = scope - 1; - - b.bound(Thing, f.range(f.tuple("Thing0"), f.tuple("Thing" + max))); - b.bound(List, f.range(f.tuple("List0"), f.tuple("List" + max))); - b.bound(EmptyList, b.upperBound(List)); - b.bound(NonEmptyList, b.upperBound(List)); - - b.bound(car, b.upperBound(List).product(b.upperBound(Thing))); - b.bound(cdr, b.upperBound(List).product(b.upperBound(List))); - b.bound(equivTo, b.upperBound(cdr)); - b.bound(prefixes, b.upperBound(cdr)); - return b; - } - - private static void usage() { - System.out.println("java examples.Lists [scope]"); - System.exit(1); - } - - /** - * Usage: java examples.Lists [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - try { - final int n = Integer.parseInt(args[0]); - final Lists model = new Lists(); - - final Bounds b = model.bounds(n); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setFlatten(false); - // solver.options().setSkolemize(false); - - Formula f = model.runShow(); - System.out.println("running show"); - Solution s = solver.solve(f, b); - System.out.println(s); - - f = model.checkEmpties(); - System.out.println("checking empties"); - s = solver.solve(f, b); - System.out.println(s); - - f = model.checkReflexive(); - System.out.println("checking reflexive"); - s = solver.solve(f, b); - System.out.println(s); - - f = model.checkSymmetric(); - System.out.println("checking symmetric"); - s = solver.solve(f, b); - System.out.println(s); - - } catch (NumberFormatException nfe) { - usage(); - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Pigeonhole.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Pigeonhole.class deleted file mode 100644 index bf5c7f284..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Pigeonhole.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Pigeonhole.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Pigeonhole.java deleted file mode 100644 index 145dbc9e4..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Pigeonhole.java +++ /dev/null @@ -1,127 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KodKod encoding of the pigeonhole problem: module internal/pigeonhole - * - *
- *
- * sig Pigeon { hole: Hole }
- *
- * sig Hole {}
- *
- * pred aPigeonPerHole() {
- * // holes are not shared
- *  no disj p1, p2: Pigeon |
- *   p1.hole = p2.hole }
- *
- * run aPigeonPerHole for exactly 30 Pigeon, exactly 29 Hole
- * 
- * - * @author Emina Torlak - */ -public final class Pigeonhole { - - // sigs - private final Relation Pigeon, Hole; - // fields - private final Relation hole; - - /** - * Creates an instance of the pigeonhole example. - */ - public Pigeonhole() { - this.Pigeon = Relation.unary("Pigeon"); - this.Hole = Relation.unary("Hole"); - this.hole = Relation.binary("hole"); - } - - /** - * Returns the declaration constraints. - * - * @return declarations - */ - public Formula declarations() { - return hole.function(Pigeon, Hole); - } - - /** - * Returns the aPigeonPerHole constraints. - * - * @return aPigeonPerHole - */ - public Formula pigeonPerHole() { - final Variable p1 = Variable.unary("p1"); - final Variable p2 = Variable.unary("p2"); - return (p1.eq(p2).not().implies(p1.join(hole).intersection(p2.join(hole)).no())).forAll(p1.oneOf(Pigeon).and(p2.oneOf(Pigeon))); - } - - /** - * Returns the bounds for the given number of pigeons and holes. - * - * @return bounds - */ - public Bounds bounds(int pigeons, int holes) { - final List atoms = new ArrayList(pigeons + holes); - for (int i = 0; i < pigeons; i++) { - atoms.add("Pigeon" + i); - } - for (int i = 0; i < holes; i++) { - atoms.add("Hole" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - - final Bounds b = new Bounds(u); - - final TupleSet pbound = f.range(f.tuple("Pigeon0"), f.tuple("Pigeon" + (pigeons - 1))); - final TupleSet hbound = f.range(f.tuple("Hole0"), f.tuple("Hole" + (holes - 1))); - b.boundExactly(Pigeon, pbound); - b.boundExactly(Hole, hbound); - b.bound(hole, pbound.product(hbound)); - return b; - } - - private static void usage() { - System.out.println("Usage: java tests.Pigeonhole [# pigeons] [# holes]"); - System.exit(1); - } - - /** - * Usage: java tests.Pigeonhole [# pigeons] [# holes] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - final Pigeonhole model = new Pigeonhole(); - final Solver solver = new Solver(); - - try { - final int p = Integer.parseInt(args[0]); - final int h = Integer.parseInt(args[1]); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setSymmetryBreaking(p); - final Formula show = model.declarations().and(model.pigeonPerHole()); - final Solution sol = solver.solve(show, model.bounds(p, h)); - // System.out.println(show); - System.out.println(sol); - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/RingElection.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/RingElection.class deleted file mode 100644 index f99e0cdbd..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/RingElection.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/RingElection.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/RingElection.java deleted file mode 100644 index 6d930f5dd..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/RingElection.java +++ /dev/null @@ -1,392 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * KodKod encoding of the following leader election algorithm: - * - *
- * module internal/ringElection
- * open util/ordering[Time] as TO
- * open util/ordering[Process] as PO
- *
- * sig Time {}
- * sig Process {
- *  succ: Process,
- *  toSend: Process -> Time,
- *  elected: set Time }
- *
- * fact Ring {all p: Process | Process in p.^succ}
- *
- * pred init (t: Time) {all p: Process | p.toSend.t = p}
- *
- * pred step (t, t': Time, p: Process) {
- *  let from = p.toSend, to = p.succ.toSend |
- *   some id: from.t {
- *    from.t' = from.t - id
- *    to.t' = to.t + (id - PO/prevs(p.succ)) } }
- *
- * pred skip (t, t': Time, p: Process) {p.toSend.t = p.toSend.t'}
- *
- * fact Traces {
- *  init (TO/first ())
- *  all t: Time - TO/last() | let t' = TO/next (t) |
- *   all p: Process | step (t, t', p) or step (t, t', succ.p) or skip (t, t', p) }
- *
- * fact DefineElected {
- *  no elected.TO/first()
- *  all t: Time - TO/first()|
- *   elected.t = {p: Process | p in p.toSend.t - p.toSend.(TO/prev(t))} }
- *
- *
- * pred progress () {
- *  all t: Time - TO/last() | let t' = TO/next (t) |
- *   some Process.toSend.t => some p: Process | not skip (t, t', p) }
- *
- * assert AtLeastOneElected { progress () => some elected.Time }
- *
- * pred looplessPath () {no disj t, t': Time | toSend.t = toSend.t'}
- *
- * assert AtMostOneElected {lone elected.Time}
- *
- * check AtMostOneElected for 3 Process, 7 Time
- * run looplessPath for 13 Time, 3 Process
- * 
- * - * @author Emina Torlak - */ -public final class RingElection { - - private final Relation Process, Time, succ, toSend, elected; - private final Relation pfirst, plast, pord, tfirst, tlast, tord; - - /** - * Constructs an instance of the RingElection example. - */ - public RingElection() { - Process = Relation.unary("Process"); - Time = Relation.unary("Time"); - succ = Relation.binary("succ"); - toSend = Relation.ternary("toSend"); - elected = Relation.binary("elected"); - pfirst = Relation.unary("pfirst"); - plast = Relation.unary("plast"); - pord = Relation.binary("pord"); - tfirst = Relation.unary("tfirst"); - tlast = Relation.unary("tlast"); - tord = Relation.binary("tord"); - } - - /** - * Returns the declaration constraints. - * - * @return - * - *
-     * sig Time {}
-     * sig Process {
-     *  succ: Process,
-     *  toSend: Process -> Time,
-     *  elected: set Time }
-     *         
- */ - public Formula declarations() { - final Formula ordTime = tord.totalOrder(Time, tfirst, tlast); - final Formula ordProcess = pord.totalOrder(Process, pfirst, plast); - final Formula succFunction = succ.function(Process, Process); - final Formula electedDomRange = elected.in(Process.product(Time)); - return succFunction.and(ordTime).and(ordProcess).and(electedDomRange); - } - - /** - * Returns the fact Ring. - * - * @return - * - *
-     * fact Ring {all p: Process | Process in p.^succ}
-     *         
- */ - public Formula ring() { - final Variable p = Variable.unary("p"); - return Process.in(p.join(succ.closure())).forAll(p.oneOf(Process)); - } - - /** - * Returns the init predicate. - * - * @return - * - *
-     *  pred init (t: Time) {all p: Process | p.toSend.t = p}
-     *         
- */ - public Formula init(Expression t) { - final Variable p = Variable.unary("p"); - return p.join(toSend).join(t).eq(p).forAll(p.oneOf(Process)); - } - - /** - * Returns the step predicate. - * - * @return - * - *
-     * pred step (t, t': Time, p: Process) {
-     *  let from = p.toSend, to = p.succ.toSend |
-     *   some id: from.t {
-     *    from.t' = from.t - id
-     *    to.t' = to.t + (id - PO/prevs(p.succ)) } }
-     *         
- */ - public Formula step(Expression t1, Expression t2, Expression p) { - final Expression from = p.join(toSend); - final Expression to = p.join(succ).join(toSend); - final Variable id = Variable.unary("id"); - final Expression prevs = (p.join(succ)).join((pord.transpose()).closure()); - final Formula f1 = from.join(t2).eq(from.join(t1).difference(id)); - final Formula f2 = to.join(t2).eq(to.join(t1).union(id.difference(prevs))); - return f1.and(f2).forSome(id.oneOf(from.join(t1))); - } - - /** - * Returns the skip predicate - * - * @return - * - *
-     *         pred skip (t, t': Time, p: Process) {p.toSend.t = p.toSend.t'}
-     *
-     *         
-     */
-    public Formula skip(Expression t1, Expression t2, Expression p) {
-        return p.join(toSend).join(t1).eq(p.join(toSend).join(t2));
-    }
-
-    /**
-     * Returns the Traces fact.
-     *
-     * @return
-     *
-     *         
-     * fact Traces {
-     *  init (TO/first ())
-     *  all t: Time - TO/last() | let t' = TO/next (t) |
-     *   all p: Process | step (t, t', p) or step (t, t', succ.p) or skip (t, t', p) }
-     *         
- */ - public Formula traces() { - final Variable t1 = Variable.unary("t"); - final Expression t2 = t1.join(tord); - final Variable p = Variable.unary("p"); - final Formula f = step(t1, t2, p).or(step(t1, t2, succ.join(p))).or(skip(t1, t2, p)); - final Formula fAll = f.forAll(p.oneOf(Process)).forAll(t1.oneOf(Time.difference(tlast))); - return init(tfirst).and(fAll); - } - - /** - * Return DefineElected fact. - * - * @return - * - *
-     * fact DefineElected {
-     *  no elected.TO/first()
-     *  all t: Time - TO/first()|
-     *   elected.t = {p: Process | p in p.toSend.t - p.toSend.(TO/prev(t))} }
-     *         
- */ - public Formula defineElected() { - final Variable t = Variable.unary("t"); - final Formula f1 = elected.join(tfirst).no(); - final Variable p = Variable.unary("p"); - final Formula c = p.in(p.join(toSend).join(t).difference(p.join(toSend).join(t.join(tord.transpose())))); - final Expression comprehension = c.comprehension(p.oneOf(Process)); - final Formula f2 = elected.join(t).eq(comprehension).forAll(t.oneOf(Time.difference(tfirst))); - return f1.and(f2); - } - - /** - * Returns the progress predicate. - * - * @return - * - *
-     * pred progress () {
-     *  all t: Time - TO/last() | let t' = TO/next (t) |
-     *   some Process.toSend.t => some p: Process | not skip (t, t', p) }
-     *         
- */ - public Formula progress() { - final Variable t1 = Variable.unary("t"); - final Expression t2 = t1.join(tord); - final Variable p = Variable.unary("p"); - final Formula f1 = Process.join(toSend).join(t1).some().implies(skip(t1, t2, p).not().forSome(p.oneOf(Process))); - return f1.forAll(t1.oneOf(Time.difference(tlast))); - } - - /** - * Returns the looplessPath predicate - * - * @return - * - *
-     * pred looplessPath () {no disj t, t': Time | toSend.t = toSend.t'}
-     *         
- */ - public Formula looplessPath() { - final Variable t1 = Variable.unary("t"); - final Variable t2 = Variable.unary("t'"); - // all t, t': Time | some t&t' || !(toSend.t = toSend.t') - final Formula f1 = t1.intersection(t2).some().or(toSend.join(t1).eq(toSend.join(t2)).not()); - return f1.forAll(t1.oneOf(Time).and(t2.oneOf(Time))); - } - - /** - * Returns the AtLeastOneElected assertion. - * - * @return - * - *
-     * assert AtLeastOneElected { progress () => some elected.Time }
-     *         
- */ - public Formula atLeastOneElected() { - return progress().implies(elected.join(Time).some()); - } - - /** - * Returns the atMostOneElected assertion - * - * @return - * - *
-     * assert AtMostOneElected {lone elected.Time}
-     *         
- */ - public Formula atMostOneElected() { - return elected.join(Time).lone(); - } - - /** - * Returns the declarations and facts of the model - * - * @return the declarations and facts of the model - */ - public Formula invariants() { - return declarations().and(ring()).and(traces()).and(defineElected()); - } - - /** - * Returns the conjunction of the invariants and the negation of - * atMostOneElected. - * - * @return invariants() && !atMostOneElected() - */ - public Formula checkAtMostOneElected() { - return invariants().and(atMostOneElected().not()); - } - - /** - * Returns a bounds object with scope processes and times. - * - * @return bounds object with scope processes and times. - */ - public Bounds bounds(int scope) { - return bounds(scope, scope); - } - - /** - * Returns a bounds object that scopes Process, Time, and their fields according - * to given values. - * - * @return bounds - */ - public Bounds bounds(int processes, int times) { - final List atoms = new ArrayList(processes + times); - for (int i = 0; i < processes; i++) { - atoms.add("Process" + i); - } - for (int i = 0; i < times; i++) { - atoms.add("Time" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final TupleSet pb = f.range(f.tuple("Process0"), f.tuple("Process" + (processes - 1))); - final TupleSet tb = f.range(f.tuple("Time0"), f.tuple("Time" + (times - 1))); - - b.bound(Process, pb); - b.bound(succ, pb.product(pb)); - b.bound(toSend, pb.product(pb).product(tb)); - b.bound(elected, pb.product(tb)); - b.bound(pord, pb.product(pb)); - b.bound(pfirst, pb); - b.bound(plast, pb); - - b.bound(Time, tb); - b.bound(tord, tb.product(tb)); - b.bound(tfirst, tb); - b.bound(tlast, tb); - - return b; - } - - private static void usage() { - System.out.println("java examples.RingElection [# processes] [# times]"); - System.exit(1); - } - - /** - * Usage: java examples.RingElection [# processes] [# times] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - - try { - final RingElection model = new RingElection(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final int p = Integer.parseInt(args[0]); - final int t = Integer.parseInt(args[1]); - - final Formula checkAtMostOneElected = model.checkAtMostOneElected(); - final Bounds boundspt = model.bounds(p, t); - - System.out.println("*****check AtMostOneElected for " + p + " Process, " + t + " Time*****"); - Solution sol1 = solver.solve(checkAtMostOneElected, boundspt); - System.out.println(sol1); - - // // run looplessPath for 13 Time, 3 Process - // final Formula runLooplessPath = - // model.declsAndFacts();//.and(model.looplessPath()); - // final Bounds bounds313 = model.bounds(p, t); - // System.out.println("*****run looplessPath for 13 Time, 3 - // Process*****"); - // System.out.println(runLooplessPath); - // System.out.println(bounds313); - // Solution sol2 = solver.solve(runLooplessPath, bounds313); - // System.out.println(sol2); - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Toughnut.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Toughnut.class deleted file mode 100644 index 4c5644cca..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Toughnut.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Toughnut.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Toughnut.java deleted file mode 100644 index 6c4e99f9d..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Toughnut.java +++ /dev/null @@ -1,142 +0,0 @@ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A kodkod encoding of John McCarthy's thoughnut problem - * - *
- * module internal/tougnut
- *
- * open util/ordering[Cell]
- *
- * sig Cell { covered: Cell -> Cell -> Cell }
- *
- * pred covering() {
- * // opposite corners not on the board
- * let board = Cell->Cell - (first()->first() + last()->last()) |
- *   covered in board->board
- *
- * // covering relation is symmetric
- * all x,y: Cell | y.(x.covered)->x->y in covered
- *
- * // each pair of cells on the board should be covered
- * // by a domino, which also covers ONE of its neighbors
- *  all x,y: Cell | one y.(x.covered) &&
- *   y.(x.covered) in  (prev(x)+next(x))->y + x->(prev(y) + next(y))
- *  }
- * 
- * - * @author Emina - */ -public final class Toughnut { - - private final Relation Cell, covered, ord; - - /** - * Creates an instance of Toughnut. - */ - public Toughnut() { - this.Cell = Relation.unary("Cell"); - this.covered = Relation.nary("covered", 4); - this.ord = Relation.binary("ord"); - } - - private Expression next(Expression e) { - return e.join(ord); - } - - private Expression prev(Expression e) { - return ord.join(e); - } - - /** - * Returns the covering predicate. Note that we don't need to specify the first - * two lines of the predicate, since they can be expressed as bounds - * constraints. - * - * @return the covering predicate - */ - public Formula checkBelowTooDoublePrime() { - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Decls d = x.oneOf(Cell).and(y.oneOf(Cell)); - final Expression xy = y.join(x.join(covered)); - // covering relation is symmetric - Formula symm = xy.product(x.product(y)).in(covered).forAll(d); - // each pair of cells on the board should be covered - // by a domino, which also covers ONE of its neighbors - Expression xNeighbors = (prev(x).union(next(x))).product(y); - Expression yNeighbors = x.product(prev(y).union(next(y))); - Formula covering = (xy.one().and(xy.in(xNeighbors.union(yNeighbors)))).forAll(d); - return symm.and(covering); - } - - /** - * Returns bounds for an nxn board. - * - * @return bounds for an nxn board. - */ - public Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) { - atoms.add(String.valueOf(i)); - } - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - - b.boundExactly(Cell, f.allOf(1)); - - final TupleSet ordBound = f.noneOf(2); - for (int i = 0; i < n - 1; i++) { - ordBound.add(f.tuple(String.valueOf(i), String.valueOf(i + 1))); - } - b.boundExactly(ord, ordBound); - - final TupleSet board = f.allOf(2); - board.remove(f.tuple(String.valueOf(0), String.valueOf(0))); - board.remove(f.tuple(String.valueOf(n - 1), String.valueOf(n - 1))); - - b.bound(covered, board.product(board)); - - return b; - } - - /** - * Usage: java examples.Toughnut [size of one side of the board; optional] - */ - public static void main(String[] args) { - try { - int n = args.length == 0 ? 4 : Integer.parseInt(args[0]); - final Toughnut nut = new Toughnut(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Formula covering = nut.checkBelowTooDoublePrime(); - final Bounds bounds = nut.bounds(n); - - // System.out.println(covering); - // System.out.println(bounds); - final Solution sol = solver.solve(covering, bounds); - System.out.println(sol); - } catch (NumberFormatException nfe) { - System.out.println("Usage: java examples.Toughnut [size of one side of the board; optional]"); - } - - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyFilesystem.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyFilesystem.class deleted file mode 100644 index 6e29c3a10..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyFilesystem.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyFilesystem.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyFilesystem.java deleted file mode 100644 index a2be31d06..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyFilesystem.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; -import kodkod.util.nodes.PrettyPrinter; - -/** - * A toy filesystem specification. - * - * @author Emina Torlak - */ -public final class ToyFilesystem { - - private final Relation file, dir, root; - private final Relation contents; - - /** - * Constructs a new instance of the file system problem. - */ - public ToyFilesystem() { - file = Relation.unary("File"); - dir = Relation.unary("Dir"); - root = Relation.unary("Root"); - contents = Relation.binary("contents"); - } - - /** - * Returns the toy filesystem constraints - * - * @return toy filesystem constraints - */ - public Formula constraints() { - final List formulas = new ArrayList(); - - formulas.add(contents.in(dir.product(dir.union(file)))); - - final Variable d = Variable.unary("d"); - formulas.add(d.in(d.join(contents.closure())).not().forAll(d.oneOf(dir))); - - formulas.add(root.in(dir)); - - formulas.add(file.union(dir).in(root.join(contents.reflexiveClosure()))); - - return Formula.and(formulas); - } - - /** - * Returns the toy filesystem bounds. - * - * @return toy filesystem bounds - */ - public final Bounds bounds() { - final Universe universe = new Universe("d0", "d1", "f0", "f1", "f2"); - final Bounds bounds = new Bounds(universe); - final TupleFactory factory = universe.factory(); - bounds.boundExactly(root, factory.setOf("d0")); - bounds.bound(dir, factory.setOf("d0", "d1")); - bounds.bound(file, factory.setOf("f0", "f1", "f2")); - bounds.bound(contents, factory.setOf(factory.tuple("d0", "d1")), bounds.upperBound(dir).product(factory.allOf(1))); - return bounds; - } - - /** - * Usage: java examples.alloy.ToyFilesystem - */ - public static void main(String[] args) { - final ToyFilesystem toy = new ToyFilesystem(); - final Formula f = toy.constraints(); - System.out.println(PrettyPrinter.print(f, 2)); - final Bounds b = toy.bounds(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final Solution s = solver.solve(f, b); - System.out.println(s); - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyLists.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyLists.class deleted file mode 100644 index 07ce02ea5..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyLists.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyLists.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyLists.java deleted file mode 100644 index 6e8e05b79..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/ToyLists.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.engine.ucore.AdaptiveRCEStrategy; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; -import kodkod.util.nodes.Nodes; - -/** - * A toy list specification. - * - * @author Emina Torlak - */ -public final class ToyLists { - - private final Relation list, nonEmptyList, emptyList, thing; - private final Relation equivTo, prefixes, car, cdr; - - /** - * Constructs a new instance of the toylists problem. - */ - public ToyLists() { - list = Relation.unary("List"); - nonEmptyList = Relation.unary("NonEmptyList"); - emptyList = Relation.unary("EmptyList"); - thing = Relation.unary("Thing"); - equivTo = Relation.binary("equivTo"); - prefixes = Relation.binary("prefixes"); - car = Relation.binary("car"); - cdr = Relation.binary("cdr"); - } - - private Expression car(Expression expr) { - return expr.join(car); - } - - private Expression cdr(Expression expr) { - return expr.join(cdr); - } - - private Expression equivTo(Expression expr) { - return expr.join(equivTo); - } - - private Expression prefixes(Expression expr) { - return expr.join(prefixes); - } - - private Formula equiv(Expression a, Expression b) { - return a.in(equivTo(b)); - } - - private Formula prefix(Expression a, Expression b) { - return a.in(prefixes(b)); - } - - /** - * Returns the toylists spec. - * - * @return toylists spec - */ - public Formula spec() { - final Variable a = Variable.unary("a"), b = Variable.unary("b"), e = Variable.unary("e"); - - final List spec = new ArrayList(); - spec.add(list.eq(nonEmptyList.union(emptyList))); - spec.add(nonEmptyList.intersection(emptyList).no()); - - spec.add(car.in(nonEmptyList.product(thing))); - spec.add(car(a).one().forAll(a.oneOf(nonEmptyList))); - - spec.add(cdr.in(nonEmptyList.product(list))); - spec.add(cdr(a).one().forAll(a.oneOf(nonEmptyList))); - spec.add(e.in(a.join(cdr.reflexiveClosure())).forSome(e.oneOf(emptyList)).forAll(a.oneOf(list))); - - spec.add(equivTo.in(list.product(list))); - spec.add(equiv(a, b).iff(car(a).eq(car(b)).and(equivTo(cdr(a)).eq(equivTo(cdr(b))))).forAll(a.oneOf(list).and(b.oneOf(list)))); - - spec.add(prefixes.in(list.product(list))); - spec.add(prefix(e, a).forAll(e.oneOf(emptyList).and(a.oneOf(list)))); - spec.add(prefix(a, e).not().forAll(e.oneOf(emptyList).and(a.oneOf(nonEmptyList)))); - - spec.add(prefix(a, b).iff(car(a).eq(car(b)).and(prefix(cdr(a), cdr(b)))).forAll(a.oneOf(nonEmptyList).and(b.oneOf(nonEmptyList)))); - - return Formula.and(spec); - } - - /** - * Returns a formula stating that two lists are prefixes of one another iff they - * are equivalent. - * - * @return a formula stating that two lists are prefixes of one another iff they - * are equivalent. - */ - public Formula equivPrefix() { - final Variable a = Variable.unary("a"), b = Variable.unary("b"); - return prefix(a, b).and(prefix(b, a)).iff(equiv(a, b)).forAll(a.oneOf(list).and(b.oneOf(list))); - } - - /** - * Returns a formula stating that a list that is equivalent to all of its - * prefixes contains at most one thing. - * - * @return a formula stating that a list that is equivalent to all of its - * prefixes contains at most one thing. - */ - public Formula loneList() { - final Variable a = Variable.unary("a"); - return prefixes(a).eq(equivTo(a)).implies(cdr(a).in(emptyList)).forAll(a.oneOf(list)); - } - - /** - * Returns a formula stating that the prefix relation is transitive over - * non-empty lists. - * - * @return a formula stating that the prefix relation is transitive over - * non-empty lists. - */ - public Formula transitivePrefixes() { - final Variable a = Variable.unary("a"), b = Variable.unary("b"), c = Variable.unary("c"); - return prefix(a, b).and(prefix(b, c)).implies(prefix(a, c)).forAll(a.oneOf(nonEmptyList).and(b.oneOf(nonEmptyList)).and(c.oneOf(nonEmptyList))); - } - - /** - * Returns a formula stating that all lists are acyclic. - * - * @return a formula stating that all lists are acyclic. - */ - public Formula acyclicity() { - // all a: List | a !in a.^cdr - final Variable a = Variable.unary("a"); - return a.in(cdr(a)).not().forAll(a.oneOf(list)); - } - - /** - * Returns a formula stating that the equivTo relation is reflexive. - * - * @return negation of a formula stating that the equivTo relation is reflexive. - */ - public Formula equivReflexivity() { - // all L: List | L in L.equivTo - final Variable a = Variable.unary("a"); - return a.in(equivTo(a)).forAll(a.oneOf(list)); - } - - /** - * Returns the bounds for the toy lists problem with the given number of lists - * and things. - * - * @return bounds for the toy lists problem with the given number of lists and - * things. - */ - public Bounds bounds(int lists, int things) { - final List atoms = new ArrayList(lists + things); - for (int i = 0; i < lists; i++) { - atoms.add("list" + i); - } - for (int i = 0; i < things; i++) { - atoms.add("thing" + i); - } - final Universe univ = new Universe(atoms); - final TupleFactory f = univ.factory(); - final Bounds b = new Bounds(univ); - - b.bound(list, f.range(f.tuple("list0"), f.tuple("list" + (lists - 1)))); - b.bound(nonEmptyList, b.upperBound(list)); - b.bound(emptyList, b.upperBound(list)); - - b.bound(thing, f.range(f.tuple("thing0"), f.tuple("thing" + (things - 1)))); - - b.bound(car, b.upperBound(nonEmptyList).product(b.upperBound(thing))); - b.bound(cdr, b.upperBound(nonEmptyList).product(b.upperBound(list))); - b.bound(equivTo, b.upperBound(list).product(b.upperBound(list))); - b.bound(prefixes, b.upperBound(list).product(b.upperBound(list))); - - return b; - } - - private static void usage() { - System.out.println("Usage: java examples.alloy.ToyLists <# of lists> <# of things> "); - System.exit(1); - } - - /** - * Usage: java examples.alloy.ToyLists <# of lists> <# of things> - */ - public static void main(String[] args) { - if (args.length < 3) - usage(); - try { - final int l = Integer.parseInt(args[0]); - final int t = Integer.parseInt(args[1]); - final int a = Integer.parseInt(args[2]); - final ToyLists model = new ToyLists(); - - final Bounds b = model.bounds(l, t); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setLogTranslation(1); - solver.options().setSymmetryBreaking(1000); - - final Formula f; - switch (a) { - case 0 : - f = model.spec(); - break; - case 1 : - f = model.spec().and(model.equivPrefix().not()); - break; - case 2 : - f = model.spec().and(model.loneList().not()); - break; - case 3 : - f = model.spec().and(model.transitivePrefixes().not()); - break; - case 4 : - f = model.spec().and(model.acyclicity().not()); - break; - case 5 : - f = model.spec().and(model.equivReflexivity().not()); - break; - default : - usage(); - throw new AssertionError("dead code"); - } - - final Solution sol = solver.solve(f, b); - if (sol.instance() != null) { - System.out.println(sol); - } else { - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - - System.out.println("Top level formulas: " + sol.proof().log().roots().size()); - System.out.println("Initial core: " + sol.proof().highLevelCore().size()); - - sol.proof().minimize(new AdaptiveRCEStrategy(sol.proof().log())); - - System.out.println("Minimal core: " + sol.proof().highLevelCore().size()); - - final Set core = Nodes.allRoots(f, sol.proof().highLevelCore().values()); - - for (Formula c : core) { - System.out.println(c); - } - - System.out.print("checking the core ... "); - if (solver.solve(Formula.and(core), b).instance() == null) { - System.out.println("correct."); - } else { - System.out.println("incorrect!"); - } - } - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Trees.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Trees.class deleted file mode 100644 index 16a50edb9..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Trees.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Trees.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Trees.java deleted file mode 100644 index 3a5da67f6..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Trees.java +++ /dev/null @@ -1,315 +0,0 @@ -/** - * - */ -package examples.alloy; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * KK encoding of the Tree example from F. Zaraket, A. Aziz, and S. Khurshid's - * "Sequential Encoding for Relational Analysis". - * - * @author Emina Torlak - */ -public final class Trees { - - /* - * KK outperformed by the sequential analysis tool on this model - */ - private final Relation V, E; - - /** - * Constructs a new instance of the trees problem - */ - public Trees() { - V = Relation.unary("V"); - E = Relation.binary("E"); - } - - /** - * Returns the declarations and facts of the model. - * - * @return - * - *
-     * sig V { E: set V }
-     * fact UndirectedGraph { E = ~E }
-     * fact NonEmpty { some V }
-     *         
- */ - public final Formula declsAndFacts() { - final Formula f0 = E.in(V.product(V)); - final Formula f1 = E.eq(E.transpose()); - final Formula f2 = V.some(); - return f0.and(f1).and(f2); - } - - /** - * Returns the inCycle predicate. - * - * @return - * - *
-     * pred InCycle(v: V, c: V -> V) {
-     * v in v.c or
-     * some v': v.c | v' in v.^(c - v->v' - v'->v)
-     * }
-     *         
- */ - public final Formula inCycle(Expression/* V */ v, Expression/* V->V */ c) { - final Formula f0 = v.in(v.join(c)); - final Variable vp = Variable.unary("v'"); - final Formula f1 = vp.in(v.join((c.difference(v.product(vp)).difference(vp.product(v))).closure())); - return f0.or(f1.forSome(vp.oneOf(v.join(c)))); - } - - /** - * Returns the acyclic predicate. - * - * @return - * - *
-     * pred Acyclic() {
-     *  not Cyclic(E)
-     * }
-     *         
- */ - public final Formula acyclic() { - return cyclic(E).not(); - } - - /** - * Returns the connected predicate. - * - * @return - * - *
-     * V->V in *c
-     *         
- */ - public final Formula connected(Expression/* V->V */ c) { - - return V.product(V).in(c.reflexiveClosure()); - } - - /** - * Returns statement 1. - * - * @return - * - *
-     * pred Statement1() { Connected(E) and Acyclic() }
-     *         
- */ - public final Formula statement1() { - return connected(E).and(acyclic()); - } - - /** - * Returns statement 2. - * - * @return - * - *
-     * pred Statement2() {
-     * Connected(E) and
-     * all u: V | all v: u.E | not Connected( E - (u->v) - (v->u) )
-     * }
-     *         
- */ - public final Formula statement2() { - final Variable u = Variable.unary("u"); - final Variable v = Variable.unary("v"); - final Formula f0 = connected(E); - final Formula f1 = connected(E.difference(u.product(v)).difference(v.product(u))).not(); - final Formula f2 = f1.forAll(v.oneOf(u.join(E))).forAll(u.oneOf(V)); - return f0.and(f2); - } - - /** - * Returns statement 3. - * - * @return - * - *
-     * pred Statement3 () {
-     * Connected(E) and #E = #V + #V - 2
-     *         
- */ - public final Formula statement3() { - final IntExpression vcount = V.count(); - return connected(E).and(E.count().eq(vcount.plus(vcount).minus(IntConstant.constant(2)))); - } - - /** - * Returns statement 3. - * - * @return - * - *
-     * pred Statement4 () {
-     * Acyclic() and #E = #V + #V - 2
-     *         
- */ - public final Formula statement4() { - final IntExpression vcount = V.count(); - return acyclic().and(E.count().eq(vcount.plus(vcount).minus(IntConstant.constant(2)))); - } - - /** - * Returns the cyclic predicate. - * - * @return - * - *
-     * pred Cyclic(c: V->V) { some v: V | inCycle(v, c) }
-     *         
- */ - public final Formula cyclic(Expression/* V->V */ c) { - final Variable v = Variable.unary("v"); - return inCycle(v, c).forSome(v.oneOf(V)); - } - - /** - * Returns statement 5. - * - * @return - * - *
-     * pred Statement5() {
-     * Acyclic() and
-     * all u,v: V | (u->v) not in E implies Cyclic(E + (u->v) + (v->u))
-     * }
-     *         
- */ - public final Formula statement5() { - final Variable u = Variable.unary("u"); - final Variable v = Variable.unary("v"); - final Formula f0 = u.product(v).in(E).not().implies(cyclic(E.union(u.product(v).union(v.product(u))))); - final Formula f1 = f0.forAll(u.oneOf(V).and(v.oneOf(V))); - return acyclic().and(f1); - } - - /** - * Returns the EquivOfTreeDefns assertion. - * - * @return - * - *
-     * assert EquivOfTreeDefns {
-     * Statement1() implies Statement2()
-     * Statement2() implies Statement3()
-     * Statement3() implies Statement4()
-     * Statement4() implies Statement5()
-     * Statement5() implies Statement1()
-     * }
-     *         
- */ - public final Formula equivOfTreeDefns() { - final Formula s1 = statement1(), s2 = statement2(), s3 = statement3(), s4 = statement4(), s5 = statement5(); - final Formula f0 = s1.implies(s2); - final Formula f1 = s2.implies(s3); - final Formula f2 = s3.implies(s4); - final Formula f3 = s4.implies(s5); - final Formula f4 = s5.implies(s1); - return f0.and(f1).and(f2).and(f3).and(f4); - } - - /** - * Returns the formula that checks the EquivOfTreeDefns assertion. - * - * @return declsAndFacts() and not equivOfTreeDefns() - */ - public final Formula checkEquivOfTreeDefns() { - return declsAndFacts().and(equivOfTreeDefns().not()); - } - - /** - * Returns the bounds for the Trees problem that uses the given number of - * vertices. - * - * @return bounds for the Trees problem that uses the given number of vertices - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("v" + i); - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - b.bound(V, f.allOf(1)); - b.bound(E, f.allOf(2)); - return b; - } - - private static void usage() { - System.out.println("java examples.Trees [# vertices]"); - System.exit(1); - } - - /** - * Usage: java examples.Trees [# vertices] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - try { - final int n = Integer.parseInt(args[0]); - final Trees model = new Trees(); - final Bounds b = model.bounds(n); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setBitwidth(16); - // System.out.println(solver.solve(model.checkEquivOfTreeDefns(), - // b)); - - final Formula[] statements = new Formula[5]; - statements[0] = model.statement1(); - statements[1] = model.statement2(); - statements[2] = model.statement3(); - statements[3] = model.statement4(); - statements[4] = model.statement5(); - - long time = 0; - - for (int i = 0; i < 5; i++) { - Formula f = model.declsAndFacts().and(statements[i]).and(statements[(i + 1) % 5].not()); - Solution s = solver.solve(f, b); - time += s.stats().translationTime() + s.stats().solvingTime(); - System.out.println(s); - if (s.instance() != null) { - return; - } - } - - System.out.println("valid: " + time + " ms"); - - } catch (NumberFormatException nfe) { - usage(); - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Viktor.class b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Viktor.class deleted file mode 100644 index b5ae9785b..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Viktor.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Viktor.java b/org.alloytools.kodkod.core/src/test/java/examples/alloy/Viktor.java deleted file mode 100644 index bbfdfc10f..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/alloy/Viktor.java +++ /dev/null @@ -1,242 +0,0 @@ -/** - * - */ -package examples.alloy; - -import static kodkod.ast.Expression.INTS; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.ConsoleReporter; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KK encoding of the Kuncak hypothesis for n = 3. - * - * @author Emina Torlak - */ -public final class Viktor { - - private final int rows, cols; - private final Relation[][] a; - private final Relation[] x; - private final IntExpression[] b; - - /** - * Constructs an instance of Viktor for n = 3. - */ - public Viktor() { - rows = 3; - cols = 1 << rows; - a = new Relation[rows][cols]; - x = new Relation[cols]; - b = new IntExpression[rows]; - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - a[i][j] = Relation.unary("a" + String.valueOf(i) + String.valueOf(j)); - } - } - for (int j = 0; j < cols; j++) { - x[j] = Relation.unary("x" + j); - } - for (int i = 0; i < rows; i++) { - b[i] = conditionalSum(a[i], x, 0, cols - 1); - } - } - - /** - * Returns the sum of the elements in x (conditional on the non-emptiness of a - * given a[i]) located at indices [lo..hi] - * - * @return the sum of cardinalities of the elements in x (conditional on the - * non-emptiness of a given a[i]) located at indices [lo..hi] - */ - private static IntExpression conditionalSum(Expression[] a, Expression[] x, int lo, int hi) { - if (lo > hi) - return IntConstant.constant(0); - else if (lo == hi) - return a[lo].some().thenElse(x[lo].sum(), IntConstant.constant(0)); - else { - final int mid = (lo + hi) / 2; - final IntExpression lsum = conditionalSum(a, x, lo, mid); - final IntExpression hsum = conditionalSum(a, x, mid + 1, hi); - return lsum.plus(hsum); - } - } - - /** - * Returns a formula constraining all x's to be singletons. - * - * @return a formula constraining all x's to be singletons - */ - public final Formula decls() { - Formula ret = Formula.TRUE; - for (Relation xj : x) { - ret = ret.and(xj.one()); - } - return ret; - } - - /** - * Returns the equations to be satisfied. - * - * @return equations to be satisfied. - */ - public final Formula equations() { - - // each b <= cols-1 - Formula f0 = Formula.TRUE; - final IntConstant colConst = IntConstant.constant(cols - 1); - for (IntExpression bi : b) { - f0 = f0.and(bi.lte(colConst)); - } - - final Variable[] y = new Variable[rows]; - for (int i = 0; i < rows; i++) { - y[i] = Variable.unary("y" + i); - } - - Decls decls = y[0].oneOf(INTS); - for (int i = 1; i < rows; i++) - decls = decls.and(y[i].oneOf(INTS)); - - Formula f1 = Formula.TRUE; - final Expression[] combo = new Expression[rows]; - for (int i = 0; i < cols; i++) { - for (int j = i + 1; j < cols; j++) { - for (int k = j + 1; k < cols; k++) { - Formula f2 = Formula.TRUE; - for (int m = 0; m < rows; m++) { - combo[0] = a[m][i]; - combo[1] = a[m][j]; - combo[2] = a[m][k]; - f2 = f2.and(conditionalSum(combo, y, 0, rows - 1).eq(b[m])); - } - f1 = f1.and(f2.not().forAll(decls)); - } - } - } - return f0.and(f1); - } - - /** - * Returns decls() && equations(). - * - * @return decls() && equations() - */ - public final Formula checkEquations() { - return decls().and(equations()); - } - - /** - * Returns the bounds for the problem. - * - * @return bounds - */ - public final Bounds bounds() { - List atoms = new ArrayList(cols + 1); - for (int i = 0; i < cols; i++) { - atoms.add(String.valueOf(i)); - } - atoms.add("a"); - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - final TupleSet abound = f.setOf("a"); - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - b.bound(a[i][j], abound); - } - } - final TupleSet xbound = f.range(f.tuple(String.valueOf(0)), f.tuple(String.valueOf(cols - 1))); - for (int j = 0; j < cols; j++) { - b.bound(x[j], xbound); - b.boundExactly(j, f.setOf(String.valueOf(j))); - } - - return b; - } - - private final void display(Instance instance, Options options) { - final Evaluator eval = new Evaluator(instance, options); - for (int i = 0; i < 2; i++) { - System.out.print(" | "); - System.out.print(instance.tuples(x[i]).indexView().min()); - System.out.println(" |"); - } - - for (int i = 0; i < rows; i++) { - System.out.print("| "); - for (int j = 0; j < cols; j++) { - System.out.print(instance.tuples(a[i][j]).isEmpty() ? 0 : 1); - System.out.print(" "); - } - System.out.print(i == 1 ? "| * | " : "| | "); - System.out.print(instance.tuples(x[i + 2]).indexView().min()); - System.out.print(i == 1 ? " | = | " : " | | "); - System.out.print(eval.evaluate(b[i])); - System.out.println(" |"); - } - - for (int i = 5; i < 8; i++) { - System.out.print(" | "); - System.out.print(instance.tuples(x[i]).indexView().min()); - System.out.println(" |"); - } - - // for(int i = 0; i < 3; i++) - // System.out.println(b[i]); - // - // for(int i = 0; i < rows; i++) { - // for(int j = 0 ; j < 8; j++) { - // IntExpression e0 = x[j].sum(); - // IntExpression e1 = a[i][j].some().thenElse(e0, - // IntConstant.constant(0)); - // System.out.println(e0 + " : " + eval.evaluate(e0)); - // System.out.println(e1 + " : " + eval.evaluate(e1)); - // } - // } - } - - /** - * Usage: java tests.Viktor - */ - public static void main(String[] args) { - - final Viktor model = new Viktor(); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setReporter(new ConsoleReporter()); - solver.options().setBitwidth(7); - final Formula f = model.checkEquations(); - final Bounds b = model.bounds(); - System.out.println(f); - System.out.println(b); - final Solution sol = solver.solve(f, b); - - System.out.println(sol); - if (sol.instance() != null) - model.display(sol.instance(), solver.options()); - - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Bigconfig.class b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Bigconfig.class deleted file mode 100644 index f3e539f69..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Bigconfig.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Bigconfig.java b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Bigconfig.java deleted file mode 100644 index 0e7b2b28d..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Bigconfig.java +++ /dev/null @@ -1,270 +0,0 @@ -package examples.netconfig; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.ConsoleReporter; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A kodkod encoding of bigconfig.als: - * - *
- *  module internal/bigconfig
- *
- *  abstract sig Site {}
- *  sig HQ, Sub extends Site {}
- *
- *  sig Router {
- *  site: Site,
- *  link: set Router
- *  }
- *
- *  pred invariants() {
- *  -- every site has at least one router
- *  Site in Router.site
- *
- *  -- links are symmetric and non-reflexive
- *  link = ~link
- *  no link & iden
- *  }
- *
- *  pred subsConnectedToHQ() {
- *  -- every sub location is connected to an HQ location at the given time
- *  site.Sub in (site.HQ).link
- *  }
- *
- *  pred connectedSites(sites: set Site) {
- *  -- all sites in the given set are connected to each other
- *  all s: sites | sites - s in ((site.s).ˆlink).site
- *  }
- *
- *  pred show() {
- *  invariants() && subsConnectedToHQ() && connectedSites(Site)
- *  }
- * 
- * - * @author Emina Torlak - */ -public class Bigconfig { - - // sigs - private final Relation Router, Site, HQ, Sub; - // fields - private final Relation site, link; - - private final int closureApprox; - - /** - * Constructs an instance of the BigConfig example. - */ - public Bigconfig(int closureApprox) { - Router = Relation.unary("Router"); - Site = Relation.unary("Site"); - HQ = Relation.unary("HQ"); - Sub = Relation.unary("Sub"); - site = Relation.binary("site"); - link = Relation.binary("link"); - this.closureApprox = closureApprox; - } - - /** - * Returns the constraints implicit in signature and field declarations. - * - * @return abstract sig Site {} sig HQ, Sub extends Site {} sig Router { site: - * Site, link: set Router } - */ - public Formula declarations() { - // HQ + Sub in Site && no HQ & Sub - final Formula hqSub = HQ.union(Sub).in(Site).and(HQ.intersection(Sub).no()); - // site is a function from Router to Site - final Formula siteFun = site.function(Router, Site); - // link in Router->Router - final Formula links = link.in(Router.product(Router)); - return hqSub.and(siteFun).and(links); - } - - /** - * Returns the invariants predicate. - * - * @return pred invariants() { -- every site has at least one router Site in - * Router.site -- links are symmetric and non-reflexive link = ~link no - * link & iden } - */ - public Formula invariants() { - Formula atLeastARouter = Site.in(Router.join(site)); - Formula linksSymmetric = link.eq(link.transpose()); - Formula linksNotReflexive = link.intersection(Expression.IDEN).no(); - return atLeastARouter.and(linksSymmetric).and(linksNotReflexive); - } - - /** - * Returns the subsConnectedToHQ predicate. - * - * @return pred subsConnectedToHQ() { -- every sub location is connected to an - * HQ location at the given time site.Sub in (site.HQ).link } - */ - public Formula subsConnectedToHQ() { - return site.join(Sub).in(site.join(HQ).join(link)); - } - - /** - * Returns the connectedSites predicate. - * - * @return pred connectedSites(sites: set Site) { -- all sites in the given set - * are connected to each other all s: sites | sites - s in - * ((site.s).^link).site } - */ - public Formula connectedSites(Expression sites) { - final Variable s = Variable.unary("s"); - Expression closed; - if (closureApprox > 0) { - closed = link; - for (int i = 1; i < closureApprox; i *= 2) { - closed = closed.union(closed.join(closed)); - } - } else { - closed = link.closure(); - } - - final Expression sreachable = site.join(s).join(closed).join(site); - final Formula f = sites.difference(s).in(sreachable); - return f.forAll(s.oneOf(sites)); - } - - /** - * Returns the show predicate. - * - * @return pred show() { invariants() && subsConnectedToHQ() && - * connectedSites(Site) } - */ - public Formula show() { - return declarations().and(invariants()).and(subsConnectedToHQ()).and(connectedSites(Site)); - } - - /** - * @return a universe with n routers and n sites. The first n atoms are sites. - */ - private Universe universe(int n) { - final List atoms = new ArrayList(n * 2); - for (int i = 0; i < n; i++) { - atoms.add("Site" + i); - } - for (int i = 0; i < n; i++) { - atoms.add("Router" + i); - } - return new Universe(atoms); - } - - /** - * Returns a bounds with the given number of hqs and subs, constructed using the - * given universe. - * - * @requires hqNum > 0 && subNum > 0 - * @requires u contains at least (hqNum+sub) Router atoms and as many Site atoms - * @return bounds - */ - private Bounds bounds(int hqNum, int subNum, Universe u) { - final TupleFactory f = u.factory(); - - final Bounds b = new Bounds(u); - final int siteMax = hqNum + subNum - 1; - - final String site0 = "Site0"; - final String siteN = "Site" + siteMax; - final String siteHQ = "Site" + (hqNum - 1); - final String siteSub = "Site" + hqNum; - final String router0 = "Router0"; - final String routerN = "Router" + siteMax; - - final TupleSet sites = f.range(f.tuple(site0), f.tuple(siteN)); - b.boundExactly(Site, sites); - b.boundExactly(HQ, f.range(f.tuple(site0), f.tuple(siteHQ))); - b.boundExactly(Sub, f.range(f.tuple(siteSub), f.tuple(siteN))); - - final TupleSet routers = f.range(f.tuple(router0), f.tuple(routerN)); - b.boundExactly(Router, routers); - b.bound(link, routers.product(routers)); - // b.bound(site, routers.product(sites)); - final TupleSet routerLocations = f.noneOf(2); - for (int i = 0; i <= siteMax; i++) { - routerLocations.add(f.tuple("Router" + i, "Site" + i)); - } - b.boundExactly(site, routerLocations); - - return b; - } - - /** - * Returns a bounds with the given number of hqs and subs. The parameter - * routerNum designates the total number of routers in the universe. - * - * @requires hqNum > 0 && subNum > 0 - * @requires hqNum + subNum <= routers - * @return bounds - */ - public Bounds bounds(int hqNum, int subNum, int routerNum) { - assert hqNum > 0 && subNum > 0 && hqNum + subNum <= routerNum; - - return bounds(hqNum, subNum, universe(routerNum)); - } - - private static void usage() { - System.out.println("Usage: java tests.Bigconfig [# hq] [# sub] [# closure unwindings, 0 for true closure] [size of partial instance, 0 default]"); - System.exit(1); - } - - /** - * Usage: java tests.Bigconfig [# hq] [# sub] [# closure unwindings, 0 for true - * closure] [size of partial instance, 0 default] - * - * @throws InterruptedException - */ - public static void main(String[] args) { - if (args.length < 3) - usage(); - - final Bigconfig model = new Bigconfig(Integer.parseInt(args[2])); - final Solver solver = new Solver(); - // solver.options().setSolver(SATFactory.ZChaffMincost); - solver.options().setSolver(SATFactory.MiniSat); - try { - final int hq = Integer.parseInt(args[0]); - final int sub = Integer.parseInt(args[1]); - final int partial = args.length > 3 ? Integer.parseInt(args[3]) : 0; - final Formula show = model.show(); - if (partial > 0) { - Bounds bounds = model.bounds(hq, sub - partial, hq + sub); - Solution sol = solver.solve(show, bounds); - System.out.println("Solved for " + hq + " hq and " + (sub - partial) + " subs."); - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - System.out.println("Solving again with a partial instance: " + hq + " hq and " + sub + " subs."); - bounds = model.bounds(hq, sub, bounds.universe()); - bounds.bound(model.link, sol.instance().tuples(model.link), bounds.upperBound(model.link)); - sol = solver.solve(show, bounds); - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - } else { - solver.options().setReporter(new ConsoleReporter()); - final Bounds bounds = model.bounds(hq, sub, hq + sub); - final Solution sol = solver.solve(show, bounds); - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - - } - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure$NetNode.class b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure$NetNode.class deleted file mode 100644 index 4de0ed80f..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure$NetNode.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure$Subnet.class b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure$Subnet.class deleted file mode 100644 index 512785716..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure$Subnet.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure.class b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure.class deleted file mode 100644 index cb52a4f0e..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure.java b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure.java deleted file mode 100644 index e97ed1279..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/ConfigAssure.java +++ /dev/null @@ -1,711 +0,0 @@ -/** - * - */ -package examples.netconfig; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; -import kodkod.util.nodes.PrettyPrinter; - -/** - * Pure Kodkod encoding of the new test case for ConfigAssure. - * - * @author Emina Torlak - */ -public final class ConfigAssure { - - /** - * port is a unary relation that contains all the port atoms, represented by - * concatenating the device name and the interface of each port. - **/ - private final Relation port; - - /** - * unknown contains ports whose components aren't fully specified. - */ - private final Relation unknown; - - /** - * The addr relation maps port atoms to all the power-of-2 atoms (1, 2, 4, ..., - * 2^31). - */ - private final Relation addr; - - /** - * The subnet relation maps one representative port atom in each subnet to all - * the other port atoms in the same subnet. For example, the Prolog predicate - * subnet(['IOS_00037'-'Vlan790', 'IOS_00038'-'Vlan790']) is represented by the - * tuples <'IOS_00037'-'Vlan790', 'IOS_00037'-'Vlan790'> and - * <'IOS_00037'-'Vlan790', 'IOS_00038'-'Vlan790'> in the subnet relation. We - * choose the first port in each Prolog predicate that has a constant address - * and mask to be the representative of that subnet, if such a port exists. - * Otherwise, we choose the first Prolog predicate encountered during parsing to - * be the representative of a given subnet. This encoding assumes that each port - * can participate in at most one subnet. - */ - private final Relation subnet; - - /** - * The group relation maps all atoms in each subnet that have the same interface - * to one representative port atom. For example, the Prolog predicate - * subnet(['IOS_00091'-'Vlan820', 'IOS_00092'-'Vlan820', - * 'IOS_00096'-'FastEthernet0/0']) is represented by the tuples - * <'IOS_00091'-'Vlan820', 'IOS_00091'-'Vlan820'>, <'IOS_00092'-'Vlan820', - * 'IOS_00091'-'Vlan820>, and - * <'IOS_00096'-'FastEthernet0/0','IOS_00096'-'FastEthernet0/0'> in the group - * relation. Ports that are not part of any subnet form their own group (of - * which they are a representative). - */ - private final Relation group; - - /** - * The groupMask relation maps port atoms that are group representatives to the - * integer atoms 1, 2, 4, 8 and 16, implicitly representing each group's mask by - * the number of zeros it contains [0..31]. - **/ - private final Relation groupMask; - - /** - * Join of the group relation with the groupMask relation: provides an implicit - * mask for each port. - */ - private final Expression mask; - - private final IntConstant ones = IntConstant.constant(-1); - private final static int minAddr = (121 << 24) | (96 << 16); - private final static int maxAddr = minAddr | (255 << 8) | 255; - - /** - * Constructs a new instance of ConfigAssure. - */ - public ConfigAssure() { - this.port = Relation.unary("port"); - this.unknown = Relation.unary("unknown"); - this.addr = Relation.binary("addr"); - this.groupMask = Relation.binary("groupMask"); - this.subnet = Relation.binary("subnet"); - this.group = Relation.binary("group"); - this.mask = group.join(groupMask); - } - - /** - * Returns the netID of the given port. - * - * @return netID of the given port - */ - IntExpression netid(Expression p) { - return addr(p).and(explicitMask(p)); - } - - /** - * Returns the ip address of the given port. - * - * @return ip address of the given port - */ - IntExpression addr(Expression p) { - return p.join(addr).sum(); - } - - /** - * Returns the number of zeros in the mask of the given port. - * - * @return the number of zeros in the mask of the given port - */ - IntExpression implicitMask(Expression p) { - return p.join(mask).sum(); - } - - /** - * Returns the explicit mask of the given port. - * - * @return explicit mask of the given port - */ - IntExpression explicitMask(Expression p) { - return ones.shl(implicitMask(p)); - } - - /** - * Returns the subnet of the given port. - * - * @return subnet of the given port - */ - Expression subnet(Expression p) { - return p.join(subnet); - } - - /** - * Returns a Formula that evaluates to true if the netid represented of the port - * p0 contains the netid of the port p1. - * - * @return zeros(p0) >= zeros(p1) and (addr(p0) & mask(p0)) = (addr(p1) & - * mask(p0)) - */ - Formula contains(Expression p0, Expression p1) { - final Formula f0 = implicitMask(p0).gte(implicitMask(p1)); - final Formula f1 = addr(p0).and(explicitMask(p0)).eq(addr(p1).and(explicitMask(p0))); - return f0.and(f1); - } - - /** - * Returns the requirements. - * - * @return requirements - */ - public Formula requirements() { - - final List reqs = new ArrayList(); - - final Variable p0 = Variable.unary("p0"), p1 = Variable.unary("p1"), p2 = Variable.unary("p2"); - - // contains the representatives of all subnets - final Expression subreps = subnet.join(port); - // contains the representatives of subnets with some unknown members - final Expression unknownSubs = subnet.join(unknown); - - // the ports with known components are guaranteed to obey the following - // constraints (ensured by the preprocessing steps). - - // no two ports on the same subnet (with some unknown ports) have the - // same address: - // all p0: unknownSubs, p1: unknown & p0.subnet, p2: p0.subnet - p1 | - // addr(p1) != addr(p2) - final Expression submembers = p0.join(subnet); - reqs.add(addr(p1).eq(addr(p2)).not().forAll(p0.oneOf(unknownSubs).and(p1.oneOf(submembers.intersection(unknown))).and(p2.oneOf(submembers.difference(p1))))); - - // all ports on the same subnet (with some unknown ports) have the same - // netid: - // all p0: unknownSubs, p1: p0.subnet | netid(p0) = netid(p1) - reqs.add(netid(p0).eq(netid(p1)).forAll(p0.oneOf(unknownSubs).and(p1.oneOf(submembers)))); - - // netids of subnets with unknown representatives don't overlap with - // netids of any other subnet: - // all p0: subreps & unknown, p1: subreps- p0 | not contains(p0, p1) and - // not contains(p1, p0) - reqs.add(contains(p0, p1).not().and(contains(p1, p0).not()).forAll(p0.oneOf(subreps.intersection(unknown)).and(p1.oneOf(subreps.difference(p0))))); - - return Formula.and(reqs); - } - - /** - * Returns a new universe that contains the given ports atoms, followed by - * Integer objects containing powers of 2 (1, 2, 4, ..., 2^31). - */ - private final Universe universe(Set ports) { - final List atoms = new ArrayList(ports.size() + 32); - atoms.addAll(ports); - for (int i = 0; i < 32; i++) { - atoms.add(Integer.valueOf(1 << i)); - } - return new Universe(atoms); - } - - /** - * Returns a tupleset that maps the given port atom to each non-zero bit in the - * given bit string. - * - * @return a tupleset that maps the given port atom to each non-zero bit in the - * given bit string. - */ - private final TupleSet portToBits(TupleFactory factory, String port, int bits) { - final TupleSet s = factory.noneOf(2); - for (int i = 0, max = 32 - Integer.numberOfLeadingZeros(bits); i < max; i++) { - if ((bits & (1 << i)) != 0) - s.add(factory.tuple(port, Integer.valueOf(1 << i))); - } - return s; - } - - /** - * Returns the bounds corresponding to the given ip address and subnet files. - * - * @return bounds corresponding to the given ip address and subnet files. - * @throws IOException if either of the files cannot be found or accessed - * @throws IllegalArgumentException if either of the files cannot be parsed - */ - public Bounds bounds(String ipAddrsFile, String subnetsFile) throws IOException { - final Map nodes = parseAddresses(ipAddrsFile); - final Map subnets = parseSubnets(subnetsFile, nodes); - - final Universe universe = universe(nodes.keySet()); - final Bounds bounds = new Bounds(universe); - final TupleFactory factory = universe.factory(); - - // bind the integers - for (int i = 0; i < 32; i++) { - bounds.boundExactly(1 << i, factory.setOf(Integer.valueOf(1 << i))); - } - - // bind the port relation exactly to the port names - bounds.boundExactly(port, factory.range(factory.tuple(universe.atom(0)), factory.tuple(universe.atom(nodes.keySet().size() - 1)))); - - // bind the unknown relation exactly to the port names of ports with - // unknown addresses or masks - final TupleSet unknownBound = factory.noneOf(1); - for (NetNode n : nodes.values()) { - if (!n.known()) { - unknownBound.add(factory.tuple(n.port)); - } - } - bounds.boundExactly(unknown, unknownBound); - - // bind the subnet relation exactly, choosing the first element of each - // subnet as the representative - final TupleSet subnetBound = factory.noneOf(2); - for (Map.Entry entry : subnets.entrySet()) { - final NetNode rep = entry.getKey(); - for (NetNode member : entry.getValue().members) { - subnetBound.add(factory.tuple(rep.port, member.port)); - } - } - bounds.boundExactly(subnet, subnetBound); - - // bind the addr relation so that each address is guaranteed to be - // between minAddr (121.96.0.0) and maxAddr (121.96.255.255), inclusive - final TupleSet lAddr = factory.noneOf(2), uAddr = factory.noneOf(2); - for (NetNode node : nodes.values()) { - if (node.varAddress) { // unknown address - lAddr.addAll(portToBits(factory, node.port, minAddr)); - uAddr.addAll(portToBits(factory, node.port, maxAddr)); - } else { // known address - final TupleSet portToAddrBits = portToBits(factory, node.port, node.address); - lAddr.addAll(portToAddrBits); - uAddr.addAll(portToAddrBits); - } - } - bounds.bound(addr, lAddr, uAddr); - - // bind the group and groupMask relations so that all ports with the - // same interface on the same subnet are guaranteed to have the same - // mask - final TupleSet lMask = factory.noneOf(2), uMask = factory.noneOf(2), groupBound = factory.noneOf(2); - for (Subnet sub : subnets.values()) { - for (Map.Entry> entry : sub.groups.entrySet()) { - final NetNode rep = entry.getKey(); - for (NetNode member : entry.getValue()) { - groupBound.add(factory.tuple(member.port, rep.port)); - nodes.remove(member.port); // remove a grouped member out of - // the addresses set - } - if (rep.varMask) { // unknown mask for the representative - uMask.addAll(portToBits(factory, rep.port, 31)); - } else { // known mask for the representative - final TupleSet portToMaskBits = portToBits(factory, rep.port, rep.mask); - lMask.addAll(portToMaskBits); - uMask.addAll(portToMaskBits); - } - } - } - - // bind the group and groupMask relations for ports that are not a part - // of any subnet - for (NetNode ungrouped : nodes.values()) { - groupBound.add(factory.tuple(ungrouped.port, ungrouped.port)); - if (ungrouped.varMask) { // unknown mask for the representative - uMask.addAll(portToBits(factory, ungrouped.port, 31)); - } else { // known mask for the representative - final TupleSet portToMaskBits = portToBits(factory, ungrouped.port, ungrouped.mask); - lMask.addAll(portToMaskBits); - uMask.addAll(portToMaskBits); - } - } - - bounds.bound(groupMask, lMask, uMask); - bounds.boundExactly(group, groupBound); - - // System.out.println("groupMask.size: " + uMask.size() + ", group.size: - // " + groupBound.size()); - // System.out.println("ports.size: " + bounds.upperBound(port).size() + - // ", unknown.size: " + unknownBound.size()); - return bounds; - - } - - /** - * Returns a string representation of the given bit string in the quad notation. - * - * @return a string representation of the given bit string in the quad notation. - */ - private static final String toQuad(int bits) { - return (bits >>> 24) + "." + ((bits >>> 16) & 255) + "." + ((bits >>> 8) & 255) + "." + (bits & 255) + "."; - } - - /** - * Displays an instance obtained with the given options. - * - * @requires inst != null and opt != null - */ - private final void display(Instance inst, Options opt) { - final Universe univ = inst.universe(); - final Evaluator eval = new Evaluator(inst, opt); - final TupleFactory factory = univ.factory(); - final List subnets = new ArrayList(); - - System.out.println("address\t\tnetwork id\tmask\tdevice-interface"); - for (int i = 0, ports = univ.size() - 32; i < ports; i++) { - final Object atom = univ.atom(i); - final Relation p = Relation.unary(atom.toString()); - inst.add(p, factory.setOf(atom)); - - System.out.print(toQuad(eval.evaluate(addr(p))) + "\t"); - System.out.print(toQuad(eval.evaluate(netid(p))) + "\t"); - System.out.print(eval.evaluate(implicitMask(p)) + "\t"); - System.out.println(p); - - final TupleSet members = eval.evaluate(subnet(p)); - if (!members.isEmpty()) - subnets.add(members); - } - - System.out.println("\nsubnets:"); - for (TupleSet sub : subnets) { - System.out.println(sub); - } - - } - - private static void usage() { - System.out.println("java examples.ConfigAssure "); - System.exit(1); - } - - /** - * Usage: java examples.ConfigAssure - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - try { - final ConfigAssure ca = new ConfigAssure(); - final Solver solver = new Solver(); - solver.options().setBitwidth(32); - solver.options().setSolver(SATFactory.MiniSat); - - final Formula formula = ca.requirements(); - final Bounds bounds = ca.bounds(args[0], args[1]); - - System.out.println("---explicit requirements (others are implicit in the bounds)---"); - System.out.println(PrettyPrinter.print(formula, 2)); - - System.out.println("\n---solving with config files " + args[0] + " and " + args[1] + "---"); - - final Solution sol = solver.solve(formula, bounds); - - System.out.println("\n---OUTCOME---"); - System.out.println(sol.outcome()); - - System.out.println("\n---STATS---"); - System.out.println(sol.stats()); - - if (sol.instance() != null) { - System.out.println("\n---INSTANCE--"); - ca.display(sol.instance(), solver.options()); - } - } catch (IOException ioe) { - ioe.printStackTrace(); - usage(); - } - } - - /** - * Parses the given ipAddresses file and returns a map that binds each port name - * in the file to its corresponding IPAddress record. - * - * @return a map that binds each port name in the given file to its - * corresponding IPAddress record. - * @throws IOException - */ - private static Map parseAddresses(String ipAddrsFile) throws IOException { - final Map nodes = new LinkedHashMap(); - final BufferedReader reader = new BufferedReader(new FileReader(new File(ipAddrsFile))); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - final NetNode node = new NetNode(line); - if (nodes.put(node.port, node) != null) - throw new IllegalArgumentException("Duplicate ip address specification: " + line); - } - return nodes; - } - - /** - * Returns a map of each representative IPAddress to its subnet, as specified by - * the given file and addresses. - * - * @return a map of each representative IPAddress to its subnet, as specified by - * the given file and addresses. - * @throws IOException - */ - private static Map parseSubnets(String subnetsFile, Map addresses) throws IOException { - final Map subnets = new LinkedHashMap(); - final BufferedReader reader = new BufferedReader(new FileReader(new File(subnetsFile))); - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - final Subnet sub = new Subnet(line, addresses); - subnets.put(sub.representative(), sub); - } - // check that all known representatives have disjoint netids - for (NetNode n1 : subnets.keySet()) { - for (NetNode n2 : subnets.keySet()) { - if (n1 != n2) { - if (n1.known() && n2.known() && (n1.contains(n2) || n2.contains(n1))) { - throw new IllegalArgumentException("Netids of members of different subnets cannot overlap: " + n1 + ".netid = " + n2 + ".netid"); - } - } - } - } - return subnets; - } - - /** - * A record containing the information parsed out of a Prolog ipAddress - * predicate, e.g. ipAddress('IOS_00008', 'Vlan608', int(0), mask(1)). - * - * @specfield device, interfaceName, port: String - * @specfield varAddress, varMask: boolean // true if the address (resp. mask) - * are variables - * @specfield address, mask: int // variable or constant identifier of the - * address or mask - * @invariant port = device + "-" + port - * @invariant !varAddress => (minAddr <= address <= maxAddr) - * @invariant !varMask => (0 <= mask <= 31) - * @author Emina Torlak - */ - private static class NetNode { - - final String device, interfaceName, port; - final boolean varAddress, varMask; - final int address, mask; - - private static final Pattern pAddress = Pattern.compile("ipAddress\\((.+), (.+), (\\S+), (\\S+)\\)\\."); - private static final Pattern pAddrVar = Pattern.compile("int\\((\\d+)\\)"); - private static final Pattern pMaskVar = Pattern.compile("mask\\((\\d+)\\)"); - - private static final Matcher mAddress = pAddress.matcher(""); - private static final Matcher mAddrVar = pAddrVar.matcher(""), mMaskVar = pMaskVar.matcher(""); - - /** - * Constructs an IP address object using the provided ipAddress string. - */ - NetNode(String addrString) { - if (mAddress.reset(addrString).matches()) { - this.device = mAddress.group(1); - this.interfaceName = mAddress.group(2); - this.port = device + "-" + interfaceName; - if (mAddrVar.reset(mAddress.group(3)).matches()) { - this.varAddress = true; - this.address = Integer.parseInt(mAddrVar.group(1)); - } else { - this.varAddress = false; - this.address = parseConstant(mAddress.group(3), minAddr, maxAddr, "Expected the address to be a variable spec, int(), or a number between " + minAddr + " and " + maxAddr + ", inclusive: " + addrString); - } - if (mMaskVar.reset(mAddress.group(4)).matches()) { - this.varMask = true; - this.mask = Integer.parseInt(mMaskVar.group(1)); - } else { - this.varMask = false; - this.mask = parseConstant(mAddress.group(4), 0, 31, "Expected the mask to be a variable spec, mask(), or a number between 0 and 31, inclusive: " + addrString); - } - } else { - throw new IllegalArgumentException("Unrecognized IP Address format: " + addrString); - } - } - - /** - * Returns the netid of this port. - * - * @requires this.known - * @return this.address & (-1<= other.mask and (this.address & (-1<= other.mask && (this.address & (-1 << mask)) == (other.address & (-1 << mask)); - } - - /** - * Returns the integer value embedded in the given string iff it is between min - * and max, inclusive. Otherwise throws an illegal argument exception with the - * given message. - */ - private static int parseConstant(String value, int min, int max, String msg) { - try { - final int val = Integer.parseInt(value); - if (min <= val && val <= max) { - return val; - } - } catch (NumberFormatException nfe) {} - throw new IllegalArgumentException(msg); - } - } - - /** - * A record containing the information parsed out of a Prolog subnet predicate, - * e.g. subnet(['IOS_00091'-'Vlan820', 'IOS_00092'-'Vlan820', - * 'IOS_00096'-'FastEthernet0/0']). - * - * @specfield member: some IPAddress // members of this subnet - * @specfield groups: member one-> member - * @specfield representative: member - * @invariant all rep: groups.member, m: groups[rep] | rep.interfaceName = - * m.interfaceName and (!rep.varMask => !m.varMask else (m.varMask => - * m.mask = rep.mask)) - * @invariant all disj m1, m2: member | (!m1.varAddress and !m2.varAddress) => - * m1.address != m2.address - * @invariant all disj m1, m2: member | (!m1.varAddress and !m2.varAddress and - * !m1.varMask and !m2.varMask) => m1.netid() = m2.netid() - * @invariant (representative.varAddress && representative.varMask) => (all m: - * member | m.varAddress && m.varMask) - * @author Emina Torlak - */ - private static class Subnet { - - final Set members; - final Map> groups; - - private static final Pattern pSubnet = Pattern.compile("subnet\\(\\[(.+)\\]\\)\\."); - private static final Pattern pSubMember = Pattern.compile(",*\\s*([^,]+)"); - private static final Matcher mSubnet = pSubnet.matcher(""), mSubMember = pSubMember.matcher(""); - - /** - * Constructs a subnet object out of the given subnet string and addresses. - */ - Subnet(String subnetString, Map addresses) { - this.members = members(subnetString, addresses); - this.groups = groups(subnetString, members); - } - - /** - * Returns the first net node encountered during parsing with known address and - * mask, if one exists. Otherwise, returns the first net node encountered during - * parsing. - * - * @return this.representative - */ - NetNode representative() { - for (NetNode n : members) { - if (!n.varAddress && !n.varMask) - return n; - } - return members.iterator().next(); - } - - /** - * Returns the subnet members specified by the given subnet string. - * - * @return subnet members specified by the given subnet string. - */ - private static Set members(String subnetString, Map addresses) { - if (mSubnet.reset(subnetString).matches()) { - final Set members = new LinkedHashSet(); - mSubMember.reset(mSubnet.group(1)); - while (mSubMember.find()) { - final String port = mSubMember.group(1); - if (addresses.containsKey(port)) { - members.add(addresses.get(port)); - } else { - throw new IllegalArgumentException("Unrecognized port " + port + " in " + subnetString); - } - } - if (members.isEmpty()) { - throw new IllegalArgumentException("Subnet spec is empty: " + subnetString); - } - for (NetNode n1 : members) { - for (NetNode n2 : members) { - if (n1 != n2) { - if (!n1.varAddress && !n2.varAddress) { - if (n1.address == n2.address) { - throw new IllegalArgumentException("Two ports on the same subnet must have distinct addresses: " + subnetString + " (" + n1.port + ".address = " + n2.port + ".address)"); - } - if (!n1.varMask && !n2.varMask && n1.netid() != n2.netid()) { - throw new IllegalArgumentException("Two ports on the same subnet must have the same net id: " + subnetString + " (" + n1.port + ".netid != " + n2.port + ".netid)"); - } - } - } - } - } - return Collections.unmodifiableSet(members); - } else { - throw new IllegalArgumentException("Unrecognized subnet format: " + subnetString); - } - } - - /** - * Returns a grouping of the given subnet members according to their group - * representatives. - * - * @return a grouping of the given subnet members according to their group - * representatives. - */ - private static Map> groups(String subnetString, Set members) { - final Map> byInterface = new LinkedHashMap>(); - for (NetNode addr : members) { - Set group = byInterface.get(addr.interfaceName); - if (group == null) { - group = new LinkedHashSet(); - byInterface.put(addr.interfaceName, group); - } - group.add(addr); - - } - final Map> byRep = new LinkedHashMap>(); - for (Set group : byInterface.values()) { - NetNode rep = null; - for (NetNode ad : group) { - if (rep == null || (rep.varMask && !ad.varMask)) { - rep = ad; - } else { - if (!ad.varMask && rep.mask != ad.mask) { - throw new IllegalArgumentException("All members of a subnet with the same interface must have the same mask: " + subnetString); - } - } - } - - byRep.put(rep, Collections.unmodifiableSet(group)); - } - return Collections.unmodifiableMap(byRep); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/IntConstraints.class b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/IntConstraints.class deleted file mode 100644 index fb206d1f5..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/IntConstraints.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/IntConstraints.java b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/IntConstraints.java deleted file mode 100644 index 4a3f9243b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/IntConstraints.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package examples.netconfig; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A Kodkod encoding of the integer constraint problem for ConfigAssure. It is - * of the form a1 <= v1 <= a2 <= v2 .... a1000<=v1000 where each vi is a - * variable and each ai is a constant. The ais are 10 apart, starting at - * 3232226033 and ending at 3232236033. - * - * @author Emina Torlak - */ -public final class IntConstraints { - - private final Relation[] var; - private final int low = (int) 3232226033L, high = (int) 3232236033L; - - /** - * Constructs a new instance of the {@link IntConstraints} problem. - */ - public IntConstraints() { - var = new Relation[1000]; - for (int i = 0; i < 1000; i++) { - var[i] = Relation.unary("var_" + (i + 1)); - } - } - - /** - * Returns a bounds for the problem. - */ - public final Bounds bounds() { - final List atoms = new ArrayList(14); - for (int i = 0; i < 32; i++) { - atoms.add(Integer.valueOf(1 << i)); - } - - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - // bound the integers - for (int i = 0; i < 32; i++) { - b.boundExactly(1 << i, f.setOf(Integer.valueOf(1 << i))); - } - - // bound the relations, making sure to specify the partial - // instance based on the low/high range for each variable. - for (int i = 0; i < 1000; i++) { - TupleSet lower = f.noneOf(1), upper = f.noneOf(1); - int min = low + i * 10, max = min + 10, bit = 31; - - // get the common high order bit pattern into lower/upper bound - // constraints - while (bit >= 0) { - int bitVal = 1 << bit; - if ((min & bitVal) == (max & bitVal)) { - if ((min & bitVal) != 0) { - Tuple bitTuple = f.tuple(Integer.valueOf(bitVal)); - lower.add(bitTuple); - upper.add(bitTuple); - } - } else { - break; // get out of the loop as soon as patterns diverge - } - bit--; - } - - // the bits on which min/max disagree should be variables, so put - // them into upper bound but not lower - while (bit >= 0) { - upper.add(f.tuple(Integer.valueOf(1 << bit))); - bit--; - } - - b.bound(var[i], lower, upper); - - } - - return b; - } - - /** - * Returns the formula a1 <= v1 <= a2 <= v2 .... a1000<=v1000 - * - * @return the formula - */ - public final Formula formula() { - final List constraints = new ArrayList(2000); - final List constants = new ArrayList(1001); - for (int i = low; i <= high; i += 10) { - constants.add(IntConstant.constant(i)); - } - - for (int i = 0; i < 1000; i++) { - IntExpression varExpr = var[i].sum(); // convert to primitive int - constraints.add(constants.get(i).lte(varExpr)); // a_i <= v_i - constraints.add(varExpr.lte(constants.get(i + 1))); // v_i <= - // a_(i+1) - } - - return Formula.and(constraints); - } - - /** - * Prints the solution to the screen. - */ - private final void print(Solution sol, Options options) { - System.out.println(sol.stats()); - final Evaluator eval = new Evaluator(sol.instance(), options); - final long mask = -1L >>> 32; - for (int i = 0; i < 1000; i++) { - long min = (low + 10 * i) & mask, max = (min + 10) & mask; - long result = eval.evaluate(var[i].sum()) & mask; - System.out.println(min + " <= [var_" + (i + 1) + "=" + result + "] <= " + max); - } - } - - /** - * Usage: java examples.IntConstraints - */ - public static void main(String[] args) { - final IntConstraints model = new IntConstraints(); - final Bounds bounds = model.bounds(); - final Formula formula = model.formula(); - - final Solver solver = new Solver(); - solver.options().setBitwidth(32); - solver.options().setSolver(SATFactory.MiniSat); - - final Solution sol = solver.solve(formula, bounds); - model.print(sol, solver.options()); - - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Netconfig.class b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Netconfig.class deleted file mode 100644 index 338cabfb1..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Netconfig.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Netconfig.java b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Netconfig.java deleted file mode 100644 index ee5596779..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/Netconfig.java +++ /dev/null @@ -1,341 +0,0 @@ -package examples.netconfig; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A kodkod encoding of netconfig.als: - * - *
- *
- * module internal/netconfig2 open util/ordering[Time] as tick
- *
- * sig Time {}
- *
- * abstract sig Site {}
- * sig HQ, Sub extends Site {}
- *
- * sig Router {
- *  site: Site,
- *  satellite: Router -> Time,
- *  lineOfSight: Router -> Time
- * }
- *
- * pred invariants() {
- *  -- every site has at least one Router Site in Router.site
- *  -- links are symmetric and non-reflexive
- *  all t: Time | lineOfSight.t = ~(lineOfSight.t) && no lineOfSight.t & iden
- *  all t: Time | satellite.t = ~(satellite.t) && no satellite.t & iden
- *
- *  -- no two Routers are connected with two both a satellite and lineOfSight
- *  -- link at the same Time
- *  all t: Time | no satellite.t & lineOfSight.t
- *
- *  -- there is at most one satellite link at any given Time: a resource constraint
- *  all t: Time | no satellite || some r1, r2: Router | r1->r2 + r2->r1 = satellite.t
- * }
- *
- * pred subsConnectedToHQ(endTime: Time) {
- *  -- every Sub location is connected to an HQ location at the given Time
- *  all subRouter: site.Sub | some hqRouter: site.HQ |
- *   subRouter->hqRouter in (satellite + lineOfSight).endTime
- * }
- *
- * pred connectedSites(sites: set Site, endTime: Time) {
- *  -- all sites in the given set are connected to each other at the given Time
- *  all s: sites | some r: site.s |
- *   sites - s in (r.^((satellite + lineOfSight).endTime)).site
- * }
- *
- * pred addSatelliteLink(r1, r2: Router, t: Time) { r1->r2 in satellite.t }
- *
- * pred addLineOfSightLink(r1, r2: Router, t: Time) {
- *  r1->r2 in satellite.tick/prev(t) && r1->r2 in lineOfSight.t }
- *
- * pred continuedConnection(r1, r2: Router, t: Time) {
- *  r1->r2 & lineOfSight.tick/prev(t) = r1->r2 & lineOfSight.t }
- *
- * pred lostConnection(r1, r2: Router, t: Time) {
- *  r1->r2 in lineOfSight.tick/prev(t) && no r1->r2 & lineOfSight.t }
- *
- * pred traces() {
- *  all r1, r2: Router, t: Time |
- *   addSatelliteLink(r1, r2, t) || addLineOfSightLink(r1, r2, t) ||
- *   continuedConnection(r1, r2, t) || lostConnection(r1, r2, t) }
- *
- * pred show() {
- *  invariants() && subsConnectedToHQ(tick/last()) &&
- *  connectedSites(Site, tick/last()) && traces() }
- *
- * --75.03 secs with Berkmin, p cnf 36512 499783
- * run show for exactly 1 HQ, exactly 9 Sub, exactly 10 Router, exactly 9 Time
- * 
- * - * @author Emina Torlak - */ -public class Netconfig { - - // sigs - private final Relation Time, Router, Site, HQ, Sub; - // fields - private final Relation site, satellite, lineOfSight, start, end, tick; - - /** - * Constructs an instance of the Netconfig problem. - */ - public Netconfig() { - Time = Relation.unary("Time"); - start = Relation.unary("start"); - end = Relation.unary("end"); - tick = Relation.binary("tick"); - Router = Relation.unary("Router"); - Site = Relation.unary("Site"); - HQ = Relation.unary("HQ"); - Sub = Relation.unary("Sub"); - site = Relation.binary("site"); - satellite = Relation.ternary("satellite"); - lineOfSight = Relation.ternary("lineOfSight"); - } - - /** - * Returns a formula stating that r is symmetric and non reflexive. - * - * @requires r.arity = 2 - * @return r = ~r && no r & iden - */ - private final Formula symmNonRefl(Expression r) { - assert r.arity() == 2; - return r.eq(r.transpose()).and(r.intersection(Expression.IDEN).no()); - } - - /** - * Returns the constraints implicit in signature and field declarations. - * - * @return the constraints implicit in signature and field declarations. - */ - public Formula declarations() { - // HQ + Sub in Site && no HQ & Sub - final Formula hqSub = HQ.union(Sub).in(Site).and(HQ.intersection(Sub).no()); - // site is a function from Router to Site - final Formula siteFun = site.function(Router, Site); - // satellite in Router->Router->Time && lineOfSight in - // Router->Router->Time - final Expression rrt = Router.product(Router).product(Time); - final Formula satLos = satellite.in(rrt).and(lineOfSight.in(rrt)); - // tick is a total ordering on time - final Formula tord = tick.totalOrder(Time, start, end); - return hqSub.and(siteFun).and(satLos).and(tord); - - } - - /** - * Returns the invariants predicate. - * - * @return invariants - */ - public Formula invariants() { - final Variable t = Variable.unary("t"); - - final Expression losAtT = lineOfSight.join(t); - final Expression satAtT = satellite.join(t); - final Formula symNonRefl = symmNonRefl(losAtT).and(symmNonRefl(satAtT)); - final Formula noSatAndLos = satAtT.intersection(losAtT).no(); - - final Variable r1 = Variable.unary("r1"); - final Variable r2 = Variable.unary("r2"); - final Expression productUnion = r1.product(r2).union(r2.product(r1)); - final Formula someSatAtT = productUnion.eq(satAtT).forSome(r1.oneOf(Router).and(r2.oneOf(Router))); - final Formula loneSatAtT = satellite.no().or(someSatAtT); - - return symNonRefl.and(noSatAndLos).and(loneSatAtT).forAll(t.oneOf(Time)); - } - - /** - * Returns the subsConnectedToHQ predicate. - * - * @return subsConnectedToHQ } - */ - public Formula subsConnectedToHQ(Expression endTime) { - final Variable subRouter = Variable.unary("subRouter"); - final Variable hqRouter = Variable.unary("hqRouter"); - final Formula f = subRouter.product(hqRouter).in(satellite.union(lineOfSight).join(endTime)); - return f.forSome(hqRouter.oneOf(site.join(HQ))).forAll(subRouter.oneOf(site.join(Sub))); - } - - /** - * Returns the connectedSites predicate. - * - * @return connectedSites - */ - public Formula connectedSites(Expression sites, Expression endTime) { - final Variable s = Variable.unary("s"); - final Variable r = Variable.unary("r"); - final Expression linksAtEndTime = satellite.union(lineOfSight).join(endTime); - final Formula f = sites.difference(s).in(r.join(linksAtEndTime.closure()).join(site)); - return f.forSome(r.oneOf(site.join(s))).forAll(s.oneOf(sites)); - } - - /** - * Returns the addSatelliteLink predicate - * - * @return addSatelliteLink - */ - public Formula addSatelliteLink(Expression r1, Expression r2, Expression t) { - return r1.product(r2).in(satellite.join(t)); - } - - /** - * Returns the addLineOfSightLink predicate. - * - * @return addLineOfSightLink - */ - public Formula addLineOfSightLink(Expression r1, Expression r2, Expression t) { - final Expression link = r1.product(r2); - return link.in(satellite.join(tick.join(t))).and(link.in(lineOfSight.join(t))); - } - - /** - * Returns the continuedConnection predicate. - * - * @return continuedConnection - */ - public Formula continuedConnection(Expression r1, Expression r2, Expression t) { - final Expression link = r1.product(r2); - return link.intersection(lineOfSight.join(tick.join(t))).eq(link.intersection(lineOfSight.join(t))); - } - - /** - * Returns the lostConnection predicate. - * - * @return lostConnection - */ - public Formula lostConnection(Expression r1, Expression r2, Expression t) { - final Expression link = r1.product(r2); - return link.in(lineOfSight.join(tick.join(t))).and(link.intersection(lineOfSight.join(t)).no()); - } - - /** - * Returns the traces predicate. - * - * @return traces - */ - public Formula traces() { - final Variable r1 = Variable.unary("r1"); - final Variable r2 = Variable.unary("r2"); - final Variable t = Variable.unary("t"); - - final Formula f = addSatelliteLink(r1, r2, t).or(addLineOfSightLink(r1, r2, t)).or(continuedConnection(r1, r2, t)).or(lostConnection(r1, r2, t)); - - return f.forAll(r1.oneOf(Router).and(r2.oneOf(Router)).and(t.oneOf(Time))); - - } - - /** - * Returns the show predicate. - * - * @return show - */ - public Formula show() { - return declarations().and(invariants()).and(subsConnectedToHQ(end)).and(connectedSites(Site, end)).and(traces()); - } - - /** - * Returns a bounds object that constructs the 'scope' for analyzing the - * commands, using the given values for the number of sites, routers, and the - * length of time. - * - * @requires all arguments are positive and hqNum <= siteNum - * @return a bounds for the model - */ - public Bounds bounds(int siteNum, int hqNum, int routerNum, int timeLength) { - assert siteNum > 0 && hqNum > 0 && hqNum <= siteNum && routerNum > 0 && timeLength > 0; - final List atoms = new ArrayList(siteNum + routerNum + timeLength); - for (int i = 0; i < siteNum; i++) { - atoms.add("Site" + i); - } - for (int i = 0; i < routerNum; i++) { - atoms.add("Router" + i); - } - for (int i = 0; i < timeLength; i++) { - atoms.add("Time" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - - final Bounds b = new Bounds(u); - - final String site0 = "Site0"; - final String siteN = "Site" + (siteNum - 1); - - final TupleSet sBound = f.range(f.tuple(site0), f.tuple(siteN)); - b.boundExactly(Site, sBound); - b.boundExactly(HQ, f.range(f.tuple(site0), f.tuple("Site" + (hqNum - 1)))); - if (hqNum < siteNum) { - b.boundExactly(Sub, f.range(f.tuple("Site" + hqNum), f.tuple(siteN))); - } else { - b.bound(Sub, f.noneOf(1)); - } - - final TupleSet tBound = f.range(f.tuple("Time0"), f.tuple("Time" + (timeLength - 1))); - b.bound(Time, tBound); - b.bound(start, tBound); - b.bound(end, tBound); - b.bound(tick, tBound.product(tBound)); - - final TupleSet rBound = f.range(f.tuple("Router0"), f.tuple("Router" + (routerNum - 1))); - b.boundExactly(Router, rBound); - // b.bound(site, rBound.product(sBound)); - b.bound(satellite, rBound.product(rBound).product(tBound)); - b.bound(lineOfSight, b.upperBound(satellite)); - - assert siteNum == routerNum; - final TupleSet siteBound = f.noneOf(2); - for (int i = 0; i < siteNum; i++) - siteBound.add(f.tuple("Router" + i, "Site" + i)); - b.boundExactly(site, siteBound);// rBound.product(sBound)); - - return b; - } - - private static final void usage() { - System.out.println("Usage: java examples.Netconfig [# sites] [# hq] [# routers] [# time steps]"); - System.exit(1); - } - - /** - * Usage: java examples.Netconfig [# sites] [# hq] [# routers] [# time steps] - */ - public static void main(String[] args) { - if (args.length < 4) - usage(); - final Netconfig model = new Netconfig(); - final Solver solver = new Solver(); - // solver.options().setSolver(SATFactory.ZChaffMincost); - solver.options().setSolver(SATFactory.MiniSat); - try { - final Formula show = model.show(); - final Solution sol = solver.solve(show, model.bounds(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]))); - // System.out.println(show); - // System.out.println("p cnf " + - // (solver.numberOfIntermediateVariables()+solver.numberOfPrimaryVariables()) - // + " " + solver.numberOfClauses()); - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/all-variables.txt b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/all-variables.txt deleted file mode 100644 index b85978358..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/all-variables.txt +++ /dev/null @@ -1,170 +0,0 @@ -ipAddress('IOS_00008', 'Vlan608', int(0), mask(1)). -ipAddress('IOS_00009', 'Vlan608', int(2), mask(3)). -ipAddress('IOS_00010', 'GigabitEthernet4/16', int(4), mask(5)). -ipAddress('IOS_00011', 'GigabitEthernet0/2', int(6), mask(7)). -ipAddress('IOS_00012', 'POS5/0', int(8), mask(9)). -ipAddress('IOS_00022', 'Vlan172', int(10), mask(11)). -ipAddress('IOS_00023', 'Vlan172', int(12), mask(13)). -ipAddress('IOS_00026', 'Vlan701', int(14), mask(15)). -ipAddress('IOS_00026', 'Vlan702', int(16), mask(17)). -ipAddress('IOS_00026', 'Vlan703', int(18), mask(19)). -ipAddress('IOS_00026', 'Vlan704', int(20), mask(21)). -ipAddress('IOS_00027', 'Hssi1/0', int(22), mask(23)). -ipAddress('IOS_00028', 'Serial1/0', int(24), mask(25)). -ipAddress('IOS_00037', 'Vlan701', int(26), mask(27)). -ipAddress('IOS_00037', 'Vlan702', int(28), mask(29)). -ipAddress('IOS_00037', 'Vlan703', int(30), mask(31)). -ipAddress('IOS_00037', 'Vlan704', int(32), mask(33)). -ipAddress('IOS_00037', 'Vlan790', int(34), mask(35)). -ipAddress('IOS_00038', 'Vlan701', int(36), mask(37)). -ipAddress('IOS_00038', 'Vlan702', int(38), mask(39)). -ipAddress('IOS_00038', 'Vlan703', int(40), mask(41)). -ipAddress('IOS_00038', 'Vlan704', int(42), mask(43)). -ipAddress('IOS_00038', 'Vlan790', int(44), mask(45)). -ipAddress('IOS_00039', 'Hssi1/0', int(46), mask(47)). -ipAddress('IOS_00039', 'Tunnel160', int(48), mask(49)). -ipAddress('IOS_00040', 'Serial1/0', int(50), mask(51)). -ipAddress('IOS_00044', 'Vlan701', int(52), mask(53)). -ipAddress('IOS_00044', 'Vlan702', int(54), mask(55)). -ipAddress('IOS_00044', 'Vlan703', int(56), mask(57)). -ipAddress('IOS_00044', 'Vlan704', int(58), mask(59)). -ipAddress('IOS_00044', 'Vlan705', int(60), mask(61)). -ipAddress('IOS_00044', 'Vlan706', int(62), mask(63)). -ipAddress('IOS_00044', 'Vlan707', int(64), mask(65)). -ipAddress('IOS_00044', 'Vlan708', int(66), mask(67)). -ipAddress('IOS_00044', 'Vlan709', int(68), mask(69)). -ipAddress('IOS_00044', 'Vlan710', int(70), mask(71)). -ipAddress('IOS_00045', 'Vlan701', int(72), mask(73)). -ipAddress('IOS_00045', 'Vlan702', int(74), mask(75)). -ipAddress('IOS_00045', 'Vlan703', int(76), mask(77)). -ipAddress('IOS_00045', 'Vlan704', int(78), mask(79)). -ipAddress('IOS_00045', 'Vlan705', int(80), mask(81)). -ipAddress('IOS_00045', 'Vlan706', int(82), mask(83)). -ipAddress('IOS_00045', 'Vlan707', int(84), mask(85)). -ipAddress('IOS_00045', 'Vlan708', int(86), mask(87)). -ipAddress('IOS_00045', 'Vlan709', int(88), mask(89)). -ipAddress('IOS_00045', 'Vlan710', int(90), mask(91)). -ipAddress('IOS_00046', 'Hssi1/0', int(92), mask(93)). -ipAddress('IOS_00047', 'Hssi1/0', int(94), mask(95)). -ipAddress('IOS_00070', 'Vlan701', int(96), mask(97)). -ipAddress('IOS_00070', 'Vlan702', int(98), mask(99)). -ipAddress('IOS_00070', 'Vlan703', int(100), mask(101)). -ipAddress('IOS_00070', 'Vlan704', int(102), mask(103)). -ipAddress('IOS_00070', 'Vlan705', int(104), mask(105)). -ipAddress('IOS_00070', 'Vlan706', int(106), mask(107)). -ipAddress('IOS_00070', 'Vlan707', int(108), mask(109)). -ipAddress('IOS_00070', 'Vlan708', int(110), mask(111)). -ipAddress('IOS_00071', 'Hssi1/0', int(112), mask(113)). -ipAddress('IOS_00072', 'Serial1/0', int(114), mask(115)). -ipAddress('IOS_00081', 'Vlan701', int(116), mask(117)). -ipAddress('IOS_00081', 'Vlan702', int(118), mask(119)). -ipAddress('IOS_00081', 'Vlan703', int(120), mask(121)). -ipAddress('IOS_00081', 'Vlan704', int(122), mask(123)). -ipAddress('IOS_00082', 'Hssi1/0', int(124), mask(125)). -ipAddress('IOS_00083', 'Serial1/0', int(126), mask(127)). -ipAddress('IOS_00091', 'Loopback0', int(128), mask(129)). -ipAddress('IOS_00091', 'Vlan543', int(130), mask(131)). -ipAddress('IOS_00091', 'Vlan544', int(132), mask(133)). -ipAddress('IOS_00091', 'Vlan545', int(134), mask(135)). -ipAddress('IOS_00091', 'Vlan546', int(136), mask(137)). -ipAddress('IOS_00091', 'Vlan547', int(138), mask(139)). -ipAddress('IOS_00091', 'Vlan548', int(140), mask(141)). -ipAddress('IOS_00091', 'Vlan549', int(142), mask(143)). -ipAddress('IOS_00091', 'Vlan550', int(144), mask(145)). -ipAddress('IOS_00091', 'Vlan551', int(146), mask(147)). -ipAddress('IOS_00091', 'Vlan552', int(148), mask(149)). -ipAddress('IOS_00091', 'Vlan553', int(150), mask(151)). -ipAddress('IOS_00091', 'Vlan554', int(152), mask(153)). -ipAddress('IOS_00091', 'Vlan555', int(154), mask(155)). -ipAddress('IOS_00091', 'Vlan556', int(156), mask(157)). -ipAddress('IOS_00091', 'Vlan557', int(158), mask(159)). -ipAddress('IOS_00091', 'Vlan558', int(160), mask(161)). -ipAddress('IOS_00091', 'Vlan559', int(162), mask(163)). -ipAddress('IOS_00091', 'Vlan560', int(164), mask(165)). -ipAddress('IOS_00091', 'Vlan561', int(166), mask(167)). -ipAddress('IOS_00091', 'Vlan562', int(168), mask(169)). -ipAddress('IOS_00091', 'Vlan563', int(170), mask(171)). -ipAddress('IOS_00091', 'Vlan564', int(172), mask(173)). -ipAddress('IOS_00091', 'Vlan565', int(174), mask(175)). -ipAddress('IOS_00091', 'Vlan566', int(176), mask(177)). -ipAddress('IOS_00091', 'Vlan567', int(178), mask(179)). -ipAddress('IOS_00091', 'Vlan568', int(180), mask(181)). -ipAddress('IOS_00091', 'Vlan569', int(182), mask(183)). -ipAddress('IOS_00091', 'Vlan570', int(184), mask(185)). -ipAddress('IOS_00091', 'Vlan571', int(186), mask(187)). -ipAddress('IOS_00091', 'Vlan572', int(188), mask(189)). -ipAddress('IOS_00091', 'Vlan573', int(190), mask(191)). -ipAddress('IOS_00091', 'Vlan574', int(192), mask(193)). -ipAddress('IOS_00091', 'Vlan575', int(194), mask(195)). -ipAddress('IOS_00091', 'Vlan576', int(196), mask(197)). -ipAddress('IOS_00091', 'Vlan577', int(198), mask(199)). -ipAddress('IOS_00091', 'Vlan580', int(200), mask(201)). -ipAddress('IOS_00091', 'Vlan581', int(202), mask(203)). -ipAddress('IOS_00091', 'Vlan582', int(204), mask(205)). -ipAddress('IOS_00091', 'Vlan583', int(206), mask(207)). -ipAddress('IOS_00091', 'Vlan584', int(208), mask(209)). -ipAddress('IOS_00091', 'Vlan585', int(210), mask(211)). -ipAddress('IOS_00091', 'Vlan586', int(212), mask(213)). -ipAddress('IOS_00091', 'Vlan587', int(214), mask(215)). -ipAddress('IOS_00091', 'Vlan588', int(216), mask(217)). -ipAddress('IOS_00091', 'Vlan800', int(218), mask(219)). -ipAddress('IOS_00091', 'Vlan820', int(220), mask(221)). -ipAddress('IOS_00091', 'Vlan837', int(222), mask(223)). -ipAddress('IOS_00091', 'Vlan838', int(224), mask(225)). -ipAddress('IOS_00091', 'Vlan839', int(226), mask(227)). -ipAddress('IOS_00091', 'Vlan840', int(228), mask(229)). -ipAddress('IOS_00091', 'Vlan885', int(230), mask(231)). -ipAddress('IOS_00092', 'Vlan543', int(232), mask(233)). -ipAddress('IOS_00092', 'Vlan544', int(234), mask(235)). -ipAddress('IOS_00092', 'Vlan545', int(236), mask(237)). -ipAddress('IOS_00092', 'Vlan546', int(238), mask(239)). -ipAddress('IOS_00092', 'Vlan547', int(240), mask(241)). -ipAddress('IOS_00092', 'Vlan548', int(242), mask(243)). -ipAddress('IOS_00092', 'Vlan549', int(244), mask(245)). -ipAddress('IOS_00092', 'Vlan550', int(246), mask(247)). -ipAddress('IOS_00092', 'Vlan551', int(248), mask(249)). -ipAddress('IOS_00092', 'Vlan552', int(250), mask(251)). -ipAddress('IOS_00092', 'Vlan553', int(252), mask(253)). -ipAddress('IOS_00092', 'Vlan554', int(254), mask(255)). -ipAddress('IOS_00092', 'Vlan555', int(256), mask(257)). -ipAddress('IOS_00092', 'Vlan556', int(258), mask(259)). -ipAddress('IOS_00092', 'Vlan557', int(260), mask(261)). -ipAddress('IOS_00092', 'Vlan558', int(262), mask(263)). -ipAddress('IOS_00092', 'Vlan559', int(264), mask(265)). -ipAddress('IOS_00092', 'Vlan560', int(266), mask(267)). -ipAddress('IOS_00092', 'Vlan561', int(268), mask(269)). -ipAddress('IOS_00092', 'Vlan562', int(270), mask(271)). -ipAddress('IOS_00092', 'Vlan563', int(272), mask(273)). -ipAddress('IOS_00092', 'Vlan564', int(274), mask(275)). -ipAddress('IOS_00092', 'Vlan565', int(276), mask(277)). -ipAddress('IOS_00092', 'Vlan566', int(278), mask(279)). -ipAddress('IOS_00092', 'Vlan567', int(280), mask(281)). -ipAddress('IOS_00092', 'Vlan568', int(282), mask(283)). -ipAddress('IOS_00092', 'Vlan569', int(284), mask(285)). -ipAddress('IOS_00092', 'Vlan570', int(286), mask(287)). -ipAddress('IOS_00092', 'Vlan571', int(288), mask(289)). -ipAddress('IOS_00092', 'Vlan572', int(290), mask(291)). -ipAddress('IOS_00092', 'Vlan573', int(292), mask(293)). -ipAddress('IOS_00092', 'Vlan574', int(294), mask(295)). -ipAddress('IOS_00092', 'Vlan575', int(296), mask(297)). -ipAddress('IOS_00092', 'Vlan576', int(298), mask(299)). -ipAddress('IOS_00092', 'Vlan577', int(300), mask(301)). -ipAddress('IOS_00092', 'Vlan580', int(302), mask(303)). -ipAddress('IOS_00092', 'Vlan581', int(304), mask(305)). -ipAddress('IOS_00092', 'Vlan582', int(306), mask(307)). -ipAddress('IOS_00092', 'Vlan583', int(308), mask(309)). -ipAddress('IOS_00092', 'Vlan584', int(310), mask(311)). -ipAddress('IOS_00092', 'Vlan585', int(312), mask(313)). -ipAddress('IOS_00092', 'Vlan586', int(314), mask(315)). -ipAddress('IOS_00092', 'Vlan587', int(316), mask(317)). -ipAddress('IOS_00092', 'Vlan588', int(318), mask(319)). -ipAddress('IOS_00092', 'Vlan800', int(320), mask(321)). -ipAddress('IOS_00092', 'Vlan820', int(322), mask(323)). -ipAddress('IOS_00092', 'Vlan837', int(324), mask(325)). -ipAddress('IOS_00092', 'Vlan838', int(326), mask(327)). -ipAddress('IOS_00092', 'Vlan839', int(328), mask(329)). -ipAddress('IOS_00092', 'Vlan840', int(330), mask(331)). -ipAddress('IOS_00092', 'Vlan885', int(332), mask(333)). -ipAddress('IOS_00094', 'GigabitEthernet4/44', int(334), mask(335)). -ipAddress('IOS_00096', 'FastEthernet0/0', int(336), mask(337)). -ipAddress('IOS_00096', 'Loopback1', int(338), mask(339)). \ No newline at end of file diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/no-variables-large.txt b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/no-variables-large.txt deleted file mode 100644 index 6efdcdcab..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/no-variables-large.txt +++ /dev/null @@ -1,830 +0,0 @@ -ipAddress('IOS_00022', 'Vlan172', 2036334608, 4). -ipAddress('IOS_00023', 'Vlan172', 2036334610, 4). -ipAddress('IOS_00094', 'GigabitEthernet4/44', 2036334625, 4). -ipAddress('IOS_00010', 'GigabitEthernet4/16', 2036334641, 4). -ipAddress('IOS_00011', 'GigabitEthernet0/2', 2036334642, 4). -ipAddress('IOS_00039', 'Tunnel160', 2036334657, 4). -ipAddress('IOS_00047', 'Hssi1/0', 2036334673, 4). -ipAddress('IOS_00071', 'Hssi1/0', 2036334689, 4). -ipAddress('IOS_00072', 'Serial1/0', 2036334705, 4). -ipAddress('IOS_00012', 'POS5/0', 2036334721, 4). -ipAddress('IOS_00082', 'Hssi1/0', 2036334737, 4). -ipAddress('IOS_00083', 'Serial1/0', 2036334753, 4). -ipAddress('IOS_00027', 'Hssi1/0', 2036334769, 4). -ipAddress('IOS_00028', 'Serial1/0', 2036334785, 4). -ipAddress('IOS_00039', 'Hssi1/0', 2036334801, 4). -ipAddress('IOS_00040', 'Serial1/0', 2036334817, 4). -ipAddress('IOS_00046', 'Hssi1/0', 2036334833, 4). -ipAddress('IOS_00008', 'Vlan608', 2036334849, 4). -ipAddress('IOS_00009', 'Vlan608', 2036334850, 4). -ipAddress('IOS_00026', 'Vlan701', 2036334865, 4). -ipAddress('IOS_00026', 'Vlan702', 2036334881, 4). -ipAddress('IOS_00026', 'Vlan703', 2036334897, 4). -ipAddress('IOS_00026', 'Vlan704', 2036334913, 4). -ipAddress('IOS_00037', 'Vlan790', 2036334929, 4). -ipAddress('IOS_00038', 'Vlan790', 2036334930, 4). -ipAddress('IOS_00037', 'Vlan701', 2036334945, 4). -ipAddress('IOS_00038', 'Vlan701', 2036334946, 4). -ipAddress('IOS_00037', 'Vlan702', 2036334961, 4). -ipAddress('IOS_00038', 'Vlan702', 2036334962, 4). -ipAddress('IOS_00037', 'Vlan703', 2036334977, 4). -ipAddress('IOS_00038', 'Vlan703', 2036334978, 4). -ipAddress('IOS_00037', 'Vlan704', 2036334993, 4). -ipAddress('IOS_00038', 'Vlan704', 2036334994, 4). -ipAddress('IOS_00044', 'Vlan701', 2036335009, 4). -ipAddress('IOS_00045', 'Vlan701', 2036335010, 4). -ipAddress('IOS_00044', 'Vlan702', 2036335025, 4). -ipAddress('IOS_00045', 'Vlan702', 2036335026, 4). -ipAddress('IOS_00044', 'Vlan703', 2036335041, 4). -ipAddress('IOS_00045', 'Vlan703', 2036335042, 4). -ipAddress('IOS_00044', 'Vlan704', 2036335057, 4). -ipAddress('IOS_00045', 'Vlan704', 2036335058, 4). -ipAddress('IOS_00044', 'Vlan705', 2036335073, 4). -ipAddress('IOS_00045', 'Vlan705', 2036335074, 4). -ipAddress('IOS_00044', 'Vlan706', 2036335089, 4). -ipAddress('IOS_00045', 'Vlan706', 2036335090, 4). -ipAddress('IOS_00044', 'Vlan707', 2036335105, 4). -ipAddress('IOS_00045', 'Vlan707', 2036335106, 4). -ipAddress('IOS_00044', 'Vlan708', 2036335121, 4). -ipAddress('IOS_00045', 'Vlan708', 2036335122, 4). -ipAddress('IOS_00044', 'Vlan709', 2036335137, 4). -ipAddress('IOS_00045', 'Vlan709', 2036335138, 4). -ipAddress('IOS_00044', 'Vlan710', 2036335153, 4). -ipAddress('IOS_00045', 'Vlan710', 2036335154, 4). -ipAddress('IOS_00070', 'Vlan701', 2036335169, 4). -ipAddress('IOS_00070', 'Vlan702', 2036335185, 4). -ipAddress('IOS_00070', 'Vlan703', 2036335201, 4). -ipAddress('IOS_00070', 'Vlan704', 2036335217, 4). -ipAddress('IOS_00070', 'Vlan705', 2036335233, 4). -ipAddress('IOS_00070', 'Vlan706', 2036335249, 4). -ipAddress('IOS_00070', 'Vlan707', 2036335265, 4). -ipAddress('IOS_00070', 'Vlan708', 2036335281, 4). -ipAddress('IOS_00081', 'Vlan701', 2036335297, 4). -ipAddress('IOS_00081', 'Vlan702', 2036335313, 4). -ipAddress('IOS_00081', 'Vlan703', 2036335329, 4). -ipAddress('IOS_00081', 'Vlan704', 2036335345, 4). -ipAddress('IOS_00091', 'Vlan820', 2036335361, 4). -ipAddress('IOS_00092', 'Vlan820', 2036335362, 4). -ipAddress('IOS_00096', 'FastEthernet0/0', 2036335363, 4). -ipAddress('IOS_00091', 'Vlan837', 2036335377, 4). -ipAddress('IOS_00092', 'Vlan837', 2036335378, 4). -ipAddress('IOS_00091', 'Vlan838', 2036335393, 4). -ipAddress('IOS_00092', 'Vlan838', 2036335394, 4). -ipAddress('IOS_00091', 'Vlan839', 2036335409, 4). -ipAddress('IOS_00092', 'Vlan839', 2036335410, 4). -ipAddress('IOS_00091', 'Vlan840', 2036335425, 4). -ipAddress('IOS_00092', 'Vlan840', 2036335426, 4). -ipAddress('IOS_00091', 'Vlan543', 2036335441, 4). -ipAddress('IOS_00092', 'Vlan543', 2036335442, 4). -ipAddress('IOS_00091', 'Vlan587', 2036335457, 4). -ipAddress('IOS_00092', 'Vlan587', 2036335458, 4). -ipAddress('IOS_00091', 'Vlan588', 2036335473, 4). -ipAddress('IOS_00092', 'Vlan588', 2036335474, 4). -ipAddress('IOS_00091', 'Vlan545', 2036335489, 4). -ipAddress('IOS_00092', 'Vlan545', 2036335490, 4). -ipAddress('IOS_00091', 'Vlan546', 2036335505, 4). -ipAddress('IOS_00092', 'Vlan546', 2036335506, 4). -ipAddress('IOS_00091', 'Vlan547', 2036335521, 4). -ipAddress('IOS_00092', 'Vlan547', 2036335522, 4). -ipAddress('IOS_00091', 'Vlan548', 2036335537, 4). -ipAddress('IOS_00092', 'Vlan548', 2036335538, 4). -ipAddress('IOS_00091', 'Vlan549', 2036335553, 4). -ipAddress('IOS_00092', 'Vlan549', 2036335554, 4). -ipAddress('IOS_00091', 'Vlan550', 2036335569, 4). -ipAddress('IOS_00092', 'Vlan550', 2036335570, 4). -ipAddress('IOS_00091', 'Vlan551', 2036335585, 4). -ipAddress('IOS_00092', 'Vlan551', 2036335586, 4). -ipAddress('IOS_00091', 'Vlan552', 2036335601, 4). -ipAddress('IOS_00092', 'Vlan552', 2036335602, 4). -ipAddress('IOS_00091', 'Vlan553', 2036335617, 4). -ipAddress('IOS_00092', 'Vlan553', 2036335618, 4). -ipAddress('IOS_00091', 'Vlan554', 2036335633, 4). -ipAddress('IOS_00092', 'Vlan554', 2036335634, 4). -ipAddress('IOS_00091', 'Vlan556', 2036335649, 4). -ipAddress('IOS_00092', 'Vlan556', 2036335650, 4). -ipAddress('IOS_00091', 'Vlan557', 2036335665, 4). -ipAddress('IOS_00092', 'Vlan557', 2036335666, 4). -ipAddress('IOS_00091', 'Vlan558', 2036335681, 4). -ipAddress('IOS_00092', 'Vlan558', 2036335682, 4). -ipAddress('IOS_00091', 'Vlan559', 2036335697, 4). -ipAddress('IOS_00092', 'Vlan559', 2036335698, 4). -ipAddress('IOS_00091', 'Vlan560', 2036335713, 4). -ipAddress('IOS_00092', 'Vlan560', 2036335714, 4). -ipAddress('IOS_00091', 'Vlan561', 2036335729, 4). -ipAddress('IOS_00092', 'Vlan561', 2036335730, 4). -ipAddress('IOS_00091', 'Vlan562', 2036335745, 4). -ipAddress('IOS_00092', 'Vlan562', 2036335746, 4). -ipAddress('IOS_00091', 'Vlan563', 2036335761, 4). -ipAddress('IOS_00092', 'Vlan563', 2036335762, 4). -ipAddress('IOS_00091', 'Vlan564', 2036335777, 4). -ipAddress('IOS_00092', 'Vlan564', 2036335778, 4). -ipAddress('IOS_00091', 'Vlan885', 2036335793, 4). -ipAddress('IOS_00092', 'Vlan885', 2036335794, 4). -ipAddress('IOS_00091', 'Vlan544', 2036335809, 4). -ipAddress('IOS_00092', 'Vlan544', 2036335810, 4). -ipAddress('IOS_00091', 'Vlan565', 2036335825, 4). -ipAddress('IOS_00092', 'Vlan565', 2036335826, 4). -ipAddress('IOS_00091', 'Vlan566', 2036335841, 4). -ipAddress('IOS_00092', 'Vlan566', 2036335842, 4). -ipAddress('IOS_00091', 'Vlan567', 2036335857, 4). -ipAddress('IOS_00092', 'Vlan567', 2036335858, 4). -ipAddress('IOS_00091', 'Vlan568', 2036335873, 4). -ipAddress('IOS_00092', 'Vlan568', 2036335874, 4). -ipAddress('IOS_00091', 'Vlan569', 2036335889, 4). -ipAddress('IOS_00092', 'Vlan569', 2036335890, 4). -ipAddress('IOS_00091', 'Vlan570', 2036335905, 4). -ipAddress('IOS_00092', 'Vlan570', 2036335906, 4). -ipAddress('IOS_00091', 'Vlan571', 2036335921, 4). -ipAddress('IOS_00092', 'Vlan571', 2036335922, 4). -ipAddress('IOS_00091', 'Vlan572', 2036335937, 4). -ipAddress('IOS_00092', 'Vlan572', 2036335938, 4). -ipAddress('IOS_00091', 'Vlan573', 2036335953, 4). -ipAddress('IOS_00092', 'Vlan573', 2036335954, 4). -ipAddress('IOS_00091', 'Vlan574', 2036335969, 4). -ipAddress('IOS_00092', 'Vlan574', 2036335970, 4). -ipAddress('IOS_00091', 'Vlan575', 2036335985, 4). -ipAddress('IOS_00092', 'Vlan575', 2036335986, 4). -ipAddress('IOS_00091', 'Vlan576', 2036336001, 4). -ipAddress('IOS_00092', 'Vlan576', 2036336002, 4). -ipAddress('IOS_00091', 'Vlan577', 2036336017, 4). -ipAddress('IOS_00092', 'Vlan577', 2036336018, 4). -ipAddress('IOS_00091', 'Vlan580', 2036336033, 4). -ipAddress('IOS_00092', 'Vlan580', 2036336034, 4). -ipAddress('IOS_00091', 'Vlan581', 2036336049, 4). -ipAddress('IOS_00092', 'Vlan581', 2036336050, 4). -ipAddress('IOS_00091', 'Vlan582', 2036336065, 4). -ipAddress('IOS_00092', 'Vlan582', 2036336066, 4). -ipAddress('IOS_00091', 'Vlan583', 2036336081, 4). -ipAddress('IOS_00092', 'Vlan583', 2036336082, 4). -ipAddress('IOS_00091', 'Vlan584', 2036336097, 4). -ipAddress('IOS_00092', 'Vlan584', 2036336098, 4). -ipAddress('IOS_00091', 'Vlan585', 2036336113, 4). -ipAddress('IOS_00092', 'Vlan585', 2036336114, 4). -ipAddress('IOS_00091', 'Vlan586', 2036336129, 4). -ipAddress('IOS_00092', 'Vlan586', 2036336130, 4). -ipAddress('IOS_00091', 'Vlan555', 2036336145, 4). -ipAddress('IOS_00092', 'Vlan555', 2036336146, 4). -ipAddress('IOS_00091', 'Vlan800', 2036336161, 4). -ipAddress('IOS_00092', 'Vlan800', 2036336162, 4). -ipAddress('IOS_00091', 'Loopback0', 2036336177, 4). -ipAddress('IOS_00096', 'Loopback1', 2036336193, 4). -ipAddress('IOS_00092', 'Loopback0', 2036336209, 4). -ipAddress('IOS_00091', 'Vlan822', 2036336225, 4). -ipAddress('IOS_00092', 'Vlan822', 2036336226, 4). -ipAddress('IOS_00091', 'Vlan821', 2036336241, 4). -ipAddress('IOS_00092', 'Vlan821', 2036336242, 4). -ipAddress('IOS_00091', 'Vlan830', 2036336257, 4). -ipAddress('IOS_00092', 'Vlan830', 2036336258, 4). -ipAddress('IOS_00091', 'Vlan825', 2036336273, 4). -ipAddress('IOS_00092', 'Vlan825', 2036336274, 4). -ipAddress('IOS_00091', 'Vlan950', 2036336289, 4). -ipAddress('IOS_00092', 'Vlan950', 2036336290, 4). -ipAddress('IOS_00091', 'Vlan823', 2036336305, 4). -ipAddress('IOS_00092', 'Vlan823', 2036336306, 4). -ipAddress('IOS_00091', 'Vlan824', 2036336321, 4). -ipAddress('IOS_00092', 'Vlan824', 2036336322, 4). -ipAddress('IOS_00091', 'Vlan831', 2036336337, 4). -ipAddress('IOS_00092', 'Vlan831', 2036336338, 4). -ipAddress('IOS_00091', 'Vlan829', 2036336353, 4). -ipAddress('IOS_00092', 'Vlan829', 2036336354, 4). -ipAddress('IOS_00091', 'Vlan832', 2036336369, 4). -ipAddress('IOS_00092', 'Vlan832', 2036336370, 4). -ipAddress('IOS_00091', 'Vlan110', 2036336385, 4). -ipAddress('IOS_00092', 'Vlan110', 2036336386, 4). -ipAddress('IOS_00091', 'Vlan833', 2036336401, 4). -ipAddress('IOS_00092', 'Vlan833', 2036336402, 4). -ipAddress('IOS_00091', 'Vlan14', 2036336417, 4). -ipAddress('IOS_00092', 'Vlan14', 2036336418, 4). -ipAddress('IOS_00091', 'Vlan834', 2036336433, 4). -ipAddress('IOS_00092', 'Vlan834', 2036336434, 4). -ipAddress('IOS_00091', 'Vlan835', 2036336449, 4). -ipAddress('IOS_00092', 'Vlan835', 2036336450, 4). -ipAddress('IOS_00091', 'Vlan836', 2036336465, 4). -ipAddress('IOS_00092', 'Vlan836', 2036336466, 4). -ipAddress('IOS_00022', 'Vlan112', 2036336481, 4). -ipAddress('IOS_00023', 'Vlan112', 2036336482, 4). -ipAddress('IOS_00022', 'Vlan115', 2036336497, 4). -ipAddress('IOS_00023', 'Vlan115', 2036336498, 4). -ipAddress('IOS_00009', 'Vlan626', 2036336513, 4). -ipAddress('IOS_00065', 'Loopback0', 2036336529, 4). -ipAddress('IOS_00022', 'Loopback0', 2036336545, 4). -ipAddress('IOS_00023', 'Loopback0', 2036336561, 4). -ipAddress('IOS_00024', 'Loopback0', 2036336577, 4). -ipAddress('IOS_00021', 'GigabitEthernet3/48', 2036336593, 4). -ipAddress('IOS_00008', 'Vlan620', 2036336594, 4). -ipAddress('IOS_00009', 'Vlan620', 2036336595, 4). -ipAddress('IOS_00016', 'FastEthernet0/0', 2036336596, 4). -ipAddress('IOS_00008', 'Vlan643', 2036336609, 4). -ipAddress('IOS_00009', 'Vlan643', 2036336610, 4). -ipAddress('IOS_00008', 'Vlan644', 2036336625, 4). -ipAddress('IOS_00009', 'Vlan644', 2036336626, 4). -ipAddress('IOS_00008', 'Vlan645', 2036336641, 4). -ipAddress('IOS_00009', 'Vlan645', 2036336642, 4). -ipAddress('IOS_00001', 'Vlan699', 2036336657, 4). -ipAddress('IOS_00018', 'Vlan699', 2036336658, 4). -ipAddress('IOS_00002', 'Vlan699', 2036336659, 4). -ipAddress('IOS_00001', 'Vlan639', 2036336673, 4). -ipAddress('IOS_00002', 'Vlan639', 2036336674, 4). -ipAddress('IOS_00001', 'Vlan14', 2036336689, 4). -ipAddress('IOS_00002', 'Vlan14', 2036336690, 4). -ipAddress('IOS_00003', 'Vlan714', 2036336691, 4). -ipAddress('IOS_00004', 'Vlan714', 2036336692, 4). -ipAddress('IOS_00008', 'Vlan623', 2036336705, 4). -ipAddress('IOS_00009', 'Vlan623', 2036336706, 4). -ipAddress('IOS_00009', 'Vlan609', 2036336721, 4). -ipAddress('IOS_00009', 'GigabitEthernet6/3', 2036336737, 4). -ipAddress('IOS_00009', 'GigabitEthernet6/4', 2036336753, 4). -ipAddress('IOS_00008', 'GigabitEthernet6/3', 2036336769, 4). -ipAddress('IOS_00008', 'GigabitEthernet6/4', 2036336785, 4). -ipAddress('IOS_00008', 'Vlan601', 2036336801, 4). -ipAddress('IOS_00009', 'Vlan601', 2036336802, 4). -ipAddress('IOS_00001', 'Vlan602', 2036336817, 4). -ipAddress('IOS_00002', 'Vlan602', 2036336818, 4). -ipAddress('IOS_00001', 'Vlan613', 2036336833, 4). -ipAddress('IOS_00002', 'Vlan613', 2036336834, 4). -ipAddress('IOS_00001', 'Loopback0', 2036336849, 4). -ipAddress('IOS_00016', 'Loopback1', 2036336865, 4). -ipAddress('IOS_00002', 'Loopback0', 2036336881, 4). -ipAddress('IOS_00006', 'Loopback0', 2036336897, 4). -ipAddress('IOS_00008', 'Loopback0', 2036336913, 4). -ipAddress('IOS_00009', 'Loopback0', 2036336929, 4). -ipAddress('IOS_00015', 'Loopback0', 2036336945, 4). -ipAddress('IOS_00017', 'Loopback0', 2036336961, 4). -ipAddress('IOS_00008', 'Vlan622', 2036336977, 4). -ipAddress('IOS_00009', 'Vlan622', 2036336978, 4). -ipAddress('IOS_00008', 'Vlan621', 2036336993, 4). -ipAddress('IOS_00009', 'Vlan621', 2036336994, 4). -ipAddress('IOS_00008', 'Vlan624', 2036337009, 4). -ipAddress('IOS_00009', 'Vlan624', 2036337010, 4). -ipAddress('IOS_00001', 'Vlan110', 2036337025, 4). -ipAddress('IOS_00002', 'Vlan110', 2036337026, 4). -ipAddress('IOS_00008', 'Vlan699', 2036337041, 4). -ipAddress('IOS_00009', 'Vlan699', 2036337042, 4). -ipAddress('IOS_00001', 'GigabitEthernet1/2', 2036337057, 4). -ipAddress('IOS_00015', 'FastEthernet1/0', 2036337058, 4). -ipAddress('IOS_00002', 'GigabitEthernet1/2', 2036337073, 4). -ipAddress('IOS_00015', 'FastEthernet1/1', 2036337074, 4). -ipAddress('IOS_00001', 'Vlan616', 2036337089, 4). -ipAddress('IOS_00002', 'Vlan616', 2036337090, 4). -ipAddress('IOS_00001', 'Vlan609', 2036337105, 4). -ipAddress('IOS_00002', 'Vlan609', 2036337106, 4). -ipAddress('IOS_00017', 'Vlan609', 2036337107, 4). -ipAddress('IOS_00008', 'Vlan637', 2036337121, 4). -ipAddress('IOS_00009', 'Vlan637', 2036337122, 4). -ipAddress('IOS_00008', 'Vlan641', 2036337137, 4). -ipAddress('IOS_00009', 'Vlan641', 2036337138, 4). -ipAddress('IOS_00008', 'Vlan642', 2036337153, 4). -ipAddress('IOS_00009', 'Vlan642', 2036337154, 4). -ipAddress('IOS_00035', 'Vlan100', 2036337169, 4). -ipAddress('IOS_00036', 'Vlan100', 2036337170, 4). -ipAddress('IOS_00026', 'Vlan100', 2036337171, 4). -ipAddress('IOS_00029', 'FastEthernet0/0', 2036337172, 4). -ipAddress('IOS_00031', 'Vlan100', 2036337173, 4). -ipAddress('IOS_00032', 'Vlan100', 2036337174, 4). -ipAddress('IOS_00033', 'Vlan100', 2036337175, 4). -ipAddress('IOS_00034', 'Vlan100', 2036337176, 4). -ipAddress('IOS_00026', 'Loopback0', 2036337185, 4). -ipAddress('IOS_00030', 'Loopback0', 2036337201, 4). -ipAddress('IOS_00029', 'Loopback1', 2036337217, 4). -ipAddress('IOS_00026', 'Vlan110', 2036337233, 4). -ipAddress('IOS_00026', 'Vlan513', 2036337249, 4). -ipAddress('IOS_00026', 'Vlan400', 2036337265, 4). -ipAddress('IOS_00026', 'Vlan501', 2036337281, 4). -ipAddress('IOS_00028', 'Loopback0', 2036337297, 4). -ipAddress('IOS_00040', 'Loopback0', 2036337313, 4). -ipAddress('IOS_00047', 'Loopback0', 2036337329, 4). -ipAddress('IOS_00012', 'Loopback0', 2036337345, 4). -ipAddress('IOS_00072', 'Loopback0', 2036337361, 4). -ipAddress('IOS_00083', 'Loopback0', 2036337377, 4). -ipAddress('IOS_00026', 'Vlan502', 2036337393, 4). -ipAddress('IOS_00069', 'Vlan200', 2036337409, 4). -ipAddress('IOS_00066', 'Vlan200', 2036337410, 4). -ipAddress('IOS_00067', 'Vlan200', 2036337411, 4). -ipAddress('IOS_00068', 'Vlan200', 2036337412, 4). -ipAddress('IOS_00005', 'Loopback0', 2036337425, 4). -ipAddress('IOS_00026', 'Vlan503', 2036337441, 4). -ipAddress('IOS_00026', 'Vlan504', 2036337457, 4). -ipAddress('IOS_00037', 'Vlan100', 2036337473, 4). -ipAddress('IOS_00038', 'Vlan100', 2036337474, 4). -ipAddress('IOS_00041', 'FastEthernet0/0', 2036337475, 4). -ipAddress('IOS_00037', 'Loopback0', 2036337489, 4). -ipAddress('IOS_00038', 'Loopback0', 2036337505, 4). -ipAddress('IOS_00042', 'Loopback0', 2036337521, 4). -ipAddress('IOS_00043', 'Loopback0', 2036337537, 4). -ipAddress('IOS_00041', 'Loopback1', 2036337553, 4). -ipAddress('IOS_00037', 'Vlan110', 2036337569, 4). -ipAddress('IOS_00038', 'Vlan110', 2036337570, 4). -ipAddress('IOS_00037', 'Vlan513', 2036337585, 4). -ipAddress('IOS_00038', 'Vlan513', 2036337586, 4). -ipAddress('IOS_00037', 'Vlan400', 2036337601, 4). -ipAddress('IOS_00038', 'Vlan400', 2036337602, 4). -ipAddress('IOS_00037', 'Vlan401', 2036337617, 4). -ipAddress('IOS_00038', 'Vlan401', 2036337618, 4). -ipAddress('IOS_00037', 'Vlan501', 2036337633, 4). -ipAddress('IOS_00038', 'Vlan501', 2036337634, 4). -ipAddress('IOS_00037', 'Vlan502', 2036337649, 4). -ipAddress('IOS_00038', 'Vlan502', 2036337650, 4). -ipAddress('IOS_00037', 'Vlan503', 2036337665, 4). -ipAddress('IOS_00038', 'Vlan503', 2036337666, 4). -ipAddress('IOS_00037', 'Vlan504', 2036337681, 4). -ipAddress('IOS_00038', 'Vlan504', 2036337682, 4). -ipAddress('IOS_00037', 'GigabitEthernet2/1', 2036337697, 4). -ipAddress('IOS_00038', 'GigabitEthernet2/1', 2036337698, 4). -ipAddress('IOS_00037', 'Vlan940', 2036337713, 4). -ipAddress('IOS_00038', 'Vlan940', 2036337714, 4). -ipAddress('IOS_00037', 'GigabitEthernet3/1', 2036337729, 4). -ipAddress('IOS_00042', 'GigabitEthernet0/0', 2036337730, 4). -ipAddress('IOS_00038', 'GigabitEthernet3/1', 2036337745, 4). -ipAddress('IOS_00043', 'GigabitEthernet0/0', 2036337746, 4). -ipAddress('IOS_00037', 'Vlan950', 2036337761, 4). -ipAddress('IOS_00038', 'Vlan950', 2036337762, 4). -ipAddress('IOS_00027', 'Loopback0', 2036337777, 4). -ipAddress('IOS_00039', 'Loopback0', 2036337793, 4). -ipAddress('IOS_00046', 'Loopback0', 2036337809, 4). -ipAddress('IOS_00071', 'Loopback0', 2036337825, 4). -ipAddress('IOS_00082', 'Loopback0', 2036337841, 4). -ipAddress('IOS_00026', 'Vlan940', 2036337857, 4). -ipAddress('IOS_00026', 'FastEthernet4/1', 2036337873, 4). -ipAddress('IOS_00030', 'FastEthernet0/0', 2036337874, 4). -ipAddress('IOS_00026', 'Vlan950', 2036337889, 4). -ipAddress('IOS_00055', 'Vlan100', 2036337905, 4). -ipAddress('IOS_00059', 'Vlan100', 2036337906, 4). -ipAddress('IOS_00060', 'Vlan100', 2036337907, 4). -ipAddress('IOS_00044', 'Vlan100', 2036337908, 4). -ipAddress('IOS_00061', 'Vlan100', 2036337909, 4). -ipAddress('IOS_00045', 'Vlan100', 2036337910, 4). -ipAddress('IOS_00062', 'Vlan100', 2036337911, 4). -ipAddress('IOS_00063', 'Vlan100', 2036337912, 4). -ipAddress('IOS_00064', 'Vlan100', 2036337913, 4). -ipAddress('IOS_00048', 'FastEthernet0/0', 2036337914, 4). -ipAddress('IOS_00051', 'Vlan100', 2036337915, 4). -ipAddress('IOS_00044', 'Loopback0', 2036337921, 4). -ipAddress('IOS_00045', 'Loopback0', 2036337937, 4). -ipAddress('IOS_00049', 'Loopback0', 2036337953, 4). -ipAddress('IOS_00050', 'Loopback0', 2036337969, 4). -ipAddress('IOS_00048', 'Loopback1', 2036337985, 4). -ipAddress('IOS_00044', 'Vlan110', 2036338001, 4). -ipAddress('IOS_00045', 'Vlan110', 2036338002, 4). -ipAddress('IOS_00044', 'Vlan513', 2036338017, 4). -ipAddress('IOS_00045', 'Vlan513', 2036338018, 4). -ipAddress('IOS_00044', 'Vlan400', 2036338033, 4). -ipAddress('IOS_00045', 'Vlan400', 2036338034, 4). -ipAddress('IOS_00044', 'Vlan401', 2036338049, 4). -ipAddress('IOS_00045', 'Vlan401', 2036338050, 4). -ipAddress('IOS_00044', 'Vlan501', 2036338065, 4). -ipAddress('IOS_00045', 'Vlan501', 2036338066, 4). -ipAddress('IOS_00044', 'Vlan502', 2036338081, 4). -ipAddress('IOS_00045', 'Vlan502', 2036338082, 4). -ipAddress('IOS_00044', 'Vlan503', 2036338097, 4). -ipAddress('IOS_00045', 'Vlan503', 2036338098, 4). -ipAddress('IOS_00044', 'Vlan504', 2036338113, 4). -ipAddress('IOS_00045', 'Vlan504', 2036338114, 4). -ipAddress('IOS_00044', 'Vlan505', 2036338129, 4). -ipAddress('IOS_00045', 'Vlan505', 2036338130, 4). -ipAddress('IOS_00044', 'Vlan506', 2036338145, 4). -ipAddress('IOS_00045', 'Vlan506', 2036338146, 4). -ipAddress('IOS_00044', 'Vlan507', 2036338161, 4). -ipAddress('IOS_00045', 'Vlan507', 2036338162, 4). -ipAddress('IOS_00044', 'Vlan508', 2036338177, 4). -ipAddress('IOS_00045', 'Vlan508', 2036338178, 4). -ipAddress('IOS_00044', 'Vlan509', 2036338193, 4). -ipAddress('IOS_00045', 'Vlan509', 2036338194, 4). -ipAddress('IOS_00044', 'Vlan510', 2036338209, 4). -ipAddress('IOS_00045', 'Vlan510', 2036338210, 4). -ipAddress('IOS_00044', 'GigabitEthernet2/18', 2036338225, 4). -ipAddress('IOS_00045', 'GigabitEthernet2/18', 2036338226, 4). -ipAddress('IOS_00044', 'Vlan940', 2036338241, 4). -ipAddress('IOS_00045', 'Vlan940', 2036338242, 4). -ipAddress('IOS_00044', 'GigabitEthernet4/1', 2036338257, 4). -ipAddress('IOS_00049', 'GigabitEthernet0/0', 2036338258, 4). -ipAddress('IOS_00045', 'GigabitEthernet4/1', 2036338273, 4). -ipAddress('IOS_00050', 'GigabitEthernet0/0', 2036338274, 4). -ipAddress('IOS_00044', 'Vlan950', 2036338289, 4). -ipAddress('IOS_00045', 'Vlan950', 2036338290, 4). -ipAddress('IOS_00070', 'Vlan100', 2036338305, 4). -ipAddress('IOS_00073', 'FastEthernet0/0', 2036338306, 4). -ipAddress('IOS_00076', 'Vlan100', 2036338307, 4). -ipAddress('IOS_00077', 'Vlan100', 2036338308, 4). -ipAddress('IOS_00078', 'Vlan100', 2036338309, 4). -ipAddress('IOS_00079', 'Vlan100', 2036338310, 4). -ipAddress('IOS_00080', 'Vlan100', 2036338311, 4). -ipAddress('IOS_00070', 'Loopback0', 2036338321, 4). -ipAddress('IOS_00074', 'Loopback0', 2036338337, 4). -ipAddress('IOS_00075', 'Loopback0', 2036338353, 4). -ipAddress('IOS_00073', 'Loopback1', 2036338369, 4). -ipAddress('IOS_00070', 'Vlan110', 2036338385, 4). -ipAddress('IOS_00070', 'Vlan513', 2036338401, 4). -ipAddress('IOS_00070', 'Vlan400', 2036338417, 4). -ipAddress('IOS_00070', 'Vlan401', 2036338433, 4). -ipAddress('IOS_00070', 'Vlan501', 2036338449, 4). -ipAddress('IOS_00070', 'Vlan502', 2036338465, 4). -ipAddress('IOS_00070', 'Vlan503', 2036338481, 4). -ipAddress('IOS_00070', 'Vlan504', 2036338497, 4). -ipAddress('IOS_00070', 'Vlan505', 2036338513, 4). -ipAddress('IOS_00070', 'Vlan506', 2036338529, 4). -ipAddress('IOS_00070', 'Vlan507', 2036338545, 4). -ipAddress('IOS_00070', 'Vlan508', 2036338561, 4). -ipAddress('IOS_00070', 'GigabitEthernet2/2', 2036338577, 4). -ipAddress('IOS_00074', 'GigabitEthernet0/0', 2036338578, 4). -ipAddress('IOS_00070', 'GigabitEthernet1/2', 2036338593, 4). -ipAddress('IOS_00075', 'GigabitEthernet0/0', 2036338594, 4). -ipAddress('IOS_00070', 'Vlan950', 2036338609, 4). -ipAddress('IOS_00070', 'Vlan940', 2036338625, 4). -ipAddress('IOS_00086', 'Vlan100', 2036338641, 4). -ipAddress('IOS_00087', 'Vlan100', 2036338642, 4). -ipAddress('IOS_00088', 'Vlan100', 2036338643, 4). -ipAddress('IOS_00081', 'Vlan100', 2036338644, 4). -ipAddress('IOS_00084', 'FastEthernet0/0', 2036338645, 4). -ipAddress('IOS_00081', 'Loopback0', 2036338657, 4). -ipAddress('IOS_00085', 'Loopback0', 2036338673, 4). -ipAddress('IOS_00084', 'Loopback1', 2036338689, 4). -ipAddress('IOS_00081', 'Vlan110', 2036338705, 4). -ipAddress('IOS_00081', 'Vlan400', 2036338721, 4). -ipAddress('IOS_00081', 'Vlan513', 2036338737, 4). -ipAddress('IOS_00081', 'Vlan501', 2036338753, 4). -ipAddress('IOS_00081', 'Vlan502', 2036338769, 4). -ipAddress('IOS_00081', 'Vlan503', 2036338785, 4). -ipAddress('IOS_00081', 'Vlan504', 2036338801, 4). -ipAddress('IOS_00081', 'GigabitEthernet2/2', 2036338817, 4). -ipAddress('IOS_00085', 'FastEthernet0/0', 2036338818, 4). -ipAddress('IOS_00081', 'Vlan950', 2036338833, 4). -ipAddress('IOS_00081', 'Vlan940', 2036338849, 4). -ipAddress('IOS_00093', 'Vlan798', 2036338865, 4). -ipAddress('IOS_00094', 'Vlan798', 2036338866, 4). -ipAddress('IOS_00097', 'Vlan798', 2036338867, 4). -ipAddress('IOS_00098', 'Vlan798', 2036338868, 4). -ipAddress('IOS_00099', 'Vlan798', 2036338869, 4). -ipAddress('IOS_00100', 'Vlan798', 2036338870, 4). -ipAddress('IOS_00091', 'Vlan701', 2036338881, 4). -ipAddress('IOS_00092', 'Vlan701', 2036338882, 4). -ipAddress('IOS_00091', 'Vlan710', 2036338897, 4). -ipAddress('IOS_00092', 'Vlan710', 2036338898, 4). -ipAddress('IOS_00093', 'Vlan772', 2036338913, 4). -ipAddress('IOS_00094', 'Vlan772', 2036338914, 4). -ipAddress('IOS_00002', 'GigabitEthernet1/24', 2036338929, 4). -ipAddress('IOS_00004', 'GigabitEthernet2/11', 2036338930, 4). -ipAddress('IOS_00001', 'GigabitEthernet1/24', 2036338945, 4). -ipAddress('IOS_00003', 'GigabitEthernet2/12', 2036338946, 4). -ipAddress('IOS_00093', 'Vlan771', 2036338961, 4). -ipAddress('IOS_00094', 'Vlan771', 2036338962, 4). -ipAddress('IOS_00093', 'Vlan780', 2036338977, 4). -ipAddress('IOS_00095', 'FastEthernet0/0', 2036338978, 4). -ipAddress('IOS_00003', 'Vlan770', 2036338993, 4). -ipAddress('IOS_00004', 'Vlan770', 2036338994, 4). -ipAddress('IOS_00091', 'Vlan711', 2036339009, 4). -ipAddress('IOS_00092', 'Vlan711', 2036339010, 4). -ipAddress('IOS_00091', 'Vlan712', 2036339025, 4). -ipAddress('IOS_00092', 'Vlan712', 2036339026, 4). -ipAddress('IOS_00089', 'GigabitEthernet1/0', 2036339041, 4). -ipAddress('IOS_00091', 'Vlan778', 2036339042, 4). -ipAddress('IOS_00090', 'FastEthernet2/0', 2036339057, 4). -ipAddress('IOS_00090', 'FastEthernet1/0', 2036339073, 4). -ipAddress('IOS_00089', 'FastEthernet1/0', 2036339089, 4). -ipAddress('IOS_00090', 'GigabitEthernet1/0', 2036339105, 4). -ipAddress('IOS_00092', 'Vlan779', 2036339106, 4). -ipAddress('IOS_00093', 'Vlan775', 2036339121, 4). -ipAddress('IOS_00094', 'Vlan775', 2036339122, 4). -ipAddress('IOS_00093', 'Vlan774', 2036339137, 4). -ipAddress('IOS_00094', 'Vlan774', 2036339138, 4). -ipAddress('IOS_00093', 'Vlan781', 2036339153, 4). -ipAddress('IOS_00093', 'Vlan776', 2036339169, 4). -ipAddress('IOS_00094', 'Vlan776', 2036339170, 4). -ipAddress('IOS_00093', 'Vlan777', 2036339185, 4). -ipAddress('IOS_00094', 'Vlan777', 2036339186, 4). -ipAddress('IOS_00093', 'Vlan773', 2036339201, 4). -ipAddress('IOS_00094', 'Vlan773', 2036339202, 4). -ipAddress('IOS_00022', 'Vlan770', 2036339217, 4). -ipAddress('IOS_00023', 'Vlan770', 2036339218, 4). -ipAddress('IOS_00022', 'Vlan771', 2036339233, 4). -ipAddress('IOS_00023', 'Vlan771', 2036339234, 4). -ipAddress('IOS_00091', 'Vlan713', 2036339249, 4). -ipAddress('IOS_00092', 'Vlan713', 2036339250, 4). -ipAddress('IOS_00022', 'Vlan793', 2036339265, 4). -ipAddress('IOS_00025', 'FastEthernet0/0', 2036339266, 4). -ipAddress('IOS_00003', 'Vlan766', 2036339281, 4). -ipAddress('IOS_00004', 'Vlan766', 2036339282, 4). -ipAddress('IOS_00003', 'Vlan798', 2036339297, 4). -ipAddress('IOS_00004', 'Vlan798', 2036339298, 4). -ipAddress('IOS_00003', 'Vlan797', 2036339313, 4). -ipAddress('IOS_00004', 'Vlan797', 2036339314, 4). -ipAddress('IOS_00003', 'Vlan795', 2036339329, 4). -ipAddress('IOS_00004', 'Vlan795', 2036339330, 4). -ipAddress('IOS_00003', 'Vlan796', 2036339345, 4). -ipAddress('IOS_00004', 'Vlan796', 2036339346, 4). -ipAddress('IOS_00091', 'Vlan714', 2036339361, 4). -ipAddress('IOS_00092', 'Vlan714', 2036339362, 4). -ipAddress('IOS_00003', 'Vlan759', 2036339377, 4). -ipAddress('IOS_00003', 'Vlan757', 2036339393, 4). -ipAddress('IOS_00004', 'Vlan757', 2036339394, 4). -ipAddress('IOS_00003', 'Vlan763', 2036339409, 4). -ipAddress('IOS_00004', 'Vlan763', 2036339410, 4). -ipAddress('IOS_00003', 'Vlan758', 2036339425, 4). -ipAddress('IOS_00003', 'Vlan760', 2036339441, 4). -ipAddress('IOS_00004', 'Vlan760', 2036339442, 4). -ipAddress('IOS_00003', 'Vlan756', 2036339457, 4). -ipAddress('IOS_00004', 'Vlan756', 2036339458, 4). -ipAddress('IOS_00091', 'Vlan715', 2036339473, 4). -ipAddress('IOS_00092', 'Vlan715', 2036339474, 4). -ipAddress('IOS_00003', 'Vlan754', 2036339489, 4). -ipAddress('IOS_00004', 'Vlan754', 2036339490, 4). -ipAddress('IOS_00003', 'Vlan753', 2036339505, 4). -ipAddress('IOS_00004', 'Vlan753', 2036339506, 4). -ipAddress('IOS_00091', 'Vlan716', 2036339521, 4). -ipAddress('IOS_00092', 'Vlan716', 2036339522, 4). -ipAddress('IOS_00003', 'Vlan792', 2036339537, 4). -ipAddress('IOS_00004', 'Vlan792', 2036339538, 4). -ipAddress('IOS_00091', 'Vlan717', 2036339553, 4). -ipAddress('IOS_00092', 'Vlan717', 2036339554, 4). -ipAddress('IOS_00091', 'Vlan718', 2036339569, 4). -ipAddress('IOS_00092', 'Vlan718', 2036339570, 4). -ipAddress('IOS_00003', 'Vlan790', 2036339585, 4). -ipAddress('IOS_00005', 'GigabitEthernet0/0', 2036339586, 4). -ipAddress('IOS_00004', 'Vlan791', 2036339601, 4). -ipAddress('IOS_00005', 'GigabitEthernet0/1', 2036339602, 4). -ipAddress('IOS_00004', 'Vlan780', 2036339617, 4). -ipAddress('IOS_00007', 'GigabitEthernet0/0', 2036339618, 4). -ipAddress('IOS_00003', 'Vlan761', 2036339633, 4). -ipAddress('IOS_00004', 'Vlan761', 2036339634, 4). -ipAddress('IOS_00091', 'Vlan719', 2036339649, 4). -ipAddress('IOS_00092', 'Vlan719', 2036339650, 4). -ipAddress('IOS_00091', 'Vlan702', 2036339665, 4). -ipAddress('IOS_00092', 'Vlan702', 2036339666, 4). -ipAddress('IOS_00091', 'Vlan720', 2036339681, 4). -ipAddress('IOS_00092', 'Vlan720', 2036339682, 4). -ipAddress('IOS_00091', 'Vlan721', 2036339697, 4). -ipAddress('IOS_00092', 'Vlan721', 2036339698, 4). -ipAddress('IOS_00091', 'Vlan722', 2036339713, 4). -ipAddress('IOS_00092', 'Vlan722', 2036339714, 4). -ipAddress('IOS_00091', 'Vlan723', 2036339729, 4). -ipAddress('IOS_00092', 'Vlan723', 2036339730, 4). -ipAddress('IOS_00091', 'Vlan724', 2036339745, 4). -ipAddress('IOS_00092', 'Vlan724', 2036339746, 4). -ipAddress('IOS_00091', 'Vlan725', 2036339761, 4). -ipAddress('IOS_00092', 'Vlan725', 2036339762, 4). -ipAddress('IOS_00091', 'Vlan726', 2036339777, 4). -ipAddress('IOS_00092', 'Vlan726', 2036339778, 4). -ipAddress('IOS_00091', 'Vlan727', 2036339793, 4). -ipAddress('IOS_00092', 'Vlan727', 2036339794, 4). -ipAddress('IOS_00091', 'Vlan728', 2036339809, 4). -ipAddress('IOS_00092', 'Vlan728', 2036339810, 4). -ipAddress('IOS_00091', 'Vlan729', 2036339825, 4). -ipAddress('IOS_00092', 'Vlan729', 2036339826, 4). -ipAddress('IOS_00091', 'Vlan703', 2036339841, 4). -ipAddress('IOS_00092', 'Vlan703', 2036339842, 4). -ipAddress('IOS_00091', 'Vlan730', 2036339857, 4). -ipAddress('IOS_00092', 'Vlan730', 2036339858, 4). -ipAddress('IOS_00091', 'Vlan731', 2036339873, 4). -ipAddress('IOS_00092', 'Vlan731', 2036339874, 4). -ipAddress('IOS_00091', 'Vlan732', 2036339889, 4). -ipAddress('IOS_00092', 'Vlan732', 2036339890, 4). -ipAddress('IOS_00091', 'Vlan733', 2036339905, 4). -ipAddress('IOS_00092', 'Vlan733', 2036339906, 4). -ipAddress('IOS_00091', 'Vlan734', 2036339921, 4). -ipAddress('IOS_00092', 'Vlan734', 2036339922, 4). -ipAddress('IOS_00091', 'Vlan735', 2036339937, 4). -ipAddress('IOS_00092', 'Vlan735', 2036339938, 4). -ipAddress('IOS_00091', 'Vlan736', 2036339953, 4). -ipAddress('IOS_00092', 'Vlan736', 2036339954, 4). -ipAddress('IOS_00091', 'Vlan737', 2036339969, 4). -ipAddress('IOS_00092', 'Vlan737', 2036339970, 4). -ipAddress('IOS_00091', 'Vlan738', 2036339985, 4). -ipAddress('IOS_00092', 'Vlan738', 2036339986, 4). -ipAddress('IOS_00091', 'Vlan739', 2036340001, 4). -ipAddress('IOS_00092', 'Vlan739', 2036340002, 4). -ipAddress('IOS_00091', 'Vlan704', 2036340017, 4). -ipAddress('IOS_00092', 'Vlan704', 2036340018, 4). -ipAddress('IOS_00091', 'Vlan740', 2036340033, 4). -ipAddress('IOS_00092', 'Vlan740', 2036340034, 4). -ipAddress('IOS_00091', 'Vlan741', 2036340049, 4). -ipAddress('IOS_00092', 'Vlan741', 2036340050, 4). -ipAddress('IOS_00091', 'Vlan742', 2036340065, 4). -ipAddress('IOS_00092', 'Vlan742', 2036340066, 4). -ipAddress('IOS_00093', 'Vlan803', 2036340081, 4). -ipAddress('IOS_00094', 'Vlan803', 2036340082, 4). -ipAddress('IOS_00093', 'Vlan804', 2036340097, 4). -ipAddress('IOS_00094', 'Vlan804', 2036340098, 4). -ipAddress('IOS_00091', 'Vlan745', 2036340113, 4). -ipAddress('IOS_00092', 'Vlan745', 2036340114, 4). -ipAddress('IOS_00091', 'Vlan746', 2036340129, 4). -ipAddress('IOS_00092', 'Vlan746', 2036340130, 4). -ipAddress('IOS_00091', 'Vlan747', 2036340145, 4). -ipAddress('IOS_00092', 'Vlan747', 2036340146, 4). -ipAddress('IOS_00091', 'Vlan748', 2036340161, 4). -ipAddress('IOS_00092', 'Vlan748', 2036340162, 4). -ipAddress('IOS_00091', 'Vlan749', 2036340177, 4). -ipAddress('IOS_00092', 'Vlan749', 2036340178, 4). -ipAddress('IOS_00091', 'Vlan705', 2036340193, 4). -ipAddress('IOS_00092', 'Vlan705', 2036340194, 4). -ipAddress('IOS_00093', 'Vlan810', 2036340209, 4). -ipAddress('IOS_00094', 'Vlan810', 2036340210, 4). -ipAddress('IOS_00091', 'Vlan751', 2036340225, 4). -ipAddress('IOS_00092', 'Vlan751', 2036340226, 4). -ipAddress('IOS_00091', 'Vlan752', 2036340241, 4). -ipAddress('IOS_00092', 'Vlan752', 2036340242, 4). -ipAddress('IOS_00091', 'Vlan753', 2036340257, 4). -ipAddress('IOS_00092', 'Vlan753', 2036340258, 4). -ipAddress('IOS_00091', 'Vlan754', 2036340273, 4). -ipAddress('IOS_00092', 'Vlan754', 2036340274, 4). -ipAddress('IOS_00091', 'Vlan755', 2036340289, 4). -ipAddress('IOS_00092', 'Vlan755', 2036340290, 4). -ipAddress('IOS_00091', 'Vlan756', 2036340305, 4). -ipAddress('IOS_00092', 'Vlan756', 2036340306, 4). -ipAddress('IOS_00091', 'Vlan757', 2036340321, 4). -ipAddress('IOS_00092', 'Vlan757', 2036340322, 4). -ipAddress('IOS_00091', 'Vlan758', 2036340337, 4). -ipAddress('IOS_00092', 'Vlan758', 2036340338, 4). -ipAddress('IOS_00091', 'Vlan759', 2036340353, 4). -ipAddress('IOS_00092', 'Vlan759', 2036340354, 4). -ipAddress('IOS_00091', 'Vlan706', 2036340369, 4). -ipAddress('IOS_00092', 'Vlan706', 2036340370, 4). -ipAddress('IOS_00091', 'Vlan760', 2036340385, 4). -ipAddress('IOS_00092', 'Vlan760', 2036340386, 4). -ipAddress('IOS_00091', 'Vlan761', 2036340401, 4). -ipAddress('IOS_00092', 'Vlan761', 2036340402, 4). -ipAddress('IOS_00091', 'Vlan762', 2036340417, 4). -ipAddress('IOS_00092', 'Vlan762', 2036340418, 4). -ipAddress('IOS_00091', 'Vlan763', 2036340433, 4). -ipAddress('IOS_00092', 'Vlan763', 2036340434, 4). -ipAddress('IOS_00091', 'Vlan764', 2036340449, 4). -ipAddress('IOS_00092', 'Vlan764', 2036340450, 4). -ipAddress('IOS_00091', 'Vlan765', 2036340465, 4). -ipAddress('IOS_00092', 'Vlan765', 2036340466, 4). -ipAddress('IOS_00091', 'Vlan766', 2036340481, 4). -ipAddress('IOS_00092', 'Vlan766', 2036340482, 4). -ipAddress('IOS_00091', 'Vlan767', 2036340497, 4). -ipAddress('IOS_00092', 'Vlan767', 2036340498, 4). -ipAddress('IOS_00091', 'Vlan768', 2036340513, 4). -ipAddress('IOS_00092', 'Vlan768', 2036340514, 4). -ipAddress('IOS_00091', 'Vlan769', 2036340529, 4). -ipAddress('IOS_00092', 'Vlan769', 2036340530, 4). -ipAddress('IOS_00091', 'Vlan707', 2036340545, 4). -ipAddress('IOS_00092', 'Vlan707', 2036340546, 4). -ipAddress('IOS_00091', 'Vlan770', 2036340561, 4). -ipAddress('IOS_00092', 'Vlan770', 2036340562, 4). -ipAddress('IOS_00091', 'Vlan771', 2036340577, 4). -ipAddress('IOS_00092', 'Vlan771', 2036340578, 4). -ipAddress('IOS_00091', 'Vlan772', 2036340593, 4). -ipAddress('IOS_00092', 'Vlan772', 2036340594, 4). -ipAddress('IOS_00091', 'Vlan773', 2036340609, 4). -ipAddress('IOS_00092', 'Vlan773', 2036340610, 4). -ipAddress('IOS_00091', 'Vlan774', 2036340625, 4). -ipAddress('IOS_00092', 'Vlan774', 2036340626, 4). -ipAddress('IOS_00091', 'Vlan775', 2036340641, 4). -ipAddress('IOS_00092', 'Vlan775', 2036340642, 4). -ipAddress('IOS_00091', 'Vlan776', 2036340657, 4). -ipAddress('IOS_00092', 'Vlan776', 2036340658, 4). -ipAddress('IOS_00091', 'Vlan777', 2036340673, 4). -ipAddress('IOS_00092', 'Vlan777', 2036340674, 4). -ipAddress('IOS_00093', 'Vlan839', 2036340689, 4). -ipAddress('IOS_00094', 'Vlan839', 2036340690, 4). -ipAddress('IOS_00091', 'Vlan708', 2036340705, 4). -ipAddress('IOS_00092', 'Vlan708', 2036340706, 4). -ipAddress('IOS_00093', 'Vlan840', 2036340721, 4). -ipAddress('IOS_00094', 'Vlan840', 2036340722, 4). -ipAddress('IOS_00091', 'Vlan781', 2036340737, 4). -ipAddress('IOS_00092', 'Vlan781', 2036340738, 4). -ipAddress('IOS_00091', 'Vlan782', 2036340753, 4). -ipAddress('IOS_00092', 'Vlan782', 2036340754, 4). -ipAddress('IOS_00091', 'Vlan783', 2036340769, 4). -ipAddress('IOS_00092', 'Vlan783', 2036340770, 4). -ipAddress('IOS_00091', 'Vlan784', 2036340785, 4). -ipAddress('IOS_00092', 'Vlan784', 2036340786, 4). -ipAddress('IOS_00091', 'Vlan785', 2036340801, 4). -ipAddress('IOS_00092', 'Vlan785', 2036340802, 4). -ipAddress('IOS_00091', 'Vlan786', 2036340817, 4). -ipAddress('IOS_00092', 'Vlan786', 2036340818, 4). -ipAddress('IOS_00091', 'Vlan787', 2036340833, 4). -ipAddress('IOS_00092', 'Vlan787', 2036340834, 4). -ipAddress('IOS_00091', 'Vlan788', 2036340849, 4). -ipAddress('IOS_00092', 'Vlan788', 2036340850, 4). -ipAddress('IOS_00091', 'Vlan743', 2036340865, 4). -ipAddress('IOS_00092', 'Vlan743', 2036340866, 4). -ipAddress('IOS_00091', 'Vlan709', 2036340881, 4). -ipAddress('IOS_00092', 'Vlan709', 2036340882, 4). -ipAddress('IOS_00091', 'Vlan780', 2036340897, 4). -ipAddress('IOS_00092', 'Vlan780', 2036340898, 4). -ipAddress('IOS_00091', 'Vlan744', 2036340913, 4). -ipAddress('IOS_00092', 'Vlan744', 2036340914, 4). -ipAddress('IOS_00091', 'Vlan750', 2036340929, 4). -ipAddress('IOS_00092', 'Vlan750', 2036340930, 4). -ipAddress('IOS_00037', 'GigabitEthernet2/2', 2036340945, 4). -ipAddress('IOS_00039', 'GigabitEthernet0/1', 2036340946, 4). -ipAddress('IOS_00038', 'GigabitEthernet3/2', 2036340961, 4). -ipAddress('IOS_00040', 'GigabitEthernet0/0', 2036340962, 4). -ipAddress('IOS_00044', 'GigabitEthernet3/1', 2036340977, 4). -ipAddress('IOS_00046', 'GigabitEthernet0/1', 2036340978, 4). -ipAddress('IOS_00045', 'GigabitEthernet3/1', 2036340993, 4). -ipAddress('IOS_00047', 'GigabitEthernet0/1', 2036340994, 4). -ipAddress('IOS_00070', 'GigabitEthernet1/1', 2036341009, 4). -ipAddress('IOS_00071', 'GigabitEthernet0/1', 2036341010, 4). -ipAddress('IOS_00070', 'GigabitEthernet2/1', 2036341025, 4). -ipAddress('IOS_00072', 'GigabitEthernet0/1', 2036341026, 4). -ipAddress('IOS_00026', 'GigabitEthernet2/1', 2036341041, 4). -ipAddress('IOS_00027', 'GigabitEthernet0/1', 2036341042, 4). -ipAddress('IOS_00026', 'FastEthernet3/1', 2036341057, 4). -ipAddress('IOS_00028', 'GigabitEthernet0/0', 2036341058, 4). -ipAddress('IOS_00081', 'FastEthernet3/1', 2036341073, 4). -ipAddress('IOS_00083', 'GigabitEthernet0/0', 2036341074, 4). -ipAddress('IOS_00081', 'GigabitEthernet2/1', 2036341089, 4). -ipAddress('IOS_00082', 'GigabitEthernet0/1', 2036341090, 4). -ipAddress('IOS_00022', 'Vlan113', 2036341105, 4). -ipAddress('IOS_00071', 'Tunnel150', 2036341121, 4). -ipAddress('IOS_00072', 'Tunnel150', 2036341122, 4). -ipAddress('IOS_00039', 'Tunnel150', 2036341123, 4). -ipAddress('IOS_00040', 'Tunnel150', 2036341124, 4). -ipAddress('IOS_00027', 'Tunnel150', 2036341125, 4). -ipAddress('IOS_00028', 'Tunnel150', 2036341126, 4). -ipAddress('IOS_00012', 'Tunnel150', 2036341127, 4). -ipAddress('IOS_00046', 'Tunnel150', 2036341128, 4). -ipAddress('IOS_00047', 'Tunnel150', 2036341129, 4). -ipAddress('IOS_00082', 'Tunnel150', 2036341130, 4). -ipAddress('IOS_00083', 'Tunnel150', 2036341131, 4). -ipAddress('IOS_00001', 'Loopback10', 2036341137, 4). -ipAddress('IOS_00091', 'Loopback10', 2036341138, 4). -ipAddress('IOS_00039', 'GigabitEthernet0/2', 2036341153, 4). -ipAddress('IOS_00040', 'GigabitEthernet0/1', 2036341154, 4). -ipAddress('IOS_00082', 'GigabitEthernet0/2', 2036341169, 4). -ipAddress('IOS_00083', 'GigabitEthernet0/1', 2036341170, 4). -ipAddress('IOS_00027', 'GigabitEthernet0/2', 2036341185, 4). -ipAddress('IOS_00028', 'GigabitEthernet0/1', 2036341186, 4). -ipAddress('IOS_00071', 'GigabitEthernet0/2', 2036341201, 4). -ipAddress('IOS_00072', 'GigabitEthernet0/2', 2036341202, 4). -ipAddress('IOS_00046', 'GigabitEthernet0/2', 2036341217, 4). -ipAddress('IOS_00047', 'GigabitEthernet0/2', 2036341218, 4). -ipAddress('IOS_00002', 'GigabitEthernet3/4', 2036341233, 4). -ipAddress('IOS_00012', 'GigabitEthernet0/2', 2036341234, 4). -ipAddress('IOS_00001', 'GigabitEthernet3/4', 2036341249, 4). -ipAddress('IOS_00012', 'GigabitEthernet0/1', 2036341250, 4). -ipAddress('IOS_00093', 'GigabitEthernet4/36', 2036341265, 4). -ipAddress('IOS_00091', 'GigabitEthernet9/1', 2036341281, 4). -ipAddress('IOS_00092', 'GigabitEthernet9/1', 2036341282, 4). -ipAddress('IOS_00065', 'FastEthernet0/0', 2036341283, 4). -ipAddress('IOS_00015', 'FastEthernet0/0', 2036341297, 4). -ipAddress('IOS_00008', 'Vlan606', 2036341313, 4). -ipAddress('IOS_00009', 'Vlan607', 2036341329, 4). -ipAddress('IOS_00001', 'GigabitEthernet3/7', 2036341345, 4). -ipAddress('IOS_00091', 'GigabitEthernet9/4', 2036341346, 4). -ipAddress('IOS_00002', 'Vlan612', 2036341361, 4). -ipAddress('IOS_00011', 'GigabitEthernet0/3', 2036341377, 4). -ipAddress('IOS_00091', 'TenGigabitEthernet10/4', 2036341393, 4). -ipAddress('IOS_00092', 'TenGigabitEthernet10/4', 2036341394, 4). -ipAddress('IOS_00023', 'FastEthernet2/6', 2036341409, 4). -ipAddress('IOS_00024', 'GigabitEthernet0/1', 2036341410, 4). -ipAddress('IOS_00006', 'Hssi1/0', 2036341425, 4). -ipAddress('IOS_00024', 'Hssi1/0', 2036341426, 4). -ipAddress('IOS_00001', 'GigabitEthernet2/6', 2036341441, 4). -ipAddress('IOS_00006', 'GigabitEthernet0/1', 2036341442, 4). -ipAddress('IOS_00001', 'TenGigabitEthernet4/3', 2036341457, 4). -ipAddress('IOS_00008', 'TenGigabitEthernet9/3', 2036341458, 4). -ipAddress('IOS_00001', 'TenGigabitEthernet4/4', 2036341473, 4). -ipAddress('IOS_00002', 'TenGigabitEthernet4/4', 2036341474, 4). -ipAddress('IOS_00002', 'TenGigabitEthernet4/3', 2036341489, 4). -ipAddress('IOS_00009', 'TenGigabitEthernet9/3', 2036341490, 4). -ipAddress('IOS_00008', 'Vlan610', 2036341505, 4). -ipAddress('IOS_00009', 'Vlan610', 2036341506, 4). -ipAddress('IOS_00010', 'Vlan580', 2036341521, 4). -ipAddress('IOS_00065', 'FastEthernet0/1', 2036341537, 4). -ipAddress('IOS_00092', 'Vlan819', 2036341553, 4). -ipAddress('IOS_00094', 'Vlan796', 2036341554, 4). -ipAddress('IOS_00091', 'Vlan818', 2036341569, 4). -ipAddress('IOS_00093', 'Vlan795', 2036341570, 4). -ipAddress('IOS_00001', 'Vlan631', 2036341585, 4). -ipAddress('IOS_00002', 'Vlan631', 2036341586, 4). -ipAddress('IOS_00003', 'Vlan794', 2036341601, 4). -ipAddress('IOS_00004', 'Vlan794', 2036341602, 4). -ipAddress('IOS_00039', 'GigabitEthernet0/3', 2036341617, 4). -ipAddress('IOS_00091', 'Vlan815', 2036341633, 4). -ipAddress('IOS_00092', 'Vlan815', 2036341634, 4). -ipAddress('IOS_00093', 'Vlan794', 2036341649, 4). -ipAddress('IOS_00094', 'Vlan794', 2036341650, 4). -ipAddress('IOS_00011', 'Loopback0', 2036341665, 4). -ipAddress('IOS_00010', 'Loopback0', 2036341681, 4). -ipAddress('IOS_00013', 'Loopback0', 2036341697, 4). -ipAddress('IOS_00014', 'Loopback0', 2036341713, 4). -ipAddress('IOS_00019', 'Vlan430', 2036341729, 4). -ipAddress('IOS_00020', 'Vlan430', 2036341730, 4). -ipAddress('IOS_00010', 'Vlan430', 2036341731, 4). -ipAddress('IOS_00010', 'Vlan500', 2036341745, 4). -ipAddress('IOS_00010', 'Vlan510', 2036341761, 4). -ipAddress('IOS_00010', 'GigabitEthernet1/48', 2036341777, 4). -ipAddress('IOS_00014', 'GigabitEthernet0/1', 2036341778, 4). -ipAddress('IOS_00010', 'GigabitEthernet2/9', 2036341793, 4). -ipAddress('IOS_00014', 'GigabitEthernet0/2', 2036341794, 4). -ipAddress('IOS_00010', 'Vlan540', 2036341809, 4). -ipAddress('IOS_00010', 'Vlan550', 2036341825, 4). -ipAddress('IOS_00010', 'Vlan570', 2036341841, 4). -ipAddress('IOS_00018', 'Vlan44', 2036341857, 4). -ipAddress('IOS_00013', 'GigabitEthernet4/1', 2036341873, 4). -ipAddress('IOS_00013', 'GigabitEthernet1/11', 2036341889, 4). -ipAddress('IOS_00013', 'GigabitEthernet1/10', 2036341905, 4). -ipAddress('IOS_00013', 'GigabitEthernet1/9', 2036341921, 4). -ipAddress('IOS_00013', 'Vlan800', 2036341937, 4). -ipAddress('IOS_00013', 'GigabitEthernet1/1', 2036341953, 4). -ipAddress('IOS_00052', 'Vlan78', 2036341969, 4). -ipAddress('IOS_00053', 'Vlan78', 2036341970, 4). -ipAddress('IOS_00054', 'Vlan78', 2036341971, 4). -ipAddress('IOS_00056', 'Vlan78', 2036341972, 4). -ipAddress('IOS_00057', 'Vlan78', 2036341973, 4). -ipAddress('IOS_00058', 'Vlan78', 2036341974, 4). -ipAddress('IOS_00011', 'GigabitEthernet0/1', 2036341985, 4). -ipAddress('IOS_00011', 'Loopback10', 2036342001, 4). \ No newline at end of file diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/some-variables.txt b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/some-variables.txt deleted file mode 100644 index bb2a71e12..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/some-variables.txt +++ /dev/null @@ -1,170 +0,0 @@ -ipAddress('IOS_00008', 'Vlan608', 2036369870, 2). -ipAddress('IOS_00009', 'Vlan608', 2036369868, 2). -ipAddress('IOS_00010', 'GigabitEthernet4/16', 2036376959, 1). -ipAddress('IOS_00011', 'GigabitEthernet0/2', 2036376958, 1). -ipAddress('IOS_00012', 'POS5/0', 2036370081, 1). -ipAddress('IOS_00022', 'Vlan172', 2036371410, 1). -ipAddress('IOS_00023', 'Vlan172', 2036371411, 1). -ipAddress('IOS_00026', 'Vlan701', 2036375619, 1). -ipAddress('IOS_00026', 'Vlan702', 2036371714, 8). -ipAddress('IOS_00026', 'Vlan703', 2036383855, 11). -ipAddress('IOS_00026', 'Vlan704', 2036377011, 1). -ipAddress('IOS_00027', 'Hssi1/0', 2036390400, 3). -ipAddress('IOS_00028', 'Serial1/0', 2036398775, 6). -ipAddress('IOS_00037', 'Vlan701', 2036368374, 2). -ipAddress('IOS_00037', 'Vlan702', 2036399599, 5). -ipAddress('IOS_00037', 'Vlan703', 2036375971, 1). -ipAddress('IOS_00037', 'Vlan704', 2036375605, 1). -ipAddress('IOS_00037', 'Vlan790', 2036376754, 3). -ipAddress('IOS_00038', 'Vlan701', 2036368372, 2). -ipAddress('IOS_00038', 'Vlan702', 2036399600, 5). -ipAddress('IOS_00038', 'Vlan703', 2036375970, 1). -ipAddress('IOS_00038', 'Vlan704', 2036375604, 1). -ipAddress('IOS_00038', 'Vlan790', 2036376756, 3). -ipAddress('IOS_00039', 'Hssi1/0', 2036395261, 1). -ipAddress('IOS_00039', 'Tunnel160', 2036378386, 6). -ipAddress('IOS_00040', 'Serial1/0', 2036370546, 0). -ipAddress('IOS_00044', 'Vlan701', 2036368584, 7). -ipAddress('IOS_00044', 'Vlan702', 2036369661, 1). -ipAddress('IOS_00044', 'Vlan703', 2036386045, 2). -ipAddress('IOS_00044', 'Vlan704', 2036399993, 7). -ipAddress('IOS_00044', 'Vlan705', 2036391469, 3). -ipAddress('IOS_00044', 'Vlan706', 2036372530, 3). -ipAddress('IOS_00044', 'Vlan707', 2036379113, 3). -ipAddress('IOS_00044', 'Vlan708', 2036367723, 1). -ipAddress('IOS_00044', 'Vlan709', 2036391991, 1). -ipAddress('IOS_00044', 'Vlan710', 2036372270, 8). -ipAddress('IOS_00045', 'Vlan701', 2036368567, 7). -ipAddress('IOS_00045', 'Vlan702', 2036369660, 1). -ipAddress('IOS_00045', 'Vlan703', 2036386047, 2). -ipAddress('IOS_00045', 'Vlan704', 2036399944, 7). -ipAddress('IOS_00045', 'Vlan705', 2036391464, 3). -ipAddress('IOS_00045', 'Vlan706', 2036372533, 3). -ipAddress('IOS_00045', 'Vlan707', 2036379118, 3). -ipAddress('IOS_00045', 'Vlan708', 2036367722, 1). -ipAddress('IOS_00045', 'Vlan709', 2036391990, 1). -ipAddress('IOS_00045', 'Vlan710', 2036372242, 8). -ipAddress('IOS_00046', 'Hssi1/0', 2036396045, 0). -ipAddress('IOS_00047', 'Hssi1/0', 2036368712, 5). -ipAddress('IOS_00070', 'Vlan701', 2036369946, 4). -ipAddress('IOS_00070', 'Vlan702', 2036369352, 0). -ipAddress('IOS_00070', 'Vlan703', 2036398282, 1). -ipAddress('IOS_00070', 'Vlan704', 2036367743, 4). -ipAddress('IOS_00070', 'Vlan705', 2036375020, 0). -ipAddress('IOS_00070', 'Vlan706', 2036367946, 2). -ipAddress('IOS_00070', 'Vlan707', 2036375702, 2). -ipAddress('IOS_00070', 'Vlan708', 2036377437, 2). -ipAddress('IOS_00071', 'Hssi1/0', 2036389082, 10). -ipAddress('IOS_00072', 'Serial1/0', 2036377931, 3). -ipAddress('IOS_00081', 'Vlan701', 2036373047, 3). -ipAddress('IOS_00081', 'Vlan702', 2036368209, 5). -ipAddress('IOS_00081', 'Vlan703', 2036397492, 0). -ipAddress('IOS_00081', 'Vlan704', 2036369601, 1). -ipAddress('IOS_00082', 'Hssi1/0', 2036372735, 3). -ipAddress('IOS_00083', 'Serial1/0', 2036386253, 3). -ipAddress('IOS_00091', 'Loopback0', 2036375497, 8). -ipAddress('IOS_00091', 'Vlan543', 2036368457, 1). -ipAddress('IOS_00091', 'Vlan544', 2036390049, 9). -ipAddress('IOS_00091', 'Vlan545', 2036369867, 2). -ipAddress('IOS_00091', 'Vlan546', 2036392961, 10). -ipAddress('IOS_00091', 'Vlan547', 2036374220, 10). -ipAddress('IOS_00091', 'Vlan548', 2036392299, 2). -ipAddress('IOS_00091', 'Vlan549', 2036369782, 7). -ipAddress('IOS_00091', 'Vlan550', 2036377783, 1). -ipAddress('IOS_00091', 'Vlan551', 2036338429, 15). -ipAddress('IOS_00091', 'Vlan552', 2036371501, 8). -ipAddress('IOS_00091', 'Vlan553', 2036379649, 12). -ipAddress('IOS_00091', 'Vlan554', 2036399796, 8). -ipAddress('IOS_00091', 'Vlan555', 2036374987, 1). -ipAddress('IOS_00091', 'Vlan556', 2036378291, 7). -ipAddress('IOS_00091', 'Vlan557', 2036367656, 5). -ipAddress('IOS_00091', 'Vlan558', 2036367366, 8). -ipAddress('IOS_00091', 'Vlan559', 2036388553, 6). -ipAddress('IOS_00091', 'Vlan560', 2036375607, 1). -ipAddress('IOS_00091', 'Vlan561', 2036395965, 3). -ipAddress('IOS_00091', 'Vlan562', 2036372981, 1). -ipAddress('IOS_00091', 'Vlan563', 2036369458, 1). -ipAddress('IOS_00091', 'Vlan564', 2036396628, 9). -ipAddress('IOS_00091', 'Vlan565', 2036397107, 1). -ipAddress('IOS_00091', 'Vlan566', 2036369202, 3). -ipAddress('IOS_00091', 'Vlan567', 2036394189, 7). -ipAddress('IOS_00091', 'Vlan568', 2036396068, 1). -ipAddress('IOS_00091', 'Vlan569', 2036377960, 4). -ipAddress('IOS_00091', 'Vlan570', 2036391881, 7). -ipAddress('IOS_00091', 'Vlan571', 2036394713, 1). -ipAddress('IOS_00091', 'Vlan572', 2036367888, 2). -ipAddress('IOS_00091', 'Vlan573', 2036370614, 5). -ipAddress('IOS_00091', 'Vlan574', 2036367961, 3). -ipAddress('IOS_00091', 'Vlan575', 2036376627, 1). -ipAddress('IOS_00091', 'Vlan576', 2036368329, 1). -ipAddress('IOS_00091', 'Vlan577', 2036370011, 5). -ipAddress('IOS_00091', 'Vlan580', 2036391405, 5). -ipAddress('IOS_00091', 'Vlan581', 2036373143, 3). -ipAddress('IOS_00091', 'Vlan582', 2036367815, 7). -ipAddress('IOS_00091', 'Vlan583', 2036396076, 1). -ipAddress('IOS_00091', 'Vlan584', 2036399158, 2). -ipAddress('IOS_00091', 'Vlan585', 2036392192, 1). -ipAddress('IOS_00091', 'Vlan586', 2036367691, 5). -ipAddress('IOS_00091', 'Vlan587', 2036373393, 6). -ipAddress('IOS_00091', 'Vlan588', 2036386837, 9). -ipAddress('IOS_00091', 'Vlan800', 2036388410, 1). -ipAddress('IOS_00091', 'Vlan820', 2036387695, 8). -ipAddress('IOS_00091', 'Vlan837', 2036369358, 1). -ipAddress('IOS_00091', 'Vlan838', 2036368423, 3). -ipAddress('IOS_00091', 'Vlan839', 2036375043, 2). -ipAddress('IOS_00091', 'Vlan840', 2036395869, 3). -ipAddress('IOS_00091', 'Vlan885', 2036368385, 3). -ipAddress('IOS_00092', 'Vlan543', 2036368456, 1). -ipAddress('IOS_00092', 'Vlan544', 2036390039, 9). -ipAddress('IOS_00092', 'Vlan545', 2036369864, 2). -ipAddress('IOS_00092', 'Vlan546', 2036393643, 10). -ipAddress('IOS_00092', 'Vlan547', 2036374035, 10). -ipAddress('IOS_00092', 'Vlan548', 2036392298, 2). -ipAddress('IOS_00092', 'Vlan549', 2036369673, 7). -ipAddress('IOS_00092', 'Vlan550', 2036377782, 1). -ipAddress('IOS_00092', 'Vlan551', 2036343332, 15). -ipAddress('IOS_00092', 'Vlan552', 2036371666, 8). -ipAddress('IOS_00092', 'Vlan553', 2036381630, 12). -ipAddress('IOS_00092', 'Vlan554', 2036399706, 8). -ipAddress('IOS_00092', 'Vlan555', 2036374986, 1). -ipAddress('IOS_00092', 'Vlan556', 2036378272, 7). -ipAddress('IOS_00092', 'Vlan557', 2036367674, 5). -ipAddress('IOS_00092', 'Vlan558', 2036367593, 8). -ipAddress('IOS_00092', 'Vlan559', 2036388548, 6). -ipAddress('IOS_00092', 'Vlan560', 2036375606, 1). -ipAddress('IOS_00092', 'Vlan561', 2036395962, 3). -ipAddress('IOS_00092', 'Vlan562', 2036372980, 1). -ipAddress('IOS_00092', 'Vlan563', 2036369459, 1). -ipAddress('IOS_00092', 'Vlan564', 2036396939, 9). -ipAddress('IOS_00092', 'Vlan565', 2036397106, 1). -ipAddress('IOS_00092', 'Vlan566', 2036369206, 3). -ipAddress('IOS_00092', 'Vlan567', 2036394162, 7). -ipAddress('IOS_00092', 'Vlan568', 2036396069, 1). -ipAddress('IOS_00092', 'Vlan569', 2036377955, 4). -ipAddress('IOS_00092', 'Vlan570', 2036391817, 7). -ipAddress('IOS_00092', 'Vlan571', 2036394712, 1). -ipAddress('IOS_00092', 'Vlan572', 2036367891, 2). -ipAddress('IOS_00092', 'Vlan573', 2036370600, 5). -ipAddress('IOS_00092', 'Vlan574', 2036367964, 3). -ipAddress('IOS_00092', 'Vlan575', 2036376626, 1). -ipAddress('IOS_00092', 'Vlan576', 2036368328, 1). -ipAddress('IOS_00092', 'Vlan577', 2036369988, 5). -ipAddress('IOS_00092', 'Vlan580', 2036391408, 5). -ipAddress('IOS_00092', 'Vlan581', 2036373136, 3). -ipAddress('IOS_00092', 'Vlan582', 2036367800, 7). -ipAddress('IOS_00092', 'Vlan583', 2036396077, 1). -ipAddress('IOS_00092', 'Vlan584', 2036399159, 2). -ipAddress('IOS_00092', 'Vlan585', 2036392193, 1). -ipAddress('IOS_00092', 'Vlan586', 2036367693, 5). -ipAddress('IOS_00092', 'Vlan587', 2036373420, 6). -ipAddress('IOS_00092', 'Vlan588', 2036387307, 9). -ipAddress('IOS_00092', 'Vlan800', 2036388411, 1). -ipAddress('IOS_00092', 'Vlan820', 2036387728, 8). -ipAddress('IOS_00092', 'Vlan837', 2036369359, 1). -ipAddress('IOS_00092', 'Vlan838', 2036368416, 3). -ipAddress('IOS_00092', 'Vlan839', 2036375040, 2). -ipAddress('IOS_00092', 'Vlan840', 2036395867, 3). -ipAddress('IOS_00092', 'Vlan885', 2036368388, 3). -ipAddress('IOS_00094', 'GigabitEthernet4/44', 2036369930, 0). -ipAddress('IOS_00096', 'FastEthernet0/0', 2036387617, 8). -ipAddress('IOS_00096', 'Loopback1', int(338), mask(339)). \ No newline at end of file diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/subnets-large.txt b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/subnets-large.txt deleted file mode 100644 index c819ec15b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/subnets-large.txt +++ /dev/null @@ -1,463 +0,0 @@ -subnet(['IOS_00022'-'Vlan172', 'IOS_00023'-'Vlan172']). -subnet(['IOS_00094'-'GigabitEthernet4/44']). -subnet(['IOS_00010'-'GigabitEthernet4/16', 'IOS_00011'-'GigabitEthernet0/2']). -subnet(['IOS_00039'-'Tunnel160']). -subnet(['IOS_00047'-'Hssi1/0']). -subnet(['IOS_00071'-'Hssi1/0']). -subnet(['IOS_00072'-'Serial1/0']). -subnet(['IOS_00012'-'POS5/0']). -subnet(['IOS_00082'-'Hssi1/0']). -subnet(['IOS_00083'-'Serial1/0']). -subnet(['IOS_00027'-'Hssi1/0']). -subnet(['IOS_00028'-'Serial1/0']). -subnet(['IOS_00039'-'Hssi1/0']). -subnet(['IOS_00040'-'Serial1/0']). -subnet(['IOS_00046'-'Hssi1/0']). -subnet(['IOS_00008'-'Vlan608', 'IOS_00009'-'Vlan608']). -subnet(['IOS_00026'-'Vlan701']). -subnet(['IOS_00026'-'Vlan702']). -subnet(['IOS_00026'-'Vlan703']). -subnet(['IOS_00026'-'Vlan704']). -subnet(['IOS_00037'-'Vlan790', 'IOS_00038'-'Vlan790']). -subnet(['IOS_00037'-'Vlan701', 'IOS_00038'-'Vlan701']). -subnet(['IOS_00037'-'Vlan702', 'IOS_00038'-'Vlan702']). -subnet(['IOS_00037'-'Vlan703', 'IOS_00038'-'Vlan703']). -subnet(['IOS_00037'-'Vlan704', 'IOS_00038'-'Vlan704']). -subnet(['IOS_00044'-'Vlan701', 'IOS_00045'-'Vlan701']). -subnet(['IOS_00044'-'Vlan702', 'IOS_00045'-'Vlan702']). -subnet(['IOS_00044'-'Vlan703', 'IOS_00045'-'Vlan703']). -subnet(['IOS_00044'-'Vlan704', 'IOS_00045'-'Vlan704']). -subnet(['IOS_00044'-'Vlan705', 'IOS_00045'-'Vlan705']). -subnet(['IOS_00044'-'Vlan706', 'IOS_00045'-'Vlan706']). -subnet(['IOS_00044'-'Vlan707', 'IOS_00045'-'Vlan707']). -subnet(['IOS_00044'-'Vlan708', 'IOS_00045'-'Vlan708']). -subnet(['IOS_00044'-'Vlan709', 'IOS_00045'-'Vlan709']). -subnet(['IOS_00044'-'Vlan710', 'IOS_00045'-'Vlan710']). -subnet(['IOS_00070'-'Vlan701']). -subnet(['IOS_00070'-'Vlan702']). -subnet(['IOS_00070'-'Vlan703']). -subnet(['IOS_00070'-'Vlan704']). -subnet(['IOS_00070'-'Vlan705']). -subnet(['IOS_00070'-'Vlan706']). -subnet(['IOS_00070'-'Vlan707']). -subnet(['IOS_00070'-'Vlan708']). -subnet(['IOS_00081'-'Vlan701']). -subnet(['IOS_00081'-'Vlan702']). -subnet(['IOS_00081'-'Vlan703']). -subnet(['IOS_00081'-'Vlan704']). -subnet(['IOS_00091'-'Vlan820', 'IOS_00092'-'Vlan820', 'IOS_00096'-'FastEthernet0/0']). -subnet(['IOS_00091'-'Vlan837', 'IOS_00092'-'Vlan837']). -subnet(['IOS_00091'-'Vlan838', 'IOS_00092'-'Vlan838']). -subnet(['IOS_00091'-'Vlan839', 'IOS_00092'-'Vlan839']). -subnet(['IOS_00091'-'Vlan840', 'IOS_00092'-'Vlan840']). -subnet(['IOS_00091'-'Vlan543', 'IOS_00092'-'Vlan543']). -subnet(['IOS_00091'-'Vlan587', 'IOS_00092'-'Vlan587']). -subnet(['IOS_00091'-'Vlan588', 'IOS_00092'-'Vlan588']). -subnet(['IOS_00091'-'Vlan545', 'IOS_00092'-'Vlan545']). -subnet(['IOS_00091'-'Vlan546', 'IOS_00092'-'Vlan546']). -subnet(['IOS_00091'-'Vlan547', 'IOS_00092'-'Vlan547']). -subnet(['IOS_00091'-'Vlan548', 'IOS_00092'-'Vlan548']). -subnet(['IOS_00091'-'Vlan549', 'IOS_00092'-'Vlan549']). -subnet(['IOS_00091'-'Vlan550', 'IOS_00092'-'Vlan550']). -subnet(['IOS_00091'-'Vlan551', 'IOS_00092'-'Vlan551']). -subnet(['IOS_00091'-'Vlan552', 'IOS_00092'-'Vlan552']). -subnet(['IOS_00091'-'Vlan553', 'IOS_00092'-'Vlan553']). -subnet(['IOS_00091'-'Vlan554', 'IOS_00092'-'Vlan554']). -subnet(['IOS_00091'-'Vlan556', 'IOS_00092'-'Vlan556']). -subnet(['IOS_00091'-'Vlan557', 'IOS_00092'-'Vlan557']). -subnet(['IOS_00091'-'Vlan558', 'IOS_00092'-'Vlan558']). -subnet(['IOS_00091'-'Vlan559', 'IOS_00092'-'Vlan559']). -subnet(['IOS_00091'-'Vlan560', 'IOS_00092'-'Vlan560']). -subnet(['IOS_00091'-'Vlan561', 'IOS_00092'-'Vlan561']). -subnet(['IOS_00091'-'Vlan562', 'IOS_00092'-'Vlan562']). -subnet(['IOS_00091'-'Vlan563', 'IOS_00092'-'Vlan563']). -subnet(['IOS_00091'-'Vlan564', 'IOS_00092'-'Vlan564']). -subnet(['IOS_00091'-'Vlan885', 'IOS_00092'-'Vlan885']). -subnet(['IOS_00091'-'Vlan544', 'IOS_00092'-'Vlan544']). -subnet(['IOS_00091'-'Vlan565', 'IOS_00092'-'Vlan565']). -subnet(['IOS_00091'-'Vlan566', 'IOS_00092'-'Vlan566']). -subnet(['IOS_00091'-'Vlan567', 'IOS_00092'-'Vlan567']). -subnet(['IOS_00091'-'Vlan568', 'IOS_00092'-'Vlan568']). -subnet(['IOS_00091'-'Vlan569', 'IOS_00092'-'Vlan569']). -subnet(['IOS_00091'-'Vlan570', 'IOS_00092'-'Vlan570']). -subnet(['IOS_00091'-'Vlan571', 'IOS_00092'-'Vlan571']). -subnet(['IOS_00091'-'Vlan572', 'IOS_00092'-'Vlan572']). -subnet(['IOS_00091'-'Vlan573', 'IOS_00092'-'Vlan573']). -subnet(['IOS_00091'-'Vlan574', 'IOS_00092'-'Vlan574']). -subnet(['IOS_00091'-'Vlan575', 'IOS_00092'-'Vlan575']). -subnet(['IOS_00091'-'Vlan576', 'IOS_00092'-'Vlan576']). -subnet(['IOS_00091'-'Vlan577', 'IOS_00092'-'Vlan577']). -subnet(['IOS_00091'-'Vlan580', 'IOS_00092'-'Vlan580']). -subnet(['IOS_00091'-'Vlan581', 'IOS_00092'-'Vlan581']). -subnet(['IOS_00091'-'Vlan582', 'IOS_00092'-'Vlan582']). -subnet(['IOS_00091'-'Vlan583', 'IOS_00092'-'Vlan583']). -subnet(['IOS_00091'-'Vlan584', 'IOS_00092'-'Vlan584']). -subnet(['IOS_00091'-'Vlan585', 'IOS_00092'-'Vlan585']). -subnet(['IOS_00091'-'Vlan586', 'IOS_00092'-'Vlan586']). -subnet(['IOS_00091'-'Vlan555', 'IOS_00092'-'Vlan555']). -subnet(['IOS_00091'-'Vlan800', 'IOS_00092'-'Vlan800']). -subnet(['IOS_00091'-'Loopback0']). -subnet(['IOS_00096'-'Loopback1']). -subnet(['IOS_00092'-'Loopback0']). -subnet(['IOS_00091'-'Vlan822', 'IOS_00092'-'Vlan822']). -subnet(['IOS_00091'-'Vlan821', 'IOS_00092'-'Vlan821']). -subnet(['IOS_00091'-'Vlan830', 'IOS_00092'-'Vlan830']). -subnet(['IOS_00091'-'Vlan825', 'IOS_00092'-'Vlan825']). -subnet(['IOS_00091'-'Vlan950', 'IOS_00092'-'Vlan950']). -subnet(['IOS_00091'-'Vlan823', 'IOS_00092'-'Vlan823']). -subnet(['IOS_00091'-'Vlan824', 'IOS_00092'-'Vlan824']). -subnet(['IOS_00091'-'Vlan831', 'IOS_00092'-'Vlan831']). -subnet(['IOS_00091'-'Vlan829', 'IOS_00092'-'Vlan829']). -subnet(['IOS_00091'-'Vlan832', 'IOS_00092'-'Vlan832']). -subnet(['IOS_00091'-'Vlan110', 'IOS_00092'-'Vlan110']). -subnet(['IOS_00091'-'Vlan833', 'IOS_00092'-'Vlan833']). -subnet(['IOS_00091'-'Vlan14', 'IOS_00092'-'Vlan14']). -subnet(['IOS_00091'-'Vlan834', 'IOS_00092'-'Vlan834']). -subnet(['IOS_00091'-'Vlan835', 'IOS_00092'-'Vlan835']). -subnet(['IOS_00091'-'Vlan836', 'IOS_00092'-'Vlan836']). -subnet(['IOS_00022'-'Vlan112', 'IOS_00023'-'Vlan112']). -subnet(['IOS_00022'-'Vlan115', 'IOS_00023'-'Vlan115']). -subnet(['IOS_00009'-'Vlan626']). -subnet(['IOS_00065'-'Loopback0']). -subnet(['IOS_00022'-'Loopback0']). -subnet(['IOS_00023'-'Loopback0']). -subnet(['IOS_00024'-'Loopback0']). -subnet(['IOS_00021'-'GigabitEthernet3/48', 'IOS_00008'-'Vlan620', 'IOS_00009'-'Vlan620', 'IOS_00016'-'FastEthernet0/0']). -subnet(['IOS_00008'-'Vlan643', 'IOS_00009'-'Vlan643']). -subnet(['IOS_00008'-'Vlan644', 'IOS_00009'-'Vlan644']). -subnet(['IOS_00008'-'Vlan645', 'IOS_00009'-'Vlan645']). -subnet(['IOS_00001'-'Vlan699', 'IOS_00018'-'Vlan699', 'IOS_00002'-'Vlan699']). -subnet(['IOS_00001'-'Vlan639', 'IOS_00002'-'Vlan639']). -subnet(['IOS_00001'-'Vlan14', 'IOS_00002'-'Vlan14', 'IOS_00003'-'Vlan714', 'IOS_00004'-'Vlan714']). -subnet(['IOS_00008'-'Vlan623', 'IOS_00009'-'Vlan623']). -subnet(['IOS_00009'-'Vlan609']). -subnet(['IOS_00009'-'GigabitEthernet6/3']). -subnet(['IOS_00009'-'GigabitEthernet6/4']). -subnet(['IOS_00008'-'GigabitEthernet6/3']). -subnet(['IOS_00008'-'GigabitEthernet6/4']). -subnet(['IOS_00008'-'Vlan601', 'IOS_00009'-'Vlan601']). -subnet(['IOS_00001'-'Vlan602', 'IOS_00002'-'Vlan602']). -subnet(['IOS_00001'-'Vlan613', 'IOS_00002'-'Vlan613']). -subnet(['IOS_00001'-'Loopback0']). -subnet(['IOS_00016'-'Loopback1']). -subnet(['IOS_00002'-'Loopback0']). -subnet(['IOS_00006'-'Loopback0']). -subnet(['IOS_00008'-'Loopback0']). -subnet(['IOS_00009'-'Loopback0']). -subnet(['IOS_00015'-'Loopback0']). -subnet(['IOS_00017'-'Loopback0']). -subnet(['IOS_00008'-'Vlan622', 'IOS_00009'-'Vlan622']). -subnet(['IOS_00008'-'Vlan621', 'IOS_00009'-'Vlan621']). -subnet(['IOS_00008'-'Vlan624', 'IOS_00009'-'Vlan624']). -subnet(['IOS_00001'-'Vlan110', 'IOS_00002'-'Vlan110']). -subnet(['IOS_00008'-'Vlan699', 'IOS_00009'-'Vlan699']). -subnet(['IOS_00001'-'GigabitEthernet1/2', 'IOS_00015'-'FastEthernet1/0']). -subnet(['IOS_00002'-'GigabitEthernet1/2', 'IOS_00015'-'FastEthernet1/1']). -subnet(['IOS_00001'-'Vlan616', 'IOS_00002'-'Vlan616']). -subnet(['IOS_00001'-'Vlan609', 'IOS_00002'-'Vlan609', 'IOS_00017'-'Vlan609']). -subnet(['IOS_00008'-'Vlan637', 'IOS_00009'-'Vlan637']). -subnet(['IOS_00008'-'Vlan641', 'IOS_00009'-'Vlan641']). -subnet(['IOS_00008'-'Vlan642', 'IOS_00009'-'Vlan642']). -subnet(['IOS_00035'-'Vlan100', 'IOS_00036'-'Vlan100', 'IOS_00026'-'Vlan100', 'IOS_00029'-'FastEthernet0/0', 'IOS_00031'-'Vlan100', 'IOS_00032'-'Vlan100', 'IOS_00033'-'Vlan100', 'IOS_00034'-'Vlan100']). -subnet(['IOS_00026'-'Loopback0']). -subnet(['IOS_00030'-'Loopback0']). -subnet(['IOS_00029'-'Loopback1']). -subnet(['IOS_00026'-'Vlan110']). -subnet(['IOS_00026'-'Vlan513']). -subnet(['IOS_00026'-'Vlan400']). -subnet(['IOS_00026'-'Vlan501']). -subnet(['IOS_00028'-'Loopback0']). -subnet(['IOS_00040'-'Loopback0']). -subnet(['IOS_00047'-'Loopback0']). -subnet(['IOS_00012'-'Loopback0']). -subnet(['IOS_00072'-'Loopback0']). -subnet(['IOS_00083'-'Loopback0']). -subnet(['IOS_00026'-'Vlan502']). -subnet(['IOS_00069'-'Vlan200', 'IOS_00066'-'Vlan200', 'IOS_00067'-'Vlan200', 'IOS_00068'-'Vlan200']). -subnet(['IOS_00005'-'Loopback0']). -subnet(['IOS_00026'-'Vlan503']). -subnet(['IOS_00026'-'Vlan504']). -subnet(['IOS_00037'-'Vlan100', 'IOS_00038'-'Vlan100', 'IOS_00041'-'FastEthernet0/0']). -subnet(['IOS_00037'-'Loopback0']). -subnet(['IOS_00038'-'Loopback0']). -subnet(['IOS_00042'-'Loopback0']). -subnet(['IOS_00043'-'Loopback0']). -subnet(['IOS_00041'-'Loopback1']). -subnet(['IOS_00037'-'Vlan110', 'IOS_00038'-'Vlan110']). -subnet(['IOS_00037'-'Vlan513', 'IOS_00038'-'Vlan513']). -subnet(['IOS_00037'-'Vlan400', 'IOS_00038'-'Vlan400']). -subnet(['IOS_00037'-'Vlan401', 'IOS_00038'-'Vlan401']). -subnet(['IOS_00037'-'Vlan501', 'IOS_00038'-'Vlan501']). -subnet(['IOS_00037'-'Vlan502', 'IOS_00038'-'Vlan502']). -subnet(['IOS_00037'-'Vlan503', 'IOS_00038'-'Vlan503']). -subnet(['IOS_00037'-'Vlan504', 'IOS_00038'-'Vlan504']). -subnet(['IOS_00037'-'GigabitEthernet2/1', 'IOS_00038'-'GigabitEthernet2/1']). -subnet(['IOS_00037'-'Vlan940', 'IOS_00038'-'Vlan940']). -subnet(['IOS_00037'-'GigabitEthernet3/1', 'IOS_00042'-'GigabitEthernet0/0']). -subnet(['IOS_00038'-'GigabitEthernet3/1', 'IOS_00043'-'GigabitEthernet0/0']). -subnet(['IOS_00037'-'Vlan950', 'IOS_00038'-'Vlan950']). -subnet(['IOS_00027'-'Loopback0']). -subnet(['IOS_00039'-'Loopback0']). -subnet(['IOS_00046'-'Loopback0']). -subnet(['IOS_00071'-'Loopback0']). -subnet(['IOS_00082'-'Loopback0']). -subnet(['IOS_00026'-'Vlan940']). -subnet(['IOS_00026'-'FastEthernet4/1', 'IOS_00030'-'FastEthernet0/0']). -subnet(['IOS_00026'-'Vlan950']). -subnet(['IOS_00055'-'Vlan100', 'IOS_00059'-'Vlan100', 'IOS_00060'-'Vlan100', 'IOS_00044'-'Vlan100', 'IOS_00061'-'Vlan100', 'IOS_00045'-'Vlan100', 'IOS_00062'-'Vlan100', 'IOS_00063'-'Vlan100', 'IOS_00064'-'Vlan100', 'IOS_00048'-'FastEthernet0/0', 'IOS_00051'-'Vlan100']). -subnet(['IOS_00044'-'Loopback0']). -subnet(['IOS_00045'-'Loopback0']). -subnet(['IOS_00049'-'Loopback0']). -subnet(['IOS_00050'-'Loopback0']). -subnet(['IOS_00048'-'Loopback1']). -subnet(['IOS_00044'-'Vlan110', 'IOS_00045'-'Vlan110']). -subnet(['IOS_00044'-'Vlan513', 'IOS_00045'-'Vlan513']). -subnet(['IOS_00044'-'Vlan400', 'IOS_00045'-'Vlan400']). -subnet(['IOS_00044'-'Vlan401', 'IOS_00045'-'Vlan401']). -subnet(['IOS_00044'-'Vlan501', 'IOS_00045'-'Vlan501']). -subnet(['IOS_00044'-'Vlan502', 'IOS_00045'-'Vlan502']). -subnet(['IOS_00044'-'Vlan503', 'IOS_00045'-'Vlan503']). -subnet(['IOS_00044'-'Vlan504', 'IOS_00045'-'Vlan504']). -subnet(['IOS_00044'-'Vlan505', 'IOS_00045'-'Vlan505']). -subnet(['IOS_00044'-'Vlan506', 'IOS_00045'-'Vlan506']). -subnet(['IOS_00044'-'Vlan507', 'IOS_00045'-'Vlan507']). -subnet(['IOS_00044'-'Vlan508', 'IOS_00045'-'Vlan508']). -subnet(['IOS_00044'-'Vlan509', 'IOS_00045'-'Vlan509']). -subnet(['IOS_00044'-'Vlan510', 'IOS_00045'-'Vlan510']). -subnet(['IOS_00044'-'GigabitEthernet2/18', 'IOS_00045'-'GigabitEthernet2/18']). -subnet(['IOS_00044'-'Vlan940', 'IOS_00045'-'Vlan940']). -subnet(['IOS_00044'-'GigabitEthernet4/1', 'IOS_00049'-'GigabitEthernet0/0']). -subnet(['IOS_00045'-'GigabitEthernet4/1', 'IOS_00050'-'GigabitEthernet0/0']). -subnet(['IOS_00044'-'Vlan950', 'IOS_00045'-'Vlan950']). -subnet(['IOS_00070'-'Vlan100', 'IOS_00073'-'FastEthernet0/0', 'IOS_00076'-'Vlan100', 'IOS_00077'-'Vlan100', 'IOS_00078'-'Vlan100', 'IOS_00079'-'Vlan100', 'IOS_00080'-'Vlan100']). -subnet(['IOS_00070'-'Loopback0']). -subnet(['IOS_00074'-'Loopback0']). -subnet(['IOS_00075'-'Loopback0']). -subnet(['IOS_00073'-'Loopback1']). -subnet(['IOS_00070'-'Vlan110']). -subnet(['IOS_00070'-'Vlan513']). -subnet(['IOS_00070'-'Vlan400']). -subnet(['IOS_00070'-'Vlan401']). -subnet(['IOS_00070'-'Vlan501']). -subnet(['IOS_00070'-'Vlan502']). -subnet(['IOS_00070'-'Vlan503']). -subnet(['IOS_00070'-'Vlan504']). -subnet(['IOS_00070'-'Vlan505']). -subnet(['IOS_00070'-'Vlan506']). -subnet(['IOS_00070'-'Vlan507']). -subnet(['IOS_00070'-'Vlan508']). -subnet(['IOS_00070'-'GigabitEthernet2/2', 'IOS_00074'-'GigabitEthernet0/0']). -subnet(['IOS_00070'-'GigabitEthernet1/2', 'IOS_00075'-'GigabitEthernet0/0']). -subnet(['IOS_00070'-'Vlan950']). -subnet(['IOS_00070'-'Vlan940']). -subnet(['IOS_00086'-'Vlan100', 'IOS_00087'-'Vlan100', 'IOS_00088'-'Vlan100', 'IOS_00081'-'Vlan100', 'IOS_00084'-'FastEthernet0/0']). -subnet(['IOS_00081'-'Loopback0']). -subnet(['IOS_00085'-'Loopback0']). -subnet(['IOS_00084'-'Loopback1']). -subnet(['IOS_00081'-'Vlan110']). -subnet(['IOS_00081'-'Vlan400']). -subnet(['IOS_00081'-'Vlan513']). -subnet(['IOS_00081'-'Vlan501']). -subnet(['IOS_00081'-'Vlan502']). -subnet(['IOS_00081'-'Vlan503']). -subnet(['IOS_00081'-'Vlan504']). -subnet(['IOS_00081'-'GigabitEthernet2/2', 'IOS_00085'-'FastEthernet0/0']). -subnet(['IOS_00081'-'Vlan950']). -subnet(['IOS_00081'-'Vlan940']). -subnet(['IOS_00093'-'Vlan798', 'IOS_00094'-'Vlan798', 'IOS_00097'-'Vlan798', 'IOS_00098'-'Vlan798', 'IOS_00099'-'Vlan798', 'IOS_00100'-'Vlan798']). -subnet(['IOS_00091'-'Vlan701', 'IOS_00092'-'Vlan701']). -subnet(['IOS_00091'-'Vlan710', 'IOS_00092'-'Vlan710']). -subnet(['IOS_00093'-'Vlan772', 'IOS_00094'-'Vlan772']). -subnet(['IOS_00002'-'GigabitEthernet1/24', 'IOS_00004'-'GigabitEthernet2/11']). -subnet(['IOS_00001'-'GigabitEthernet1/24', 'IOS_00003'-'GigabitEthernet2/12']). -subnet(['IOS_00093'-'Vlan771', 'IOS_00094'-'Vlan771']). -subnet(['IOS_00093'-'Vlan780', 'IOS_00095'-'FastEthernet0/0']). -subnet(['IOS_00003'-'Vlan770', 'IOS_00004'-'Vlan770']). -subnet(['IOS_00091'-'Vlan711', 'IOS_00092'-'Vlan711']). -subnet(['IOS_00091'-'Vlan712', 'IOS_00092'-'Vlan712']). -subnet(['IOS_00089'-'GigabitEthernet1/0', 'IOS_00091'-'Vlan778']). -subnet(['IOS_00090'-'FastEthernet2/0']). -subnet(['IOS_00090'-'FastEthernet1/0']). -subnet(['IOS_00089'-'FastEthernet1/0']). -subnet(['IOS_00090'-'GigabitEthernet1/0', 'IOS_00092'-'Vlan779']). -subnet(['IOS_00093'-'Vlan775', 'IOS_00094'-'Vlan775']). -subnet(['IOS_00093'-'Vlan774', 'IOS_00094'-'Vlan774']). -subnet(['IOS_00093'-'Vlan781']). -subnet(['IOS_00093'-'Vlan776', 'IOS_00094'-'Vlan776']). -subnet(['IOS_00093'-'Vlan777', 'IOS_00094'-'Vlan777']). -subnet(['IOS_00093'-'Vlan773', 'IOS_00094'-'Vlan773']). -subnet(['IOS_00022'-'Vlan770', 'IOS_00023'-'Vlan770']). -subnet(['IOS_00022'-'Vlan771', 'IOS_00023'-'Vlan771']). -subnet(['IOS_00091'-'Vlan713', 'IOS_00092'-'Vlan713']). -subnet(['IOS_00022'-'Vlan793', 'IOS_00025'-'FastEthernet0/0']). -subnet(['IOS_00003'-'Vlan766', 'IOS_00004'-'Vlan766']). -subnet(['IOS_00003'-'Vlan798', 'IOS_00004'-'Vlan798']). -subnet(['IOS_00003'-'Vlan797', 'IOS_00004'-'Vlan797']). -subnet(['IOS_00003'-'Vlan795', 'IOS_00004'-'Vlan795']). -subnet(['IOS_00003'-'Vlan796', 'IOS_00004'-'Vlan796']). -subnet(['IOS_00091'-'Vlan714', 'IOS_00092'-'Vlan714']). -subnet(['IOS_00003'-'Vlan759']). -subnet(['IOS_00003'-'Vlan757', 'IOS_00004'-'Vlan757']). -subnet(['IOS_00003'-'Vlan763', 'IOS_00004'-'Vlan763']). -subnet(['IOS_00003'-'Vlan758']). -subnet(['IOS_00003'-'Vlan760', 'IOS_00004'-'Vlan760']). -subnet(['IOS_00003'-'Vlan756', 'IOS_00004'-'Vlan756']). -subnet(['IOS_00091'-'Vlan715', 'IOS_00092'-'Vlan715']). -subnet(['IOS_00003'-'Vlan754', 'IOS_00004'-'Vlan754']). -subnet(['IOS_00003'-'Vlan753', 'IOS_00004'-'Vlan753']). -subnet(['IOS_00091'-'Vlan716', 'IOS_00092'-'Vlan716']). -subnet(['IOS_00003'-'Vlan792', 'IOS_00004'-'Vlan792']). -subnet(['IOS_00091'-'Vlan717', 'IOS_00092'-'Vlan717']). -subnet(['IOS_00091'-'Vlan718', 'IOS_00092'-'Vlan718']). -subnet(['IOS_00003'-'Vlan790', 'IOS_00005'-'GigabitEthernet0/0']). -subnet(['IOS_00004'-'Vlan791', 'IOS_00005'-'GigabitEthernet0/1']). -subnet(['IOS_00004'-'Vlan780', 'IOS_00007'-'GigabitEthernet0/0']). -subnet(['IOS_00003'-'Vlan761', 'IOS_00004'-'Vlan761']). -subnet(['IOS_00091'-'Vlan719', 'IOS_00092'-'Vlan719']). -subnet(['IOS_00091'-'Vlan702', 'IOS_00092'-'Vlan702']). -subnet(['IOS_00091'-'Vlan720', 'IOS_00092'-'Vlan720']). -subnet(['IOS_00091'-'Vlan721', 'IOS_00092'-'Vlan721']). -subnet(['IOS_00091'-'Vlan722', 'IOS_00092'-'Vlan722']). -subnet(['IOS_00091'-'Vlan723', 'IOS_00092'-'Vlan723']). -subnet(['IOS_00091'-'Vlan724', 'IOS_00092'-'Vlan724']). -subnet(['IOS_00091'-'Vlan725', 'IOS_00092'-'Vlan725']). -subnet(['IOS_00091'-'Vlan726', 'IOS_00092'-'Vlan726']). -subnet(['IOS_00091'-'Vlan727', 'IOS_00092'-'Vlan727']). -subnet(['IOS_00091'-'Vlan728', 'IOS_00092'-'Vlan728']). -subnet(['IOS_00091'-'Vlan729', 'IOS_00092'-'Vlan729']). -subnet(['IOS_00091'-'Vlan703', 'IOS_00092'-'Vlan703']). -subnet(['IOS_00091'-'Vlan730', 'IOS_00092'-'Vlan730']). -subnet(['IOS_00091'-'Vlan731', 'IOS_00092'-'Vlan731']). -subnet(['IOS_00091'-'Vlan732', 'IOS_00092'-'Vlan732']). -subnet(['IOS_00091'-'Vlan733', 'IOS_00092'-'Vlan733']). -subnet(['IOS_00091'-'Vlan734', 'IOS_00092'-'Vlan734']). -subnet(['IOS_00091'-'Vlan735', 'IOS_00092'-'Vlan735']). -subnet(['IOS_00091'-'Vlan736', 'IOS_00092'-'Vlan736']). -subnet(['IOS_00091'-'Vlan737', 'IOS_00092'-'Vlan737']). -subnet(['IOS_00091'-'Vlan738', 'IOS_00092'-'Vlan738']). -subnet(['IOS_00091'-'Vlan739', 'IOS_00092'-'Vlan739']). -subnet(['IOS_00091'-'Vlan704', 'IOS_00092'-'Vlan704']). -subnet(['IOS_00091'-'Vlan740', 'IOS_00092'-'Vlan740']). -subnet(['IOS_00091'-'Vlan741', 'IOS_00092'-'Vlan741']). -subnet(['IOS_00091'-'Vlan742', 'IOS_00092'-'Vlan742']). -subnet(['IOS_00093'-'Vlan803', 'IOS_00094'-'Vlan803']). -subnet(['IOS_00093'-'Vlan804', 'IOS_00094'-'Vlan804']). -subnet(['IOS_00091'-'Vlan745', 'IOS_00092'-'Vlan745']). -subnet(['IOS_00091'-'Vlan746', 'IOS_00092'-'Vlan746']). -subnet(['IOS_00091'-'Vlan747', 'IOS_00092'-'Vlan747']). -subnet(['IOS_00091'-'Vlan748', 'IOS_00092'-'Vlan748']). -subnet(['IOS_00091'-'Vlan749', 'IOS_00092'-'Vlan749']). -subnet(['IOS_00091'-'Vlan705', 'IOS_00092'-'Vlan705']). -subnet(['IOS_00093'-'Vlan810', 'IOS_00094'-'Vlan810']). -subnet(['IOS_00091'-'Vlan751', 'IOS_00092'-'Vlan751']). -subnet(['IOS_00091'-'Vlan752', 'IOS_00092'-'Vlan752']). -subnet(['IOS_00091'-'Vlan753', 'IOS_00092'-'Vlan753']). -subnet(['IOS_00091'-'Vlan754', 'IOS_00092'-'Vlan754']). -subnet(['IOS_00091'-'Vlan755', 'IOS_00092'-'Vlan755']). -subnet(['IOS_00091'-'Vlan756', 'IOS_00092'-'Vlan756']). -subnet(['IOS_00091'-'Vlan757', 'IOS_00092'-'Vlan757']). -subnet(['IOS_00091'-'Vlan758', 'IOS_00092'-'Vlan758']). -subnet(['IOS_00091'-'Vlan759', 'IOS_00092'-'Vlan759']). -subnet(['IOS_00091'-'Vlan706', 'IOS_00092'-'Vlan706']). -subnet(['IOS_00091'-'Vlan760', 'IOS_00092'-'Vlan760']). -subnet(['IOS_00091'-'Vlan761', 'IOS_00092'-'Vlan761']). -subnet(['IOS_00091'-'Vlan762', 'IOS_00092'-'Vlan762']). -subnet(['IOS_00091'-'Vlan763', 'IOS_00092'-'Vlan763']). -subnet(['IOS_00091'-'Vlan764', 'IOS_00092'-'Vlan764']). -subnet(['IOS_00091'-'Vlan765', 'IOS_00092'-'Vlan765']). -subnet(['IOS_00091'-'Vlan766', 'IOS_00092'-'Vlan766']). -subnet(['IOS_00091'-'Vlan767', 'IOS_00092'-'Vlan767']). -subnet(['IOS_00091'-'Vlan768', 'IOS_00092'-'Vlan768']). -subnet(['IOS_00091'-'Vlan769', 'IOS_00092'-'Vlan769']). -subnet(['IOS_00091'-'Vlan707', 'IOS_00092'-'Vlan707']). -subnet(['IOS_00091'-'Vlan770', 'IOS_00092'-'Vlan770']). -subnet(['IOS_00091'-'Vlan771', 'IOS_00092'-'Vlan771']). -subnet(['IOS_00091'-'Vlan772', 'IOS_00092'-'Vlan772']). -subnet(['IOS_00091'-'Vlan773', 'IOS_00092'-'Vlan773']). -subnet(['IOS_00091'-'Vlan774', 'IOS_00092'-'Vlan774']). -subnet(['IOS_00091'-'Vlan775', 'IOS_00092'-'Vlan775']). -subnet(['IOS_00091'-'Vlan776', 'IOS_00092'-'Vlan776']). -subnet(['IOS_00091'-'Vlan777', 'IOS_00092'-'Vlan777']). -subnet(['IOS_00093'-'Vlan839', 'IOS_00094'-'Vlan839']). -subnet(['IOS_00091'-'Vlan708', 'IOS_00092'-'Vlan708']). -subnet(['IOS_00093'-'Vlan840', 'IOS_00094'-'Vlan840']). -subnet(['IOS_00091'-'Vlan781', 'IOS_00092'-'Vlan781']). -subnet(['IOS_00091'-'Vlan782', 'IOS_00092'-'Vlan782']). -subnet(['IOS_00091'-'Vlan783', 'IOS_00092'-'Vlan783']). -subnet(['IOS_00091'-'Vlan784', 'IOS_00092'-'Vlan784']). -subnet(['IOS_00091'-'Vlan785', 'IOS_00092'-'Vlan785']). -subnet(['IOS_00091'-'Vlan786', 'IOS_00092'-'Vlan786']). -subnet(['IOS_00091'-'Vlan787', 'IOS_00092'-'Vlan787']). -subnet(['IOS_00091'-'Vlan788', 'IOS_00092'-'Vlan788']). -subnet(['IOS_00091'-'Vlan743', 'IOS_00092'-'Vlan743']). -subnet(['IOS_00091'-'Vlan709', 'IOS_00092'-'Vlan709']). -subnet(['IOS_00091'-'Vlan780', 'IOS_00092'-'Vlan780']). -subnet(['IOS_00091'-'Vlan744', 'IOS_00092'-'Vlan744']). -subnet(['IOS_00091'-'Vlan750', 'IOS_00092'-'Vlan750']). -subnet(['IOS_00037'-'GigabitEthernet2/2', 'IOS_00039'-'GigabitEthernet0/1']). -subnet(['IOS_00038'-'GigabitEthernet3/2', 'IOS_00040'-'GigabitEthernet0/0']). -subnet(['IOS_00044'-'GigabitEthernet3/1', 'IOS_00046'-'GigabitEthernet0/1']). -subnet(['IOS_00045'-'GigabitEthernet3/1', 'IOS_00047'-'GigabitEthernet0/1']). -subnet(['IOS_00070'-'GigabitEthernet1/1', 'IOS_00071'-'GigabitEthernet0/1']). -subnet(['IOS_00070'-'GigabitEthernet2/1', 'IOS_00072'-'GigabitEthernet0/1']). -subnet(['IOS_00026'-'GigabitEthernet2/1', 'IOS_00027'-'GigabitEthernet0/1']). -subnet(['IOS_00026'-'FastEthernet3/1', 'IOS_00028'-'GigabitEthernet0/0']). -subnet(['IOS_00081'-'FastEthernet3/1', 'IOS_00083'-'GigabitEthernet0/0']). -subnet(['IOS_00081'-'GigabitEthernet2/1', 'IOS_00082'-'GigabitEthernet0/1']). -subnet(['IOS_00022'-'Vlan113']). -subnet(['IOS_00071'-'Tunnel150', 'IOS_00072'-'Tunnel150', 'IOS_00039'-'Tunnel150', 'IOS_00040'-'Tunnel150', 'IOS_00027'-'Tunnel150', 'IOS_00028'-'Tunnel150', 'IOS_00012'-'Tunnel150', 'IOS_00046'-'Tunnel150', 'IOS_00047'-'Tunnel150', 'IOS_00082'-'Tunnel150', 'IOS_00083'-'Tunnel150']). -subnet(['IOS_00001'-'Loopback10', 'IOS_00091'-'Loopback10']). -subnet(['IOS_00039'-'GigabitEthernet0/2', 'IOS_00040'-'GigabitEthernet0/1']). -subnet(['IOS_00082'-'GigabitEthernet0/2', 'IOS_00083'-'GigabitEthernet0/1']). -subnet(['IOS_00027'-'GigabitEthernet0/2', 'IOS_00028'-'GigabitEthernet0/1']). -subnet(['IOS_00071'-'GigabitEthernet0/2', 'IOS_00072'-'GigabitEthernet0/2']). -subnet(['IOS_00046'-'GigabitEthernet0/2', 'IOS_00047'-'GigabitEthernet0/2']). -subnet(['IOS_00002'-'GigabitEthernet3/4', 'IOS_00012'-'GigabitEthernet0/2']). -subnet(['IOS_00001'-'GigabitEthernet3/4', 'IOS_00012'-'GigabitEthernet0/1']). -subnet(['IOS_00093'-'GigabitEthernet4/36']). -subnet(['IOS_00091'-'GigabitEthernet9/1', 'IOS_00092'-'GigabitEthernet9/1', 'IOS_00065'-'FastEthernet0/0']). -subnet(['IOS_00015'-'FastEthernet0/0']). -subnet(['IOS_00008'-'Vlan606']). -subnet(['IOS_00009'-'Vlan607']). -subnet(['IOS_00001'-'GigabitEthernet3/7', 'IOS_00091'-'GigabitEthernet9/4']). -subnet(['IOS_00002'-'Vlan612']). -subnet(['IOS_00011'-'GigabitEthernet0/3']). -subnet(['IOS_00091'-'TenGigabitEthernet10/4', 'IOS_00092'-'TenGigabitEthernet10/4']). -subnet(['IOS_00023'-'FastEthernet2/6', 'IOS_00024'-'GigabitEthernet0/1']). -subnet(['IOS_00006'-'Hssi1/0', 'IOS_00024'-'Hssi1/0']). -subnet(['IOS_00001'-'GigabitEthernet2/6', 'IOS_00006'-'GigabitEthernet0/1']). -subnet(['IOS_00001'-'TenGigabitEthernet4/3', 'IOS_00008'-'TenGigabitEthernet9/3']). -subnet(['IOS_00001'-'TenGigabitEthernet4/4', 'IOS_00002'-'TenGigabitEthernet4/4']). -subnet(['IOS_00002'-'TenGigabitEthernet4/3', 'IOS_00009'-'TenGigabitEthernet9/3']). -subnet(['IOS_00008'-'Vlan610', 'IOS_00009'-'Vlan610']). -subnet(['IOS_00010'-'Vlan580']). -subnet(['IOS_00065'-'FastEthernet0/1']). -subnet(['IOS_00092'-'Vlan819', 'IOS_00094'-'Vlan796']). -subnet(['IOS_00091'-'Vlan818', 'IOS_00093'-'Vlan795']). -subnet(['IOS_00001'-'Vlan631', 'IOS_00002'-'Vlan631']). -subnet(['IOS_00003'-'Vlan794', 'IOS_00004'-'Vlan794']). -subnet(['IOS_00039'-'GigabitEthernet0/3']). -subnet(['IOS_00091'-'Vlan815', 'IOS_00092'-'Vlan815']). -subnet(['IOS_00093'-'Vlan794', 'IOS_00094'-'Vlan794']). -subnet(['IOS_00011'-'Loopback0']). -subnet(['IOS_00010'-'Loopback0']). -subnet(['IOS_00013'-'Loopback0']). -subnet(['IOS_00014'-'Loopback0']). -subnet(['IOS_00019'-'Vlan430', 'IOS_00020'-'Vlan430', 'IOS_00010'-'Vlan430']). -subnet(['IOS_00010'-'Vlan500']). -subnet(['IOS_00010'-'Vlan510']). -subnet(['IOS_00010'-'GigabitEthernet1/48', 'IOS_00014'-'GigabitEthernet0/1']). -subnet(['IOS_00010'-'GigabitEthernet2/9', 'IOS_00014'-'GigabitEthernet0/2']). -subnet(['IOS_00010'-'Vlan540']). -subnet(['IOS_00010'-'Vlan550']). -subnet(['IOS_00010'-'Vlan570']). -subnet(['IOS_00018'-'Vlan44']). -subnet(['IOS_00013'-'GigabitEthernet4/1']). -subnet(['IOS_00013'-'GigabitEthernet1/11']). -subnet(['IOS_00013'-'GigabitEthernet1/10']). -subnet(['IOS_00013'-'GigabitEthernet1/9']). -subnet(['IOS_00013'-'Vlan800']). -subnet(['IOS_00013'-'GigabitEthernet1/1']). -subnet(['IOS_00052'-'Vlan78', 'IOS_00053'-'Vlan78', 'IOS_00054'-'Vlan78', 'IOS_00056'-'Vlan78', 'IOS_00057'-'Vlan78', 'IOS_00058'-'Vlan78']). -subnet(['IOS_00011'-'GigabitEthernet0/1']). -subnet(['IOS_00011'-'Loopback10']). \ No newline at end of file diff --git a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/subnets.txt b/org.alloytools.kodkod.core/src/test/java/examples/netconfig/subnets.txt deleted file mode 100644 index 783d345ce..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/netconfig/subnets.txt +++ /dev/null @@ -1,99 +0,0 @@ -subnet(['IOS_00022'-'Vlan172', 'IOS_00023'-'Vlan172']). -subnet(['IOS_00094'-'GigabitEthernet4/44']). -subnet(['IOS_00010'-'GigabitEthernet4/16', 'IOS_00011'-'GigabitEthernet0/2']). -subnet(['IOS_00039'-'Tunnel160']). -subnet(['IOS_00047'-'Hssi1/0']). -subnet(['IOS_00071'-'Hssi1/0']). -subnet(['IOS_00072'-'Serial1/0']). -subnet(['IOS_00012'-'POS5/0']). -subnet(['IOS_00082'-'Hssi1/0']). -subnet(['IOS_00083'-'Serial1/0']). -subnet(['IOS_00027'-'Hssi1/0']). -subnet(['IOS_00028'-'Serial1/0']). -subnet(['IOS_00039'-'Hssi1/0']). -subnet(['IOS_00040'-'Serial1/0']). -subnet(['IOS_00046'-'Hssi1/0']). -subnet(['IOS_00008'-'Vlan608', 'IOS_00009'-'Vlan608']). -subnet(['IOS_00026'-'Vlan701']). -subnet(['IOS_00026'-'Vlan702']). -subnet(['IOS_00026'-'Vlan703']). -subnet(['IOS_00026'-'Vlan704']). -subnet(['IOS_00037'-'Vlan790', 'IOS_00038'-'Vlan790']). -subnet(['IOS_00037'-'Vlan701', 'IOS_00038'-'Vlan701']). -subnet(['IOS_00037'-'Vlan702', 'IOS_00038'-'Vlan702']). -subnet(['IOS_00037'-'Vlan703', 'IOS_00038'-'Vlan703']). -subnet(['IOS_00037'-'Vlan704', 'IOS_00038'-'Vlan704']). -subnet(['IOS_00044'-'Vlan701', 'IOS_00045'-'Vlan701']). -subnet(['IOS_00044'-'Vlan702', 'IOS_00045'-'Vlan702']). -subnet(['IOS_00044'-'Vlan703', 'IOS_00045'-'Vlan703']). -subnet(['IOS_00044'-'Vlan704', 'IOS_00045'-'Vlan704']). -subnet(['IOS_00044'-'Vlan705', 'IOS_00045'-'Vlan705']). -subnet(['IOS_00044'-'Vlan706', 'IOS_00045'-'Vlan706']). -subnet(['IOS_00044'-'Vlan707', 'IOS_00045'-'Vlan707']). -subnet(['IOS_00044'-'Vlan708', 'IOS_00045'-'Vlan708']). -subnet(['IOS_00044'-'Vlan709', 'IOS_00045'-'Vlan709']). -subnet(['IOS_00044'-'Vlan710', 'IOS_00045'-'Vlan710']). -subnet(['IOS_00070'-'Vlan701']). -subnet(['IOS_00070'-'Vlan702']). -subnet(['IOS_00070'-'Vlan703']). -subnet(['IOS_00070'-'Vlan704']). -subnet(['IOS_00070'-'Vlan705']). -subnet(['IOS_00070'-'Vlan706']). -subnet(['IOS_00070'-'Vlan707']). -subnet(['IOS_00070'-'Vlan708']). -subnet(['IOS_00081'-'Vlan701']). -subnet(['IOS_00081'-'Vlan702']). -subnet(['IOS_00081'-'Vlan703']). -subnet(['IOS_00081'-'Vlan704']). -subnet(['IOS_00091'-'Vlan820', 'IOS_00092'-'Vlan820', 'IOS_00096'-'FastEthernet0/0']). -subnet(['IOS_00091'-'Vlan837', 'IOS_00092'-'Vlan837']). -subnet(['IOS_00091'-'Vlan838', 'IOS_00092'-'Vlan838']). -subnet(['IOS_00091'-'Vlan839', 'IOS_00092'-'Vlan839']). -subnet(['IOS_00091'-'Vlan840', 'IOS_00092'-'Vlan840']). -subnet(['IOS_00091'-'Vlan543', 'IOS_00092'-'Vlan543']). -subnet(['IOS_00091'-'Vlan587', 'IOS_00092'-'Vlan587']). -subnet(['IOS_00091'-'Vlan588', 'IOS_00092'-'Vlan588']). -subnet(['IOS_00091'-'Vlan545', 'IOS_00092'-'Vlan545']). -subnet(['IOS_00091'-'Vlan546', 'IOS_00092'-'Vlan546']). -subnet(['IOS_00091'-'Vlan547', 'IOS_00092'-'Vlan547']). -subnet(['IOS_00091'-'Vlan548', 'IOS_00092'-'Vlan548']). -subnet(['IOS_00091'-'Vlan549', 'IOS_00092'-'Vlan549']). -subnet(['IOS_00091'-'Vlan550', 'IOS_00092'-'Vlan550']). -subnet(['IOS_00091'-'Vlan551', 'IOS_00092'-'Vlan551']). -subnet(['IOS_00091'-'Vlan552', 'IOS_00092'-'Vlan552']). -subnet(['IOS_00091'-'Vlan553', 'IOS_00092'-'Vlan553']). -subnet(['IOS_00091'-'Vlan554', 'IOS_00092'-'Vlan554']). -subnet(['IOS_00091'-'Vlan556', 'IOS_00092'-'Vlan556']). -subnet(['IOS_00091'-'Vlan557', 'IOS_00092'-'Vlan557']). -subnet(['IOS_00091'-'Vlan558', 'IOS_00092'-'Vlan558']). -subnet(['IOS_00091'-'Vlan559', 'IOS_00092'-'Vlan559']). -subnet(['IOS_00091'-'Vlan560', 'IOS_00092'-'Vlan560']). -subnet(['IOS_00091'-'Vlan561', 'IOS_00092'-'Vlan561']). -subnet(['IOS_00091'-'Vlan562', 'IOS_00092'-'Vlan562']). -subnet(['IOS_00091'-'Vlan563', 'IOS_00092'-'Vlan563']). -subnet(['IOS_00091'-'Vlan564', 'IOS_00092'-'Vlan564']). -subnet(['IOS_00091'-'Vlan885', 'IOS_00092'-'Vlan885']). -subnet(['IOS_00091'-'Vlan544', 'IOS_00092'-'Vlan544']). -subnet(['IOS_00091'-'Vlan565', 'IOS_00092'-'Vlan565']). -subnet(['IOS_00091'-'Vlan566', 'IOS_00092'-'Vlan566']). -subnet(['IOS_00091'-'Vlan567', 'IOS_00092'-'Vlan567']). -subnet(['IOS_00091'-'Vlan568', 'IOS_00092'-'Vlan568']). -subnet(['IOS_00091'-'Vlan569', 'IOS_00092'-'Vlan569']). -subnet(['IOS_00091'-'Vlan570', 'IOS_00092'-'Vlan570']). -subnet(['IOS_00091'-'Vlan571', 'IOS_00092'-'Vlan571']). -subnet(['IOS_00091'-'Vlan572', 'IOS_00092'-'Vlan572']). -subnet(['IOS_00091'-'Vlan573', 'IOS_00092'-'Vlan573']). -subnet(['IOS_00091'-'Vlan574', 'IOS_00092'-'Vlan574']). -subnet(['IOS_00091'-'Vlan575', 'IOS_00092'-'Vlan575']). -subnet(['IOS_00091'-'Vlan576', 'IOS_00092'-'Vlan576']). -subnet(['IOS_00091'-'Vlan577', 'IOS_00092'-'Vlan577']). -subnet(['IOS_00091'-'Vlan580', 'IOS_00092'-'Vlan580']). -subnet(['IOS_00091'-'Vlan581', 'IOS_00092'-'Vlan581']). -subnet(['IOS_00091'-'Vlan582', 'IOS_00092'-'Vlan582']). -subnet(['IOS_00091'-'Vlan583', 'IOS_00092'-'Vlan583']). -subnet(['IOS_00091'-'Vlan584', 'IOS_00092'-'Vlan584']). -subnet(['IOS_00091'-'Vlan585', 'IOS_00092'-'Vlan585']). -subnet(['IOS_00091'-'Vlan586', 'IOS_00092'-'Vlan586']). -subnet(['IOS_00091'-'Vlan555', 'IOS_00092'-'Vlan555']). -subnet(['IOS_00091'-'Vlan800', 'IOS_00092'-'Vlan800']). -subnet(['IOS_00091'-'Loopback0']). diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195.class deleted file mode 100644 index 34146aee0..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195.java deleted file mode 100644 index 9c5a0ebe6..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Formula.and; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; - -/** - * A KK encoding of ALG195+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class ALG195 extends Quasigroups7 { - - /** - * Constructs a new instance of ALG195. - */ - public ALG195() {} - - /** - * Parametrization of axioms 12 and 13. - * - * @requires e's are unary, op is ternary - */ - @Override - Formula ax12and13(Relation[] e, Relation op) { - return Formula.TRUE; - } - - /** - * Parametrization of axioms 14 and 15. - * - * @requires e's are unary, op is ternary - */ - @Override - Formula ax14and15(Relation[] e, Relation op) { - final Expression expr0 = e[5].join(op); // op(e5,...) - final Expression expr1 = e[5].join(expr0); // op(e5,e5) - final Expression expr2 = expr1.join(expr0); // op(e5,op(e5,e5)) - final Expression expr3 = expr2.join(expr2.join(op)); // op(op(e5,op(e5,e5)),op(e5,op(e5,e5))) - final Expression expr3a = expr3.join(op); // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),...) - final Expression expr4 = e[5].join(expr3a); // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5) - // e0 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),op(e5,op(e5,e5))) - final Formula f0 = e[0].eq(expr2.join(expr3a)); - // e2 = op(op(e5,op(e5,e5)),op(e5,op(e5,e5))) - final Formula f2 = e[2].eq(expr3); - // e3 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5) - final Formula f3 = e[3].eq(expr4); - // e4 = op(e5,op(e5,e5)) - final Formula f4 = e[4].eq(expr2); - // e6 = - // op(op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5),op(e5,op(e5,e5))) - final Formula f6 = e[6].eq(expr2.join(expr4.join(op))); - return and(f0, f2, f3, f4, f6); - } - - /** - * Parametrization of axioms 16-22. - * - * @requires e is unary, h is binary - */ - @Override - Formula ax16_22(Relation e, Relation h) { - final Expression expr0 = e.join(op2); // op2(e,...) - final Expression expr1 = e.join(expr0); // op2(e,e) - final Expression expr2 = expr1.join(expr0); // op2(e,op2(e,e)) - final Expression expr3 = expr2.join(expr2.join(op2)); // op2(op2(e,op2(e,e)),op2(e,op2(e,e))) - final Expression expr3a = expr3.join(op2); // op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),...) - final Expression expr4 = e.join(expr3a); // op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),e) - // h(e10) = op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),op2(e,op2(e,e))) - final Formula f0 = e1[0].join(h).eq(expr2.join(expr3a)); - // h(e11) = op2(e,e) - final Formula f1 = e1[1].join(h).eq(expr1); - // h(e12) = op2(op2(e,op2(e,e)),op2(e,op2(e,e))) - final Formula f2 = e1[2].join(h).eq(expr3); - // h(e13) = op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),e) - final Formula f3 = e1[3].join(h).eq(expr4); - // h(e14) = op2(e,op2(e,e)) - final Formula f4 = e1[4].join(h).eq(expr2); - // h(e16) = - // op2(op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),e),op2(e,op2(e,e))) - final Formula f6 = e1[6].join(h).eq(expr2.join(expr4.join(op2))); - - return and(f0, f1, f2, f3, f4, f6); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !co1() - */ - public final Formula checkCO1() { - return axioms().and(co1().not()); - } - - /** - * Returns the bounds the problem (axioms 1, 4, 9-13, second formula of 14-15, - * and first formula of 16-22). - * - * @return the bounds for the problem - */ - @Override - public final Bounds bounds() { - final Bounds b = super.bounds(); - final TupleFactory f = b.universe().factory(); - - final TupleSet op1h = b.upperBound(op1).clone(); - final TupleSet op2h = b.upperBound(op2).clone(); - - for (int i = 0; i < 7; i++) { - op1h.remove(f.tuple("e1" + i, "e1" + i, "e1" + i)); // axiom 12 - op2h.remove(f.tuple("e2" + i, "e2" + i, "e2" + i)); // axiom 13 - } - - final TupleSet op1l = f.setOf(f.tuple("e15", "e15", "e11")); // axiom - // 14, - // line - // 2 - final TupleSet op2l = f.setOf(f.tuple("e25", "e25", "e21")); // axiom - // 15, - // line - // 2 - - op1h.removeAll(f.area(f.tuple("e15", "e15", "e10"), f.tuple("e15", "e15", "e16"))); - op1h.addAll(op1l); - - op2h.removeAll(f.area(f.tuple("e25", "e25", "e20"), f.tuple("e25", "e25", "e26"))); - op2h.addAll(op2l); - - b.bound(op1, op1l, op1h); - b.bound(op2, op2l, op2h); - - final TupleSet high = f.area(f.tuple("e10", "e20"), f.tuple("e14", "e26")); - high.addAll(f.area(f.tuple("e16", "e20"), f.tuple("e16", "e26"))); - - // first line of axioms 16-22 - for (int i = 0; i < 7; i++) { - Tuple t = f.tuple("e15", "e2" + i); - high.add(t); - b.bound(h[i], f.setOf(t), high); - high.remove(t); - } - - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.ALG195"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.ALG195 - */ - public static void main(String[] args) { - - try { - - final ALG195 model = new ALG195(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Formula f = model.checkCO1(); - final Bounds b = model.bounds(); - // System.out.println(model.decls()); - // System.out.println(model.ax2ax7()); - // System.out.println(b); - final Solution sol = solver.solve(f, b); - if (sol.instance() == null) { - System.out.println(sol); - } else { - System.out.println(sol.stats()); - model.display(sol.instance()); - } - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195_1.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195_1.class deleted file mode 100644 index 8021d13c1..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195_1.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195_1.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195_1.java deleted file mode 100644 index a4d6eb779..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG195_1.java +++ /dev/null @@ -1,414 +0,0 @@ -/** - * - */ -package examples.tptp; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * @author emina - */ -public final class ALG195_1 { - - final Relation[] e1, e2, h; - final Relation op1, op2, s1, s2; - - /** - * Constructs a new instance of Quasigroups7. - */ - ALG195_1() { - op1 = Relation.ternary("op1"); - op2 = Relation.ternary("op2"); - s1 = Relation.unary("s1"); - s2 = Relation.unary("s2"); - e1 = new Relation[7]; - e2 = new Relation[7]; - h = new Relation[7]; - for (int i = 0; i < 7; i++) { - e1[i] = Relation.unary("e1" + i); - e2[i] = Relation.unary("e2" + i); - h[i] = Relation.binary("h" + (i + 1)); - } - } - - private static Formula function(Relation s, Relation op) { - final Variable x = Variable.unary("x"), y = Variable.unary("y"); - return y.join(x.join(op)).one().forAll(x.oneOf(s).and(y.oneOf(s))); - } - - /** - * Returns the relation constraints. - * - * @returns the relation constraints. - */ - public final Formula decls() { - Formula f = function(s1, op1).and(function(s2, op2)); - for (Relation x : h) { - f = f.and(x.function(s1, s2)); - } - for (int i = 0; i < 7; i++) { - f = f.and(h[i].function(s1, s2)); - f = f.and(e1[i].one()).and(e2[i].one()); - } - return f; - } - - /** - * States that op is a latin square over s = e[0] +...+ e[6]. - * - * @requires e's are unary, s is unary, op is ternary - */ - private static Formula opCoversRange(Relation[] e, Relation s, Relation op) { - Formula f = Formula.TRUE; - for (Relation x : e) { - f = f.and(s.eq(s.join(x.join(op)))).and(s.eq(x.join(s.join(op)))); - } - return f; - } - - /** - * Returns axioms 2 and 7. - * - * @return ax2 and ax7 - */ - public final Formula ax2ax7() { - return opCoversRange(e1, s1, op1); - } - - /** - * Parametrization of axioms 3 and 6. - * - * @requires s is unary, op is ternary - */ - private static Formula ax3and6(Relation[] e, Relation op) { - Formula f = Formula.TRUE; - for (Relation x : e) { - for (Relation y : e) { - Expression expr0 = x.join(y.join(op)); // op(y,x) - Expression expr1 = y.join(expr0.join(op)); // op(op(y,x),y) - Expression expr2 = y.join(expr1.join(op)); // op(op(op(y,x),y),y) - f = f.and(expr2.eq(x)); - } - } - return f; - } - - /** - * Returns axiom 3. - * - * @return ax3 - */ - public final Formula ax3() { - return ax3and6(e1, op1); - } - - /** - * Returns axioms 5 and 8. - * - * @return ax5 and ax8 - */ - public final Formula ax5ax8() { - return opCoversRange(e2, s2, op2); - } - - /** - * Returns axiom 6. - * - * @return ax6 - */ - public final Formula ax6() { - return ax3and6(e2, op2); - } - - /** - * Parametrization of axioms 12 and 13. - * - * @requires e's are unary, op is ternary - */ - Formula ax12and13(Relation[] e, Relation op) { - Formula f = Formula.TRUE; - for (Relation r : e) { - f = f.and(r.join(r.join(op)).eq(r).not()); - } - return f; - } - - /** - * Returns axioms 9 and 10. - * - * @return axioms 9 and 10. - */ - // public final Formula ax9ax10() { - // Formula f = Formula.TRUE; - // for(int i = 0 ; i < 6; i++) { - // for(int j = i+1; j < 7; j++) { - // f = f.and(e1[i].eq(e1[j]).not()); - // f = f.and(e2[i].eq(e2[j]).not()); - // } - // } - // return f; - // } - - /** - * Returns axiom 12. - * - * @return ax12 - */ - public final Formula ax12() { - return ax12and13(e1, op1); - } - - /** - * Returns axiom 13. - * - * @return ax13 - */ - public final Formula ax13() { - return ax12and13(e2, op2); - } - - /** - * Parametrization of axioms 14 and 15. - * - * @requires e's are unary, op is ternary - */ - Formula ax14and15(Relation[] e, Relation op) { - final Expression expr0 = e[5].join(op); // op(e5,...) - final Expression expr1 = e[5].join(expr0); // op(e5,e5) - final Expression expr2 = expr1.join(expr0); // op(e5,op(e5,e5)) - final Expression expr3 = expr2.join(expr2.join(op)); // op(op(e5,op(e5,e5)),op(e5,op(e5,e5))) - final Expression expr3a = expr3.join(op); // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),...) - final Expression expr4 = e[5].join(expr3a); // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5) - // e0 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),op(e5,op(e5,e5))) - final Formula f0 = e[0].eq(expr2.join(expr3a)); - // e1 = op(e5,e5) - final Formula f1 = e[1].eq(expr1); - // e2 = op(op(e5,op(e5,e5)),op(e5,op(e5,e5))) - final Formula f2 = e[2].eq(expr3); - // e3 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5) - final Formula f3 = e[3].eq(expr4); - // e4 = op(e5,op(e5,e5)) - final Formula f4 = e[4].eq(expr2); - // e6 = - // op(op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5),op(e5,op(e5,e5))) - final Formula f6 = e[6].eq(expr2.join(expr4.join(op))); - return f0.and(f1).and(f2).and(f3).and(f4).and(f6); - } - - /** - * Returns lines 1 and 3-6 of axiom 14. - * - * @return ax14 - */ - public final Formula ax14() { - return ax14and15(e1, op1); - } - - /** - * Returns lines 1 and 3-6 of axiom 15. - * - * @return ax15 - */ - public final Formula ax15() { - return ax14and15(e2, op2); - } - - /** - * Parametrization of axioms 16-22. - * - * @requires e is unary, h is binary - */ - Formula ax16_22(Relation e, Relation h) { - final Expression expr0 = e.join(op2); // op2(e,...) - final Expression expr1 = e.join(expr0); // op2(e,e) - final Expression expr2 = expr1.join(expr0); // op2(e,op2(e,e)) - final Expression expr3 = expr2.join(expr2.join(op2)); // op2(op2(e,op2(e,e)),op2(e,op2(e,e))) - final Expression expr3a = expr3.join(op2); // op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),...) - final Expression expr4 = e.join(expr3a); // op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),e) - // h(e10) = op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),op2(e,op2(e,e))) - final Formula f0 = e1[0].join(h).eq(expr2.join(expr3a)); - // h(e11) = op2(e,e) - final Formula f1 = e1[1].join(h).eq(expr1); - // h(e12) = op2(op2(e,op2(e,e)),op2(e,op2(e,e))) - final Formula f2 = e1[2].join(h).eq(expr3); - // h(e13) = op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),e) - final Formula f3 = e1[3].join(h).eq(expr4); - // h(e14) = op2(e,op2(e,e)) - final Formula f4 = e1[4].join(h).eq(expr2); - // h1(e15) = e - final Formula f5 = e1[5].join(h).eq(e); - // h(e16) = - // op2(op2(op2(op2(e,op2(e,e)),op2(e,op2(e,e))),e),op2(e,op2(e,e))) - final Formula f6 = e1[6].join(h).eq(expr2.join(expr4.join(op2))); - - return f0.and(f1).and(f2).and(f3).and(f4).and(f5).and(f6); - } - - /** - * Returns axioms 16-22. - * - * @return axioms 16-22. - */ - public final Formula ax16_22() { - Formula f = Formula.TRUE; - for (int i = 0; i < 7; i++) { - f = f.and(ax16_22(e2[i], h[i])); - } - return f; - } - - /** - * Returns the conjunction of all axioms and implicit constraints (decls()). - * - * @return the conjunction of all axioms and implicit constraints - */ - public final Formula axioms() { - return decls().and(ax2ax7()).and(ax3()).and(ax5ax8()).and(ax6()).and(ax12()).and(ax13()).and(ax14()).and(ax15()).and(ax16_22()); - } - - /** - * Returns the part of the conjecture 1 that applies to the given h. - * - * @return the part of the conjecture 1 that applies to the given h. - */ - private final Formula co1h(Relation h) { - Formula f = Formula.TRUE; - for (Relation x : e1) { - for (Relation y : e1) { - Expression expr0 = (y.join(x.join(op1))).join(h); // h(op1(x,y)) - Expression expr1 = (y.join(h)).join((x.join(h)).join(op2)); // op2(h(x),h(y)) - f = f.and(expr0.eq(expr1)); - } - } - return f.and(s2.eq(s1.join(h))); - } - - /** - * Returns conjecture 1. - * - * @return co1 - */ - public final Formula co1() { - - Formula f = Formula.FALSE; - for (int i = 0; i < 7; i++) { - f = f.or(co1h(h[i])); - } - - return f; - } - - /** - * Returns the partial bounds the problem (axioms 1, 4, 9-11). - * - * @return the partial bounds for the problem - */ - public Bounds bounds() { - final List atoms = new ArrayList(14); - for (int i = 0; i < 7; i++) - atoms.add("e1" + i); - for (int i = 0; i < 7; i++) - atoms.add("e2" + i); - - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - - final TupleSet s1bound = f.range(f.tuple("e10"), f.tuple("e16")); - final TupleSet s2bound = f.range(f.tuple("e20"), f.tuple("e26")); - - b.boundExactly(s1, s1bound); - b.boundExactly(s2, s2bound); - - // axioms 9, 10, 11 - for (int i = 0; i < 7; i++) { - b.boundExactly(e1[i], f.setOf("e1" + i)); - b.boundExactly(e2[i], f.setOf("e2" + i)); - } - - // axom 1 - b.bound(op1, f.area(f.tuple("e10", "e10", "e10"), f.tuple("e16", "e16", "e16"))); - // axiom 4 - b.bound(op2, f.area(f.tuple("e20", "e20", "e20"), f.tuple("e26", "e26", "e26"))); - - final TupleSet hbound = s1bound.product(s2bound); - for (Relation r : h) { - b.bound(r, hbound); - } - - return b; - } - - private static void displayOp(Instance instance, Relation op) { - System.out.println("\n" + op + ":"); - final Iterator iter = instance.tuples(op).iterator(); - for (int i = 0; i < 7; i++) { - for (int j = 0; j < 7; j++) { - System.out.print(iter.next().atom(2)); - System.out.print("\t"); - } - System.out.println(); - } - } - - /** - * Prints the values of the op1, op2, and h1-h7 relations to standard out. - */ - void display(Instance instance) { - displayOp(instance, op1); - displayOp(instance, op2); - for (int i = 0; i < 7; i++) { - System.out.println("\n" + h[i] + ":"); - System.out.println(instance.tuples(h[i])); - } - } - - private static void usage() { - System.out.println("java examples.tptp.ALG195_1"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.ALG195_1 - */ - public static void main(String[] args) { - - try { - - final ALG195_1 model = new ALG195_1(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Formula f = model.axioms().and(model.co1().not()); - final Bounds b = model.bounds(); - // System.out.println(model.decls()); - // System.out.println(model.ax2ax7()); - // System.out.println(b); - final Solution sol = solver.solve(f, b); - if (sol.instance() == null) { - System.out.println(sol); - } else { - System.out.println(sol.stats()); - model.display(sol.instance()); - } - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG197.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG197.class deleted file mode 100644 index 793699449..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG197.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG197.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG197.java deleted file mode 100644 index b84ea3073..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG197.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * - */ -package examples.tptp; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; - -/** - * A KK encoding of ALG197+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class ALG197 extends Quasigroups7 { - - /** - * Constructs a new instance of ALG197. - */ - public ALG197() {} - - /** - * Parametrization of axioms 12 and 13. - * - * @requires e's are unary, op is ternary - */ - @Override - Formula ax12and13(Relation[] e, Relation op) { - final List f0 = new ArrayList(); - final List f1 = new ArrayList(); - for (int i = 0; i < 7; i++) { - Formula f = e[i].join(e[i].join(op)).eq(e[i]); - f0.add(f); - f1.add(f.not()); - } - return Formula.or(f0).and(Formula.or(f1)); - } - - /** - * Parametrization of axioms 14 and 15. - * - * @requires e's are unary, op is ternary - */ - @Override - Formula ax14and15(Relation[] e, Relation op) { - final Expression expr0 = e[6].join(op); // op(e6,...) - final Expression expr1 = e[6].join(expr0); // op(e6,e6) - final Expression expr2 = expr1.join(expr1.join(op)); // op(op(e6,e6),op(e6,e6)) - final Expression expr3 = expr2.join(expr0); // op(e6,op(op(e6,e6),op(e6,e6))) - // e0 = op(e6,op(e6,e6)) - final Formula f0 = e[0].eq(expr1.join(expr0)); - // e1 = op(op(e6,e6),op(e6,e6)) - final Formula f1 = e[1].eq(expr2); - // e2 = op(op(op(e6,e6),op(e6,e6)),op(e6,e6)) - final Formula f2 = e[2].eq(expr1.join(expr2.join(op))); - // e3 = op(e6,op(op(e6,e6),op(e6,e6))) - final Formula f3 = e[3].eq(expr3); - // e4 = op(e6,op(e6,op(op(e6,e6),op(e6,e6)))) - final Formula f4 = e[4].eq(expr3.join(expr0)); - return Formula.and(f0, f1, f2, f3, f4); - } - - /** - * Parametrization of axioms 16-22. - * - * @requires e is unary, h is binary - */ - @Override - Formula ax16_22(Relation e, Relation h) { - final Expression expr0 = e.join(op2); // op2(e,...) - final Expression expr1 = e.join(expr0); // op2(e,e) - final Expression expr2 = expr1.join(expr1.join(op2)); // op2(op2(e,e),op2(e,e)) - final Expression expr3 = expr2.join(expr0); // op2(e,op2(op2(e,e),op2(e,e))) - // h(e10) = op2(e,op2(e,e)) - final Formula f0 = e1[0].join(h).eq(expr1.join(expr0)); - // h(e11) = op2(op2(e,e),op2(e,e)) - final Formula f1 = e1[1].join(h).eq(expr2); - // h(e12) = op2(op2(op2(e,e),op2(e,e)),op2(e,e)) - final Formula f2 = e1[2].join(h).eq(expr1.join(expr2.join(op2))); - // h(e13) = op2(e,op2(op2(e,e),op2(e,e))) - final Formula f3 = e1[3].join(h).eq(expr3); - // h(e14) = op2(e,op2(e,op2(op2(e,e),op2(e,e)))) - final Formula f4 = e1[4].join(h).eq(expr3.join(expr0)); - // h(e15) = op2(e,e) - final Formula f5 = e1[5].join(h).eq(expr1); - return Formula.and(f0, f1, f2, f3, f4, f5); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !co1() - */ - public final Formula checkCO1() { - return axioms().and(co1().not()); - } - - /** - * Returns the bounds the problem (axioms 1, 4, 9-11, last formula of 14-15, and - * first formula of 16-22). - * - * @return the bounds for the problem - */ - @Override - public final Bounds bounds() { - final Bounds b = super.bounds(); - final TupleFactory f = b.universe().factory(); - - final TupleSet op1h = b.upperBound(op1).clone(); - final TupleSet op2h = b.upperBound(op2).clone(); - - final TupleSet op1l = f.setOf(f.tuple("e16", "e16", "e15")); // axiom - // 14, - // line - // 6 - final TupleSet op2l = f.setOf(f.tuple("e26", "e26", "e25")); // axiom - // 15, - // line - // 6 - - op1h.removeAll(f.area(f.tuple("e16", "e16", "e10"), f.tuple("e16", "e16", "e16"))); - op1h.addAll(op1l); - - op2h.removeAll(f.area(f.tuple("e26", "e26", "e20"), f.tuple("e26", "e26", "e26"))); - op2h.addAll(op2l); - - b.bound(op1, op1l, op1h); - b.bound(op2, op2l, op2h); - - final TupleSet high = f.area(f.tuple("e10", "e20"), f.tuple("e15", "e26")); - - // first line of axioms 16-22 - for (int i = 0; i < 7; i++) { - Tuple t = f.tuple("e16", "e2" + i); - high.add(t); - b.bound(h[i], f.setOf(t), high); - high.remove(t); - } - - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.ALG197"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.ALG197 - */ - public static void main(String[] args) { - - try { - - final ALG197 model = new ALG197(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Formula f = model.checkCO1(); - final Bounds b = model.bounds(); - final Solution sol = solver.solve(f, b); - if (sol.instance() == null) { - System.out.println(sol); - } else { - System.out.println(sol.stats()); - model.display(sol.instance()); - } - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG212.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG212.class deleted file mode 100644 index a4b60a43b..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG212.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG212.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG212.java deleted file mode 100644 index e14e4856b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/ALG212.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Universe; - -/** - * A KK encoding of ALG212+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class ALG212 { - - private final Relation f; - - /** - * Constucts a new instance of ALG212. - */ - public ALG212() { - f = Relation.nary("f", 4); - } - - /** - * Returns the declarations. - * - * @return declarations. - */ - public final Formula decls() { - // all x,y,z: univ | one f[x][y][z] - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Variable z = Variable.unary("z"); - final Formula f0 = z.join(y.join(x.join(f))).one(); - return f0.forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the majority axiom. - * - * @return majority - */ - public final Formula majority() { - // all x, y: A | f[x][x][y] = x - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - return y.join(x.join(x.join(f))).eq(x).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV))); - } - - /** - * Returns the permute1 axiom. - * - * @return permute1 - */ - public final Formula permute1() { - // all x, y, z: A | f[x][y][z] = f[z][x][y] - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Variable z = Variable.unary("z"); - final Formula f0 = z.join(y.join(x.join(f))).eq(y.join(x.join(z.join(f)))); - return f0.forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the permute2 axiom. - * - * @return permute2 - */ - public final Formula permute2() { - // all x, y, z: A | f[x][y][z] = f[x][z][y] - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Variable z = Variable.unary("z"); - final Formula f0 = z.join(y.join(x.join(f))).eq(y.join(z.join(x.join(f)))); - return f0.forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the associativity axiom. - * - * @return associativity - */ - public final Formula associativity() { - // all w, x, y, z: A | f[f[x][w][y]][w][z] = f[x][w][f[y][w][z]] - final Variable w = Variable.unary("w"); - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Variable z = Variable.unary("z"); - final Expression e0 = y.join(w.join(x.join(f))); - final Expression e1 = z.join(w.join(e0.join(f))); - final Expression e2 = z.join(w.join(y.join(f))); - final Expression e3 = e2.join(w.join(x.join(f))); - return e1.eq(e3).forAll(w.oneOf(UNIV).and(x.oneOf(UNIV)).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the conjuction of all axioms. - * - * @return axioms - */ - public final Formula axioms() { - return decls().and(majority()).and(permute1()).and(permute2()).and(associativity()); - } - - /** - * Returns the dist_long conjecture. - * - * @return dist_long - */ - public final Formula distLong() { - // all u, w, x, y, z: A | f[f[x][y][z]][u][w] = - // f[f[x][u][w]][f[y][u][w]][f[z][u][w]] - final Variable u = Variable.unary("u"); - final Variable w = Variable.unary("w"); - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Variable z = Variable.unary("z"); - final Expression e0 = z.join(y.join(x.join(f))); - final Expression e1 = w.join(u.join(e0.join(f))); - final Expression e2 = w.join(u.join(x.join(f))); - final Expression e3 = w.join(u.join(y.join(f))); - final Expression e4 = w.join(u.join(z.join(f))); - final Expression e5 = e4.join(e3.join(e2.join(f))); - return e1.eq(e5).forAll(u.oneOf(UNIV).and(w.oneOf(UNIV)).and(x.oneOf(UNIV)).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !distLong() - */ - public final Formula checkDistLong() { - return axioms().and(distLong().not()); - } - - /** - * Returns the bounds for the given scope. - * - * @return bounds for the given scope - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - b.bound(f, u.factory().allOf(4)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.ALG212 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.ALG212 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final ALG212 model = new ALG212(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(n*n); - // solver.options().setFlatten(false); - final Formula f = model.checkDistLong(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/COM008.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/COM008.class deleted file mode 100644 index a0807c085..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/COM008.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/COM008.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/COM008.java deleted file mode 100644 index b4d8d62ca..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/COM008.java +++ /dev/null @@ -1,249 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.IDEN; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KK encoding of COM008+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class COM008 { - - private final Relation equalish, rewrite, trr; - private final Relation a, b, c, goal; - private final Relation Atom; - - /** - * Constructs a new instance of COM008. - */ - public COM008() { - equalish = Relation.binary("equalish"); - rewrite = Relation.binary("rewrite"); - trr = Relation.binary("trr"); - a = Relation.unary("a"); - b = Relation.unary("b"); - c = Relation.unary("c"); - goal = Relation.unary("goal"); - Atom = Relation.unary("Atom"); - } - - /** - * Returns the declarations. - * - * @return one a && one b && one c - */ - public final Formula decls() { - return a.one().and(b.one()).and(c.one()); - } - - /** - * Returns the found axiom. - * - * @return the found axiom. - */ - public final Formula found() { - final Variable A = Variable.unary("A"); - return b.product(A).union(c.product(A)).in(trr).implies(goal.some()).forAll(A.oneOf(Atom)); - } - - /** - * Returns the assumption axiom. - * - * @return the assumption axiom. - */ - public final Formula assumption() { - return a.product(b).union(a.product(c)).in(trr); - } - - /** - * Returns the reflexivity axiom. - * - * @return the reflexivity axiom. - */ - public final Formula reflexivity() { - final Expression eqdom = equalish.join(Atom); - return eqdom.product(eqdom).intersection(IDEN).in(equalish); - } - - /** - * Returns the symmetry axiom. - * - * @return the symmetry axiom. - */ - public final Formula symmetry() { - return equalish.eq(equalish.transpose()); - } - - /** - * Returns the equalish_in_transitive_reflexive_rewrite axiom. - * - * @return the equalish_in_transitive_reflexive_rewrite axiom. - */ - public final Formula equalishInTrr() { - return equalish.in(trr); - } - - /** - * Returns the rewrite_in_transitive_reflexive_rewrite axiom. - * - * @return the rewrite_in_transitive_reflexive_rewrite axiom. - */ - public final Formula rewriteInTrr() { - return rewrite.in(trr); - } - - /** - * Returns the transitivity_of_transitive_reflexive_rewrite axiom. - * - * @return the transitivity_of_transitive_reflexive_rewrite axiom. - */ - public final Formula transitivityOfTrr() { - return trr.join(trr).in(trr); - } - - /** - * Returns the lo_cfl axiom. - * - * @return the lo_cfl axiom. - */ - public final Formula loCfl() { - final Variable A = Variable.unary("A"); - final Variable B = Variable.unary("B"); - final Variable C = Variable.unary("C"); - final Formula f0 = A.product(B).union(A.product(C)).in(rewrite); - final Formula f1 = B.join(trr).intersection(C.join(trr)).some(); - return f0.implies(f1).forAll(A.oneOf(Atom).and(B.oneOf(Atom)).and(C.oneOf(Atom))); - } - - /** - * Returns the ih_cfl axiom. - * - * @return the ih_cfl axiom. - */ - public final Formula ihCfl() { - final Variable A = Variable.unary("A"); - final Variable B = Variable.unary("B"); - final Variable C = Variable.unary("C"); - final Formula f0 = a.product(A).in(rewrite).and(A.product(B).union(A.product(C)).in(trr)); - final Formula f1 = B.join(trr).intersection(C.join(trr)).some(); - return f0.implies(f1).forAll(A.oneOf(Atom).and(B.oneOf(Atom)).and(C.oneOf(Atom))); - } - - /** - * Returns the equalish_or_rewrite axiom. - * - * @return the equalish_or_rewrite axiom. - */ - public final Formula equalishOrRewrite() { - final Variable A = Variable.unary("A"); - final Variable B = Variable.unary("B"); - final Formula f0 = A.product(B).in(trr); - final Formula f1 = A.product(B).in(equalish); - final Formula f2 = A.join(rewrite).intersection(trr.join(B)).some(); - return f0.implies(f1.or(f2)).forAll(A.oneOf(Atom).and(B.oneOf(Atom))); - } - - public final Formula axioms() { - return decls().and(equalishInTrr()).and(rewriteInTrr()).and(found()).and(assumption()).and(reflexivity()).and(symmetry()).and(transitivityOfTrr()).and(loCfl()).and(ihCfl()).and(equalishOrRewrite()); - } - - /** - * Returns the conjecture. - * - * @return some goal - */ - public final Formula goalToBeProved() { - return goal.some(); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !goalToBeProved() - */ - public final Formula checkGoalToBeProved() { - return axioms().and(goalToBeProved().not()); - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - atoms.add("goal"); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds bound = new Bounds(u); - final TupleFactory f = u.factory(); - final TupleSet d1 = f.range(f.tuple("a0"), f.tuple("a" + (n - 1))); - final TupleSet d2 = d1.product(d1); - - bound.bound(rewrite, d2); - bound.bound(equalish, d2); - - bound.bound(a, d1); - bound.bound(b, d1); - bound.bound(c, d1); - bound.boundExactly(Atom, d1); - - bound.bound(trr, d2); - - bound.bound(goal, f.setOf("goal")); - return bound; - } - - private static void usage() { - System.out.println("java examples.tptp.COM008 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.COM008 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final COM008 model = new COM008(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(22); - // solver.options().setFlatten(false); - final Formula f = model.checkGoalToBeProved(); - final Bounds b = model.bounds(n); - // System.out.println(f); - - final Solution sol = solver.solve(f, b); - System.out.println(sol); - - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO091.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO091.class deleted file mode 100644 index 59145d399..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO091.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO091.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO091.java deleted file mode 100644 index 5855b9551..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO091.java +++ /dev/null @@ -1,83 +0,0 @@ -package examples.tptp; - -import kodkod.ast.Formula; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; - -/** - * The GEO091+1 problem from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public class GEO091 extends GEO158 { - - /** - * Constructs a new instance of GEO091. - */ - public GEO091() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * Returns the conjecture theorem_2_13. - * - * @return theorem_2_13 - */ - public final Formula theorem_2_13() { - // all C, C1, C2: Curve | - // ((C1 + C2)->C in partOf && C in Open && - // !(lone endPoint.C1 & endPoint.C2)) => C1 = C2 - final Variable c = Variable.unary("C"); - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Formula f0 = c1.union(c2).product(c).in(partOf).and(c.in(open)); - final Formula f1 = endPoint.join(c1).intersection(endPoint.join(c2)).lone().not(); - return f0.and(f1).implies(c1.eq(c2)).forAll(c.oneOf(curve).and(c1.oneOf(curve)).and(c2.oneOf(curve))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !theorem_2_13() - */ - public final Formula checkTheorem_2_13() { - return axioms().and(theorem_2_13().not()); - } - - private static void usage() { - System.out.println("java examples.tptp.GEO191 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.GEO191 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final GEO091 model = new GEO091(); - final Formula f = model.checkTheorem_2_13(); - - System.out.println(model.theorem_2_13()); - - final Bounds b = model.bounds(n); - final Solution sol = solver.solve(f, b); - - System.out.println(sol); - // System.out.println((new - // Evaluator(sol.instance())).evaluate(model.axioms().and(model.theorem213().not()))); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO092.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO092.class deleted file mode 100644 index 9d39ba882..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO092.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO092.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO092.java deleted file mode 100644 index 0e32fef79..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO092.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * - */ -package examples.tptp; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; - -/** - * The GEO092+1 problem from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public class GEO092 extends GEO158 { - - /** - * Constructs a new instance of GEO091. - */ - public GEO092() { - super(); - // TODO Auto-generated constructor stub - } - - /* - * fof(proposition_2_14_1,conjecture, ( ! [C1,C2,P] : ( ( meet(P,C1,C2) & - * open(sum(C1,C2)) ) => ! [Q] : ( Q != P => ~ ( incident_c(Q,C1) & - * incident_c(Q,C2) ) ) ) )). - */ - /** - * Returns the conjecture proposition_2_14_1. - * - * @return proposition_2_14_1 - */ - public final Formula proposition2141() { - // all c1, c2: curve, p: point | - // p->c1->c2 in meet && c1->c2 in sum.open => - // all q: point - p | c1 + c2 !in q.incident - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Variable p = Variable.unary("P"); - final Variable q = Variable.unary("Q"); - final Expression e0 = c1.product(c2); - final Formula f0 = p.product(e0).in(meet).and(e0.in(sum.join(open))); - final Formula f1 = c1.union(c2).in(q.join(incident)).not().forAll(q.oneOf(point.difference(p))); - return f0.implies(f1).forAll(c1.oneOf(curve).and(c2.oneOf(curve)).and(p.oneOf(point))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !proposition2141() - */ - public final Formula checkProposition2141() { - return axioms().and(proposition2141().not()); - } - - private static void usage() { - System.out.println("java examples.tptp.GEO192 [scope]"); - System.exit(1); - } - - /** - * Usage: ava examples.tptp.GEO192 [# curves] [# points] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final GEO092 model = new GEO092(); - final Formula f = model.checkProposition2141(); - - System.out.println(model.proposition2141()); - - final Bounds b = model.bounds(n); - final Solution sol = solver.solve(f, b); - - System.out.println(sol); - // System.out.println((new - // Evaluator(sol.instance())).evaluate(model.axioms().and(model.theorem213().not()))); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO115.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO115.class deleted file mode 100644 index 5988c3fe6..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO115.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO115.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO115.java deleted file mode 100644 index 7c325449b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO115.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * - */ -package examples.tptp; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; - -/** - * KK encoding of GEO115+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class GEO115 extends GEO159 { - - /** - * Constructs a new instance of GEO115. - */ - public GEO115() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * Returns the conjecture theorem_3_8_5. - * - * @return theorem_3_8_5 - */ - public final Formula theorem385() { - // all c: curve, p, q, r: point | - // c->p->q->r in between => - // incident.c - q in q.(p.(c.between)) + ((c.between).r).q - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Variable q = Variable.unary("Q"); - final Variable r = Variable.unary("R"); - final Formula f0 = c.product(p).product(q).product(r).in(between); - final Expression e0 = q.join(p.join(c.join(between))); - final Expression e1 = c.join(between).join(r).join(q); - final Formula f1 = incident.join(c).difference(q).in(e0.union(e1)); - return f0.implies(f1).forAll(p.oneOf(point).and(q.oneOf(point)).and(r.oneOf(point)).and(c.oneOf(curve))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !theorem385() - */ - public final Formula checkTheorem385() { - return axioms().and(theorem385().not()); - } - - private static void usage() { - System.out.println("java examples.tptp.GEO115 [# curves] [# points]"); - System.exit(1); - } - - /** - * Usage: ava examples.tptp.GEO115 [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final GEO115 model = new GEO115(); - final Formula f = model.theorem385(); - - final Bounds b = model.bounds(n); - final Solution sol = solver.solve(f, b); - - System.out.println(sol); - - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO158.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO158.class deleted file mode 100644 index b8b6663d6..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO158.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO158.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO158.java deleted file mode 100644 index c76d2793f..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO158.java +++ /dev/null @@ -1,431 +0,0 @@ -package examples.tptp; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * The GEO158+1 problem from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public class GEO158 { - - final Relation partOf, incident, sum, endPoint, innerPoint, meet, closed, open; - final Relation curve, point; - /* - * part_of : C -> C incident_c : P -> C sum : C -> C -> one C end_point : P -> C - * inner_point : P -> C meet : P -> C -> C closed : C open : C - */ - - /** - * Constructs a new instance of GEO0040. - */ - public GEO158() { - super(); - partOf = Relation.binary("partOf"); - incident = Relation.binary("incident"); - sum = Relation.ternary("sum"); - endPoint = Relation.binary("endPoint"); - closed = Relation.unary("Closed"); - open = Relation.unary("Open"); - curve = Relation.unary("Curve"); - point = Relation.unary("Point"); - meet = Relation.ternary("meet"); - innerPoint = Relation.binary("innerPoint"); - } - - /** - * Returns all the 'type' declarations. - * - * @return the type declarations - */ - public Formula decls() { - final Expression cc = curve.product(curve); - final Expression pc = point.product(curve); - final Formula f0 = partOf.in(cc); - final Formula f1 = closed.in(curve).and(open.in(curve)); - final Formula f2 = meet.in(point.product(cc)).and(sum.in(curve.product(cc))); - final Formula f3 = incident.in(pc).and(endPoint.in(pc)).and(innerPoint.in(pc)); - // all C1, C2: Curve | one C2.(C1.sum) - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Formula f4 = c2.join(c1.join(sum)).one().forAll(c1.oneOf(curve).and(c2.oneOf(curve))); - return f0.and(f1).and(f2).and(f3).and(f4); - } - - /** - * Returns the part_of_defn axiom. - * - * @return part_of_defn - */ - public final Formula partOfDefn() { - // all C, C1: Curve | C1->C in partOf iff incident.C1 in incident.C - final Variable c = Variable.unary("C"), c1 = Variable.unary("C1"); - final Formula f = c1.product(c).in(partOf).iff(incident.join(c1).in(incident.join(c))); - return f.forAll(c.oneOf(curve).and(c1.oneOf(curve))); - } - - /** - * Returns the sum_defn axiom. - * - * @return sum_defn - */ - public final Formula sumDefn() { - // all C, C1, C2: Curve | C1->C2->C in sum iff - // incident.C = incident.C1 + incident.C2 - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Variable c = Variable.unary("C"); - final Formula f0 = c1.product(c2).product(c).in(sum); - final Formula f1 = incident.join(c).eq(incident.join(c1).union(incident.join(c2))); - return f0.iff(f1).forAll(c.oneOf(curve).and(c1.oneOf(curve)).and(c2.oneOf(curve))); - } - - /** - * Returns the end_point_defn axiom. - * - * @return end_point_defn - */ - public final Formula endPointDefn() { - /* - * all P: Point, C: Curve | P->C in endPoint iff (P->C in incident && all C1, - * C2: partOf.C & P.incident | C1->C2 in partOf || C2->C1 in partOf) - */ - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - - final Expression e0 = p.product(c); - final Formula f0 = e0.in(endPoint); - final Formula f1 = e0.in(incident); - - final Variable c1 = Variable.unary("C1"), c2 = Variable.unary("C2"); - final Formula f2 = c1.product(c2).in(partOf).or(c2.product(c1).in(partOf)); - final Expression e1 = partOf.join(c).intersection(p.join(incident)); - final Formula f3 = f2.forAll(c1.oneOf(e1).and(c2.oneOf(e1))); - - return f0.iff(f1.and(f3)).forAll(p.oneOf(point).and(c.oneOf(curve))); - } - - /** - * Returns the inner_point_defn axiom. - * - * @return inner_point_defn - */ - public final Formula innerPointDefn() { - // all P: Point, C: Curve | P->C in innerPoint iff - // (P->C in incident && no P->C & endPoint) - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Expression e0 = p.product(c); - final Formula f0 = e0.in(innerPoint); - final Formula f1 = e0.in(incident).and(e0.intersection(endPoint).no()); - return f0.iff(f1).forAll(p.oneOf(point).and(c.oneOf(curve))); - } - - /** - * Returns the meet_defn axiom. - * - * @return meet_defn - */ - public final Formula meetDefn() { - // all P: Point, C, C1: Curve | P->C->C1 in meet iff - // (P->C in incident && P->C1 in incident && - // incident.C & incident.C1 in endPoint.C & endPoint.C1) - final Variable c = Variable.unary("C"); - final Variable c1 = Variable.unary("C1"); - final Variable p = Variable.unary("P"); - - final Formula f0 = p.product(c).product(c1).in(meet); - final Formula f1 = p.product(c).in(incident).and(p.product(c1).in(incident)); - final Expression e0 = incident.join(c).intersection(incident.join(c1)); - final Expression e1 = endPoint.join(c).intersection(endPoint.join(c1)); - final Formula f2 = e0.in(e1); - - final Formula f3 = f0.iff(f1.and(f2)); - - return f3.forAll(p.oneOf(point).and(c.oneOf(curve)).and(c1.oneOf(curve))); - } - - /** - * Returns the closed_defn axiom. - * - * @return closed_defn - */ - public final Formula closedDefn() { - // all C: Curve | C in Closed iff no endPoint.C - final Variable c = Variable.unary("C"); - return c.in(closed).iff(endPoint.join(c).no()).forAll(c.oneOf(curve)); - } - - /** - * Returns the open_defn axiom. - * - * @return open_defn - */ - public final Formula openDefn() { - // all C: Curve | C in Open iff some endPoint.C - final Variable c = Variable.unary("C"); - return c.in(open).iff(endPoint.join(c).some()).forAll(c.oneOf(curve)); - } - - /** - * Returns the c1 axiom. - * - * @return c1 - */ - public final Formula c1() { - // all C, C1: Curve | (C1->C in partOf && C1 != C) => C1 in Open - final Variable c = Variable.unary("C"); - final Variable c1 = Variable.unary("C1"); - final Formula f0 = c1.product(c).in(partOf).and(c1.eq(c).not()); - final Formula f1 = c1.in(open); - return f0.implies(f1).forAll(c.oneOf(curve).and(c1.oneOf(curve))); - } - - /** - * Returns the c2 axiom. - * - * @return c2 - */ - public final Formula c2() { - // all C, C1, C2, C3: Curve | ((C1 + C2 + C3)->C in partOf && - // some endPoint.C1 & endPoint.C2 & endPoint.C3) => - // (C2->C3 in partOf || C3->C2 in partOf || C1->C2 in partOf || - // C2->C1 in partOf || C1->C3 in partOf || C3->C1 in partOf) - final Variable c = Variable.unary("C"); - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Variable c3 = Variable.unary("C3"); - - final Formula f0 = c1.union(c2).union(c3).product(c).in(partOf); - final Formula f1 = endPoint.join(c1).intersection(endPoint.join(c2)).intersection(endPoint.join(c3)).some(); - final Formula f2 = c2.product(c3).in(partOf).or(c3.product(c2).in(partOf)); - final Formula f3 = c1.product(c2).in(partOf).or(c2.product(c1).in(partOf)); - final Formula f4 = c1.product(c3).in(partOf).or(c3.product(c1).in(partOf)); - - return f0.and(f1).implies(f2.or(f3).or(f4)).forAll(c.oneOf(curve).and(c1.oneOf(curve)).and(c2.oneOf(curve)).and(c3.oneOf(curve))); - } - - /** - * Returns the c3 axiom. - * - * @return c3 - */ - public final Formula c3() { - // all C: Curve | some innerPoint.C - final Variable c = Variable.unary("C"); - return innerPoint.join(c).some().forAll(c.oneOf(curve)); - } - - /** - * Returns the c4 axiom. - * - * @return c4 - */ - public final Formula c4() { - // all C: Curve, P: Point | P->C in innerPoint => some P.meet & sum.C - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Formula f0 = p.product(c).in(innerPoint); - final Formula f1 = p.join(meet).intersection(sum.join(c)).some(); - return f0.implies(f1).forAll(c.oneOf(curve).and(p.oneOf(point))); - } - - /** - * Returns the c5 axiom. - * - * @return c5 - */ - public final Formula c5() { - // all C: Curve, P, Q, R: endPoint.C | - // P = Q || P = R || Q = R - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Variable q = Variable.unary("Q"); - final Variable r = Variable.unary("R"); - final Expression e0 = endPoint.join(c); - final Formula f0 = p.eq(q).or(p.eq(r)).or(q.eq(r)); - return f0.forAll(c.oneOf(curve).and(p.oneOf(e0)).and(q.oneOf(e0)).and(r.oneOf(e0))); - } - - /** - * Returns the c6 axiom. - * - * @return c6 - */ - public final Formula c6() { - // all C: Curve, P: endPoint.C | some endPoint.C - P - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Expression e0 = endPoint.join(c); - return e0.difference(p).some().forAll(c.oneOf(curve).and(p.oneOf(e0))); - } - - /** - * Returns the c7 axiom. - * - * @return c7 - */ - public final Formula c7() { - // all C, C1, C2: Curve, P: Point | (C in Closed && - // P->C1->C2 in meet && sum[C1][C2] = C) => - // ((endPoint.C1)->C1->C2 in meet) - final Variable c = Variable.unary("C"); - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Variable p = Variable.unary("P"); - - final Formula f0 = c.in(closed).and(p.product(c1).product(c2).in(meet)); - final Formula f1 = c2.join(c1.join(sum)).eq(c); - final Formula f2 = endPoint.join(c1).product(c1).product(c2).in(meet); - return f0.and(f1).implies(f2).forAll(c.oneOf(curve).and(c1.oneOf(curve)).and(c2.oneOf(curve)).and(p.oneOf(point))); - } - - /** - * Returns the c8 axiom. - * - * @return c8 - */ - public final Formula c8() { - // all C1, C2: Curve | some meet.C2.C1 => some sum[C1][C2] - final Variable c1 = Variable.unary("C1"); - final Variable c2 = Variable.unary("C2"); - final Formula f0 = meet.join(c2).join(c1).some(); - final Formula f1 = c2.join(c1.join(sum)).some(); - return f0.implies(f1).forAll(c1.oneOf(curve).and(c2.oneOf(curve))); - } - - /** - * Returns the c9 axiom. - * - * @return c9 - */ - public final Formula c9() { - // all C, C1: Curve | incident.C = incident.C1 => C = C1 - final Variable c = Variable.unary("C"); - final Variable c1 = Variable.unary("C1"); - return incident.join(c).eq(incident.join(c1)).implies(c.eq(c1)).forAll(c.oneOf(curve).and(c1.oneOf(curve))); - } - - /** - * Returns the conjunction of all axioms and decls - * - * @returns the conjunction of all axioms and decls - */ - public Formula axioms() { - return decls().and(partOfDefn()).and(sumDefn()).and(endPointDefn()).and(innerPointDefn()).and(meetDefn()).and(openDefn()).and(closedDefn()).and(c1()).and(c2()).and(c3()).and(c4()).and(c5()).and(c6()).and(c7()).and(c8()).and(c9()); - } - - /** - * Returns the formula "some Curve" - * - * @return some Curve - */ - public Formula someCurve() { - return curve.some(); - } - - /** - * Returns a bounds with the given number of maximum curves and points - * - * @return a bounds with the given number of maximum curves and points - */ - public Bounds bounds(int scope) { - assert scope > 0; - List atoms = new ArrayList(scope); - for (int i = 0; i < scope; i++) - atoms.add("c" + i); - for (int i = 0; i < scope; i++) - atoms.add("p" + i); - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - final TupleSet c = f.range(f.tuple("c0"), f.tuple("c" + (scope - 1))); - final TupleSet p = f.range(f.tuple("p0"), f.tuple("p" + (scope - 1))); - final TupleSet cc = c.product(c), pc = p.product(c); - b.bound(curve, c); - b.bound(point, p); - b.bound(partOf, cc); - b.bound(incident, pc); - b.bound(sum, c.product(cc)); - b.bound(endPoint, pc); - b.bound(innerPoint, pc); - b.bound(meet, pc.product(c)); - b.bound(closed, c); - b.bound(open, c); - return b; - } - - /** - * Returns the conjunction of the axioms and the hypothesis. - * - * @return axioms() && someCurve() - */ - public final Formula checkConsistent() { - return axioms().and(someCurve()); - } - - private static void usage() { - System.out.println("java examples.tptp.GEO158 [ univ size ]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.GEO158 [# univ size ] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final GEO158 model = new GEO158(); - final Formula f = model.checkConsistent(); - - // System.out.println(model.decls()); - // System.out.println(model.partOfDefn()); - // System.out.println(model.sumDefn()); - // - // System.out.println(model.endPointDefn()); - // System.out.println(model.innerPointDefn()); - // System.out.println(model.meetDefn()); - // - // System.out.println(model.openDefn()); - // System.out.println(model.closedDefn()); - // System.out.println(model.c1()); - // - // System.out.println(model.c2()); - // System.out.println(model.c3()); - // System.out.println(model.c4()); - // - // System.out.println(model.c6()); - // System.out.println(model.c7()); - // System.out.println(model.c8()); - // - // System.out.println(model.c9()); - - final Bounds b = model.bounds(n); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO159.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO159.class deleted file mode 100644 index a2972d086..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO159.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO159.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO159.java deleted file mode 100644 index f3b8b313b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GEO159.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * - */ -package examples.tptp; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleSet; - -/** - * The GEO159+1 problem from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public class GEO159 extends GEO158 { - - final Relation between; - - /* - * beteween : C -> P -> P -> P - */ - /** - * Constructs a new instance of GEO159. - */ - public GEO159() { - between = Relation.nary("between_c", 4); - } - - /** - * Returns the between_c_defn axiom. - * - * @return between_c_defn - */ - public final Formula betweenDefn() { - // all c, p, q, r: point | - // c->p->q->r in between <=> p != r && some p.endPoint & r.endPoint & - // q.innerPoint & partOf.c - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Variable q = Variable.unary("Q"); - final Variable r = Variable.unary("R"); - final Expression e = p.join(endPoint).intersection(r.join(endPoint)).intersection(q.join(innerPoint)).intersection(partOf.join(c)); - final Formula f0 = c.product(p).product(q).product(r).in(between); - final Formula f1 = p.eq(q).not().and(e.some()); - return f0.iff(f1).forAll(p.oneOf(point).and(q.oneOf(point)).and(r.oneOf(point)).and(c.oneOf(curve))); - } - - /** - * Returns all the 'type' declarations. - * - * @return the type declarations - */ - @Override - public Formula decls() { - return super.decls().and(between.in(curve.product(point).product(point).product(point))); - } - - /** - * Returns the conjunction of all axioms and decls - * - * @returns the conjunction of all axioms and decls - */ - public Formula checkDefs() { - return super.axioms().and(betweenDefn()).and(someCurve()); - } - - /** - * Returns a bounds with the given number of maximum curves and points - * - * @return a bounds with the given number of maximum curves and points - */ - @Override - public Bounds bounds(int scope) { - final Bounds b = super.bounds(scope); - final TupleSet c = b.upperBound(curve); - final TupleSet p = b.upperBound(point); - b.bound(between, c.product(p).product(p).product(p)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.GEO159 [scope]"); - System.exit(1); - } - - /** - * Usage: ava examples.tptp.GEO159 [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final GEO159 model = new GEO159(); - final Formula f = model.checkDefs(); - - final Bounds b = model.bounds(n); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GRA013_026.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GRA013_026.class deleted file mode 100644 index da4e976ab..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GRA013_026.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GRA013_026.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/GRA013_026.java deleted file mode 100644 index 5f6d2439b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/GRA013_026.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * - */ -package examples.tptp; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.ConsoleReporter; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; -import kodkod.util.nodes.PrettyPrinter; - -/** - * A KK encoding of GRA019+1.p through GRA026+1.p from - * http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class GRA013_026 { - - private final Relation red, green, lessThan, goal, node; - private final int graphSize, cliqueSize; - - /** - * Constructs a new instance of GRA013_026 with the given graph and clique size. - * - * @requires 0 < cliqueSize <= graphSize - */ - public GRA013_026(int graphSize, int cliqueSize) { - if (cliqueSize <= 0) - throw new IllegalArgumentException("cliqueSize must be positive: " + cliqueSize); - if (cliqueSize > graphSize) - throw new IllegalArgumentException("cliqueSize must be less than or equal to graph size: " + cliqueSize + ">" + graphSize); - node = Relation.unary("N"); - red = Relation.binary("red"); - green = Relation.binary("green"); - lessThan = Relation.binary("lessThan"); - goal = Relation.unary("goal"); - this.graphSize = graphSize; - this.cliqueSize = cliqueSize; - } - - private final Formula cliqueAxiom(Expression color) { - final Variable[] vars = new Variable[cliqueSize]; - for (int i = 0; i < cliqueSize; i++) { - vars[i] = Variable.unary("V" + i); - } - final List members = new ArrayList(cliqueSize); - for (int i = 0, max = cliqueSize - 1; i < max; i++) { - final List tmp = new ArrayList(); - for (int j = i + 1; j < cliqueSize; j++) { - tmp.add(vars[j]); - } - members.add(vars[i].product(Expression.union(tmp))); - } - Decls d = vars[0].oneOf(node); - for (int i = 1; i < cliqueSize; i++) { - d = d.and(vars[i].oneOf(vars[i - 1].join(lessThan))); - } - return Expression.union(members).in(color).implies(goalToBeProved()).forAll(d); - } - - /** - * Returns the red clique axiom. - * - * @return red clique axiom. - */ - public final Formula redCliqueAxiom() { - return cliqueAxiom(red); - } - - /** - * Returns the green clique axiom. - * - * @return green clique axiom. - */ - public final Formula greenCliqueAxiom() { - return cliqueAxiom(green); - } - - /** - * Returns the partition axiom. - * - * @return partition axiom - */ - public final Formula partition() { - return lessThan.in(red.union(green)); - } - - /** - * Returns the transitivity axiom. - * - * @return transitivity axiom - */ - public final Formula lessThanTransitive() { - return lessThan.join(lessThan).in(lessThan); - } - - /** - * Returns the no overlap axiom. - * - * @return no overlap axiom. - */ - public final Formula noOverlap() { - return red.intersection(green).no(); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms - */ - public final Formula axioms() { - return Formula.and(redCliqueAxiom(), greenCliqueAxiom(), partition(), lessThanTransitive(), noOverlap()); - } - - /** - * Returns the goal_to_be_proved conjecture. - * - * @return goal_to_be_proved conjecture. - */ - public final Formula goalToBeProved() { - return goal.some(); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !goalToBeProved() - */ - public final Formula checkGoalToBeProved() { - return axioms().and(goalToBeProved().not()); - } - - /** - * Returns the bounds. - * - * @return the bounds - */ - public final Bounds bounds() { - final List atoms = new ArrayList(graphSize); - for (int i = 1; i <= graphSize; i++) - atoms.add("n" + i); - atoms.add("goal"); - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - b.bound(goal, f.setOf("goal")); - final TupleSet ns = f.range(f.tuple("n1"), f.tuple("n" + graphSize)); - b.boundExactly(node, ns); - - final TupleSet s = f.noneOf(2); - for (int i = 1; i < graphSize; i++) { - for (int j = i + 1; j < graphSize; j++) - s.add(f.tuple("n" + i, "n" + j)); - } - b.boundExactly(lessThan, s); - b.bound(red, s); - b.bound(green, s); - return b; - } - - private static void usage() { - System.out.println("Usage: java examples.tptp.GRA013_026 "); - System.exit(1); - } - - /** - * Usage: java examples.tptp.GRA013_026 - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - try { - - final GRA013_026 model = new GRA013_026(Integer.parseInt(args[0]), Integer.parseInt(args[1])); - - final Bounds b = model.bounds(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setReporter(new ConsoleReporter()); - - final Formula f = model.checkGoalToBeProved(); - System.out.println(PrettyPrinter.print(f, 2)); - // System.out.println(b); - final Solution s = solver.solve(f, b); - System.out.println(s); - // System.out.println((new Evaluator(s.instance())).evaluate(f)); - - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/LAT258.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/LAT258.class deleted file mode 100644 index 675cdcde8..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/LAT258.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/LAT258.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/LAT258.java deleted file mode 100644 index 0b7a46a74..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/LAT258.java +++ /dev/null @@ -1,376 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KK encoding of LAT258+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class LAT258 { - - private final Relation goal, p, t, u, v, w, x, y, z; - private final Relation lessThan, meet, join; - - /** - * Constructs a new instance of LAT258. - */ - public LAT258() { - goal = Relation.unary("goal"); - p = Relation.unary("p"); - t = Relation.unary("t"); - u = Relation.unary("u"); - v = Relation.unary("v"); - w = Relation.unary("w"); - x = Relation.unary("x"); - y = Relation.unary("y"); - z = Relation.unary("z"); - lessThan = Relation.binary("lessThan"); - meet = Relation.ternary("meet"); - join = Relation.ternary("join"); - } - - /** - * Returns function declarations. - * - * @return function declarations - */ - public final Formula decls() { - return p.one().and(t.one()).and(v.one()).and(w.one()).and(u.one()).and(x.one()).and(y.one()).and(z.one()); - } - - /** - * Returns the join_assumption axiom. - * - * @return join_assumption axiom. - */ - public final Formula joinAssumption() { - // x->y->t + x->z->u in join - return x.product(y).product(t).union(x.product(z).product(u)).in(join); - } - - /** - * Returns the meet_assumption axiom. - * - * @return the meet_assumption axiom. - */ - public final Formula meetAssumption() { - // t->u->v in meet - return t.product(u).product(v).in(meet); - } - - /** - * Returns the meet_join_assumption axiom. - * - * @return the meet_join_assumption axiom. - */ - public final Formula meetJoinAssumption() { - // y->z->w in meet && x->w->p in join - return y.product(z).product(w).in(meet).and(x.product(w).product(p).in(join)); - } - - /** - * Returns the goal_ax axiom. - * - * @return the goal_ax axiom. - */ - public final Formula goalAx() { - // v->p in lessThan => some goal - return v.product(p).in(lessThan).implies(goal.some()); - } - - /** - * Returns the less_than_reflexive axiom. - * - * @return the less_than_reflexive axiom. - */ - public final Formula lessThanReflexive() { - // iden in lessThan - return Expression.IDEN.in(lessThan); - } - - /** - * Returns the less_than_transitive axiom. - * - * @return the less_than_transitive axiom. - */ - public final Formula lessThanTransitive() { - // lessThan.lessThan in lessThan - return lessThan.join(lessThan).in(lessThan); - } - - /** - * Returns the lower_bound_meet axiom. - * - * @return the lower_bound_meet axiom. - */ - public final Formula lowerBoundMeet() { - final Variable c = Variable.unary("C"); - final Expression e0 = c.join(lessThan); - final Formula f0 = meet.join(c).in(e0.product(e0)); - // all c: univ | meet.c in c.lessThan->c.lessThan - return f0.forAll(c.oneOf(UNIV)); - } - - /* - * fof(greatest_lower_bound_meet,axiom,( ! [A,B,C,D] : ( ( meet(A,B,C) & - * less_than(D,A) & less_than(D,B) ) => less_than(D,C) ) )). - */ - /** - * Returns the greatest_lower_bound_meet axiom. - * - * @return the greatest_lower_bound_meet axiom. - */ - public final Formula greatestLowerBoundMeet() { - final Variable a = Variable.unary("A"), b = Variable.unary("B"); - final Expression e0 = b.join(a.join(meet)); - final Formula f0 = e0.some().implies(lessThan.join(a).intersection(lessThan.join(b)).in(lessThan.join(e0))); - return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the upper_bound_join axiom. - * - * @return the upper_bound_join axiom. - */ - public final Formula upperBoundJoin() { - final Variable c = Variable.unary("C"); - final Expression e0 = lessThan.join(c); - final Formula f0 = join.join(c).in(e0.product(e0)); - // all c: univ | join.c in lessThan.c->lessThan.c - return f0.forAll(c.oneOf(UNIV)); - } - - /** - * Returns the least_upper_bound_join axiom. - * - * @return the least_upper_bound_join axiom. - */ - public final Formula leastUpperBoundJoin() { - final Variable a = Variable.unary("A"), b = Variable.unary("B"); - final Expression e0 = b.join(a.join(meet)); - final Formula f0 = e0.some().implies(a.join(lessThan).intersection(b.join(lessThan)).in(e0.join(lessThan))); - return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the less_than_meet_join axiom. - * - * @return the less_than_meet_join axiom. - */ - public final Formula lessThanMeetJoin() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Expression e0 = a.product(b); - final Formula f0 = e0.product(a).in(meet); - final Formula f1 = e0.product(b).in(join); - // all a: univ, b: a.lessThan | a->b->a in meet && a->b->b in join - return f0.and(f1).forAll(b.oneOf(a.join(lessThan))).forAll(a.oneOf(UNIV)); - } - - /** - * Assumes that e is a ternary relation. - * - * @return e.univ~ in e.univ - */ - private final Formula commutative(Expression e) { - final Expression first2 = e.join(UNIV); - return first2.transpose().in(first2); - } - - /** - * Returns the commutitivity_meet axiom. - * - * @return the commutitivity_meet axiom. - */ - public final Formula commutativityMeet() { - return commutative(meet); - } - - /** - * Returns the commutitivity_join axiom. - * - * @return the commutitivity_join axiom. - */ - public final Formula commutativityJoin() { - return commutative(join); - } - - /* - * fof(associativity_meet,axiom,( ! [A,B,C,D,E,F] : ( ( meet(A,B,D) & - * meet(D,C,E) & meet(B,C,F) ) => meet(A,F,E) ) )). - */ - /** - * Assumes that r is a ternary relation. - * - * @return all a, b, c: univ | a->(c.(b.r))->(c.(d.r)) in r - */ - private final Formula associative(Expression r) { - final Variable a = Variable.unary("A"), b = Variable.unary("B"), c = Variable.unary("C"); - final Expression d = b.join(a.join(r)); - final Expression e = c.join(d.join(r)); - final Expression f = c.join(b.join(r)); - final Formula f0 = a.product(f).product(e).in(r); - // all a, b, c: univ | a->(c.(b.r))->(c.((b.(a.r)).r)) in r - return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns the associativity_meet axiom. - * - * @return the associativity_meet axiom. - */ - public final Formula associativityMeet() { - return associative(meet); - } - - /** - * Returns the associativity_join axiom. - * - * @return the associativity_ axiom. - */ - public final Formula associativityJoin() { - return associative(join); - } - - /** - * Returns the lo_le_distr axiom. - * - * @return the lo_le_distr axiom. - */ - public final Formula loLeDistr() { - final Variable a = Variable.unary("A"), b = Variable.unary("B"), c = Variable.unary("C"); - final Expression h = c.join(b.join(join)); - final Expression d = h.join(a.join(meet)); - final Expression e = b.join(a.join(meet)); - final Expression f = c.join(a.join(meet)); - final Expression g = f.join(e.join(join)); - final Formula f0 = d.product(g).in(lessThan); - // all a, b, c: univ | (c.(b.(meet))).(a.meet) -> - // (c.(a.meet)).((b.(a.meet)).join) in lessThan - return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns the do_lattice axiom. - * - * @return the do_lattice axiom. - */ - public final Formula doLattice() { - return UNIV.product(UNIV).in(meet.join(UNIV)); - } - - /** - * Returns the goal_to_be_proved conjecture. - * - * @return goal_to_be_proved conjecture. - */ - public final Formula goalToBeProved() { - return goal.some(); - } - - /** - * Returns the conjunction of all decls and axioms. - * - * @return the conjunction of all decls and axioms. - */ - public final Formula axioms() { - return decls().and(joinAssumption()).and(meetAssumption()).and(meetJoinAssumption()).and(goalAx()).and(lessThanReflexive()).and(lessThanTransitive()).and(lowerBoundMeet()).and(greatestLowerBoundMeet()).and(upperBoundJoin()).and(leastUpperBoundJoin()).and(lessThanMeetJoin()).and(commutativityMeet()).and(commutativityJoin()).and(associativityMeet()).and(associativityJoin()).and(loLeDistr()).and(doLattice()); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !goalToBeProved() - */ - public final Formula checkGoalToBeProved() { - return axioms().and(goalToBeProved().not()); - } - - /** - * Returns the bounds for the given scope. - * - * @return the bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("n" + i); - final Universe univ = new Universe(atoms); - final TupleFactory f = univ.factory(); - final Bounds b = new Bounds(univ); - b.bound(goal, f.setOf("n0")); - final TupleSet all1 = f.allOf(1); - b.bound(p, all1); - b.bound(t, all1); - b.bound(v, all1); - b.bound(w, all1); - b.bound(u, all1); - b.bound(x, all1); - b.bound(y, all1); - b.bound(z, all1); - b.bound(lessThan, f.allOf(2)); - final TupleSet all3 = f.allOf(3); - b.bound(join, all3); - b.bound(meet, all3); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.LAT258 [scope]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.LAT258 [scope] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - try { - - final int n = Integer.parseInt(args[0]); - final LAT258 model = new LAT258(); - - final Bounds b = model.bounds(n); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - final Formula f = model.checkGoalToBeProved(); - System.out.println(f); - // System.out.println(b); - final Solution s = solver.solve(f, b); - System.out.println(s); - - } catch (NumberFormatException nfe) { - usage(); - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED001.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED001.class deleted file mode 100644 index 2e466081f..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED001.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED001.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED001.java deleted file mode 100644 index d6b959ea3..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED001.java +++ /dev/null @@ -1,367 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.IDEN; -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KK encoding of axioms MED001+0.ax and MED001+1.ax from - * http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public abstract class MED001 { - - protected final Relation bcapacityne, bcapacityex, bcapacitysn, conditionhyper, conditionhypo, conditionnormo, - drugi, uptakelg, uptakepg, releaselg, bsecretioni, drugbg, qilt27, s0, s1, s2, s3, drugsu, n0; - protected final Relation gt; - - protected MED001() { - bcapacityne = Relation.unary("bcapacityne"); - bcapacityex = Relation.unary("bcapacityex"); - bcapacitysn = Relation.unary("bcapacitysn"); - conditionhyper = Relation.unary("conditionhyper"); - conditionhypo = Relation.unary("conditionhypo"); - conditionnormo = Relation.unary("conditionnormo"); - drugi = Relation.unary("drugi"); - uptakelg = Relation.unary("uptakelg"); - uptakepg = Relation.unary("uptakepg"); - releaselg = Relation.unary("releaselg"); - bsecretioni = Relation.unary("bsecretioni"); - drugbg = Relation.unary("drugbg"); - qilt27 = Relation.unary("qilt27"); - s0 = Relation.unary("s0"); - s1 = Relation.unary("s1"); - s2 = Relation.unary("s2"); - s3 = Relation.unary("s3"); - drugsu = Relation.unary("drugsu"); - n0 = Relation.unary("n0"); - gt = Relation.binary("gt"); - } - - /** - * Returns the declarations. - * - * @return declarations - */ - public final Formula decls() { - return n0.one(); - } - - /** - * Returns the irreflexivity_gt axiom. - * - * @return irreflexivity_gt - */ - public final Formula irreflexivity_gt() { - return gt.intersection(IDEN).no(); - } - - /** - * Returns the transitivity_gt axiom. - * - * @return transitivity_gt - */ - public final Formula transitivity_gt() { - return gt.join(gt).in(gt); - } - - /** - * Returns the axioms xorcapacity1 through xorcapacity1_4. - * - * @return xorcapacity1_4 - */ - public final Formula xorcapacity1_4() { - return UNIV.in(bcapacityne.union(bcapacityex).union(bcapacitysn)).and(bcapacityne.intersection(bcapacityex).no()).and(bcapacityne.intersection(bcapacitysn).no()).and(bcapacityex.intersection(bcapacitysn).no()); - } - - /** - * Returns the axioms xorcondition1 through xorcondition1. - * - * @return xorcondition1_4 - */ - public final Formula xorcondition1_4() { - return UNIV.in(conditionhyper.union(conditionhypo).union(conditionnormo)).and(conditionhyper.intersection(conditionhypo).no()).and(conditionhyper.intersection(conditionnormo).no()).and(conditionnormo.intersection(conditionhypo).no()); - } - - /** - * Returns the insulin_effect axiom. - * - * @return insulin_effect - */ - public final Formula insulin_effect() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - return x1.in(drugi).implies(x1.in(uptakelg.intersection(uptakepg))).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the liver_glucose axiom. - * - * @return liver_glucose - */ - public final Formula liver_glucose() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - return x1.in(uptakelg).implies(x1.in(releaselg).not()).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the sulfonylurea_effect axiom. - * - * @return sulfonylurea_effect - */ - public final Formula sulfonylurea_effect() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - return x1.in(drugi).and(x0.in(bcapacityex).not()).implies(x1.in(bsecretioni)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the biguanide_effect axiom. - * - * @return biguanide_effect - */ - public final Formula biguanide_effect() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - return x1.in(drugbg).implies(x1.in(releaselg).not()).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the sn_cure_1 axiom. - * - * @return sn_cure_1 - */ - public final Formula sn_cure_1() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(bsecretioni).and(x0.in(bcapacitysn)).and(x0.in(qilt27)).and(x0.join(gt).in(conditionhyper)); - return f0.implies(x1.in(conditionnormo)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the sn_cure_2 axiom. - * - * @return sn_cure_2 - */ - public final Formula sn_cure_2() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(releaselg).not().and(x0.in(bcapacitysn)).and(x0.in(qilt27).not()).and(x0.join(gt).in(conditionhyper)); - return f0.implies(x1.in(conditionnormo)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the ne_cure axiom. - * - * @return ne_cure - */ - public final Formula ne_cure() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(releaselg).not().or(x1.in(uptakepg)).and(x0.in(bcapacityne)).and(x1.in(bsecretioni)).and(x0.join(gt).in(conditionhyper)); - return f0.implies(x1.in(conditionnormo)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the ex_cure axiom. - * - * @return ex_cure - */ - public final Formula ex_cure() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(uptakelg).and(x1.in(uptakepg)).and(x0.in(bcapacityex).not()).and(x0.join(gt).in(conditionhyper)); - return f0.implies(x1.in(conditionnormo.union(conditionhypo))).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the axioms xorstep1 through xorstep7. - * - * @return xorstep1_7 - */ - public final Formula xorstep1_7() { - return UNIV.in(s0.union(s1).union(s2).union(s3)).and(s0.intersection(s1).no()).and(s0.intersection(s2).no()).and(s0.intersection(s3).no()).and(s1.intersection(s2).no()).and(s1.intersection(s3).no()).and(s2.intersection(s3).no()); - } - - /** - * Returns the normo axiom. - * - * @return normo - */ - public final Formula normo() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(bsecretioni).and(x0.in(bcapacitysn)).and(x0.in(qilt27)).and(x0.join(gt).in(conditionhyper)); - final Formula f1 = x1.in(releaselg).not().and(x0.in(bcapacitysn)).and(x0.in(qilt27).not()).and(x0.join(gt).in(conditionhyper)); - final Formula f2 = x1.in(releaselg).not().or(x1.in(uptakelg)).and(x0.in(bcapacitysn)).and(x1.in(bsecretioni)).and(x0.join(gt).in(conditionhyper)); - final Formula f3 = x1.in(uptakelg).and(x1.in(uptakepg)).and(x0.in(bcapacityex)).and(x0.join(gt).in(conditionhyper)); - return x1.in(conditionnormo).implies(f0.or(f1).or(f2).or(f3)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the axioms step1 through step4. - * - * @return step1_4 - */ - public final Formula step1_4() { - return s1.intersection(qilt27).in(drugsu).and(s1.intersection(UNIV.difference(qilt27)).in(drugbg)).and(s2.in(drugbg.intersection(drugsu))).and(s3.in(drugi.intersection(drugsu.union(drugbg)).union(drugi))); - } - - /** - * Returns the axioms sucomp and insulincomp. - * - * @return *comp - */ - public final Formula comp() { - return drugsu.in(s1.intersection(qilt27).union(s2).union(s3)).and(drugi.in(s3)); - } - - /** - * Returns the insulin_completion axiom. - * - * @return insulin_completion - */ - public final Formula insulin_completion() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(uptakelg.union(uptakepg)); - return f0.implies(x1.in(drugi)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the uptake_completion axiom. - * - * @return uptake_completion - */ - public final Formula uptake_completion() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(releaselg).not(); - return f0.implies(x1.in(uptakelg)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the su_completion axiom. - * - * @return su_completion - */ - public final Formula su_completion() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(bsecretioni); - return f0.implies(x1.in(drugsu).and(x0.in(bcapacityex).not())).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the bg_completion axiom. - * - * @return bg_completion - */ - public final Formula bg_completion() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x1.in(releaselg).not(); - return f0.implies(x1.in(drugbg)).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the trans_ax1 axiom. - * - * @return trans_ax1 - */ - public final Formula trans_ax1() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x0.in(s0).and(x1.in(conditionnormo).not()); - final Formula f1 = x1.intersection(s1).some().and(x1.join(gt).in(conditionhyper)); - return f0.implies(f1).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the trans_ax2 axiom. - * - * @return trans_ax2 - */ - public final Formula trans_ax2() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x0.in(s1).and(x1.in(conditionnormo).not()); - final Formula f1 = x1.intersection(s2).intersection(bcapacityne.union(bcapacityex)).some().and(x1.join(gt).in(conditionhyper)); - return f0.implies(f1).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the trans_ax3 axiom. - * - * @return trans_ax3 - */ - public final Formula trans_ax3() { - final Variable x0 = Variable.unary("X0"); - final Expression x1 = UNIV.difference(x0.join(gt)); - final Formula f0 = x0.in(s2).and(x1.in(conditionnormo).not()); - final Formula f1 = x1.intersection(s3).intersection(bcapacityex).some().and(x1.join(gt).in(conditionhyper)); - return f0.implies(f1).forAll(x0.oneOf(UNIV)); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms. - */ - public final Formula axioms() { - return Formula.and(trans_ax2(), trans_ax3(), transitivity_gt(), decls(), irreflexivity_gt(), normo(), xorcapacity1_4(), xorcondition1_4(), insulin_effect(), liver_glucose(), sulfonylurea_effect(), biguanide_effect(), bg_completion(), sn_cure_1(), sn_cure_2(), ne_cure(), ex_cure(), su_completion(), xorstep1_7(), step1_4(), comp(), insulin_completion(), uptake_completion(), trans_ax1()); - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - final TupleSet s = f.allOf(1); - b.bound(bcapacityne, s); - b.bound(bcapacityex, s); - b.bound(bcapacitysn, s); - b.bound(conditionhyper, s); - b.bound(conditionhypo, s); - b.bound(conditionnormo, s); - b.bound(drugi, s); - b.bound(uptakelg, s); - b.bound(uptakepg, s); - b.bound(releaselg, s); - b.bound(bsecretioni, s); - b.bound(drugbg, s); - b.bound(qilt27, s); - b.bound(s0, s); - b.bound(s1, s); - b.bound(s2, s); - b.bound(s3, s); - b.bound(drugsu, s); - b.bound(n0, s); - b.bound(gt, f.allOf(2)); - return b; - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED007.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED007.class deleted file mode 100644 index eaedd0178..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED007.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED007.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED007.java deleted file mode 100644 index afcbcfa6e..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED007.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import kodkod.ast.Formula; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; - -/** - * A KK encoding of MED007+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class MED007 extends MED001 { - - /** - * Constructs a new instance of MED007. - */ - public MED007() {} - - /** - * Returns transsls2_qilt27 conjecture. - * - * @return transsls2_qilt27 - */ - public final Formula transsls2_qilt27() { - final Variable x0 = Variable.unary("X0"); - final Formula f0 = n0.in(s1).and(n0.join(gt).in(conditionhyper)).and(n0.in(bcapacitysn).not()).and(n0.in(qilt27)); - final Formula f1 = n0.product(x0).in(gt).not().and(x0.in(s2)).and(x0.join(gt).in(conditionhyper)).and(x0.in(bcapacityne.union(bcapacityex))).forSome(x0.oneOf(UNIV)); - return f0.implies(f1); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !transsls2_qilt27() - */ - public final Formula checkTranssls2_qilt27() { - return axioms().and(transsls2_qilt27().not()); - } - - private static void usage() { - System.out.println("java examples.tptp.MED007 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.MED007 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final MED007 model = new MED007(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(1000); - // solver.options().setFlatten(false); - final Formula f = model.checkTranssls2_qilt27(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED009.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED009.class deleted file mode 100644 index e15ea98c7..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED009.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED009.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED009.java deleted file mode 100644 index 7e070f741..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MED009.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import kodkod.ast.Formula; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; - -/** - * A KK encoding of MED009+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class MED009 extends MED001 { - - /** - * Constructs a new instance of MED007. - */ - public MED009() {} - - /** - * Returns transsls2_qige27 conjecture. - * - * @return transsls2_qige27 - */ - public final Formula transsls2_qige27() { - final Variable x0 = Variable.unary("X0"); - final Formula f0 = n0.in(s1).and(n0.join(gt).in(conditionhyper)).and(n0.in(bcapacitysn).not()).and(n0.in(qilt27).not()); - final Formula f1 = n0.product(x0).in(gt).not().and(x0.in(s2)).and(x0.join(gt).in(conditionhyper)).and(x0.in(bcapacityne.union(bcapacityex))).forSome(x0.oneOf(UNIV)); - return f0.implies(f1); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !transsls2_qige27() - */ - public final Formula checkTranssls2_qige27() { - return axioms().and(transsls2_qige27().not()); - } - - private static void usage() { - System.out.println("java examples.tptp.MED009 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.MED009 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final MED009 model = new MED009(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(1000); - // solver.options().setFlatten(false); - final Formula f = model.checkTranssls2_qige27(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MGT066.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MGT066.class deleted file mode 100644 index 3c98cc340..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MGT066.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MGT066.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/MGT066.java deleted file mode 100644 index 0683e0a10..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/MGT066.java +++ /dev/null @@ -1,152 +0,0 @@ -package examples.tptp; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of MGT066+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class MGT066 { - - private Relation lt, leq, gt, geq; - - /** - * Constructs a new instance of MGT066. - */ - public MGT066() { - super(); - lt = Relation.binary("smaller"); - leq = Relation.binary("smaller_or_equal"); - gt = Relation.binary("greater"); - geq = Relation.binary("greater_or_equal"); - } - - /** - * Returns the definition_smaller_or_equal axiom. - * - * @return definition_smaller_or_equal - */ - public final Formula definitionSmallerOrEqual() { - return leq.eq(lt.union(Expression.IDEN)); - } - - /** - * Returns the definition_greater_or_equal axiom. - * - * @return definition_greater_or_equal - */ - public final Formula definitionGreaterOrEqual() { - return geq.eq(gt.union(Expression.IDEN)); - } - - /** - * Returns definition_smaller axiom. - * - * @return definition_smaller - */ - public final Formula definitionSmaller() { - return lt.eq(gt.transpose()); - } - - /** - * Returns meaning_postulate_greater_strict axiom. - * - * @return meaning_postulate_greater_strict - */ - public final Formula meaningPostulateGreaterStrict() { - return gt.intersection(gt.transpose()).no(); - } - - /** - * Returns meaning_postulate_greater_transitive - * - * @return meaning_postulate_greater_transitive - */ - public final Formula meaningPostulateGreaterTransitive() { - return (gt.join(gt)).in(gt); - } - - /** - * Returns meaning_postulate_greater_comparable - * - * @return meaning_postulate_greater_comparable - */ - public final Formula meaningPostulateGreaterComparable() { - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - return x.eq(y).or(y.in(x.join(lt))).or(x.in(y.join(lt))).forAll(x.oneOf(Expression.UNIV).and(y.oneOf(Expression.UNIV))); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms - */ - public final Formula axioms() { - return definitionSmaller().and(definitionSmallerOrEqual()).and(definitionGreaterOrEqual()).and(meaningPostulateGreaterComparable()).and(meaningPostulateGreaterStrict()).and(meaningPostulateGreaterTransitive()); - } - - /** - * Returns a bounds for a universe of the given size. - * - * @return bounds for a universe of the given size. - */ - public final Bounds bounds(int size) { - assert size > 0; - final List atoms = new ArrayList(size); - for (int i = 0; i < size; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - b.bound(lt, f.allOf(2)); - b.bound(leq, f.allOf(2)); - b.bound(gt, f.allOf(2)); - b.bound(geq, f.allOf(2)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.MGT066 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.MGT066 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final MGT066 model = new MGT066(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setSymmetryBreaking(n * n); - final Formula f = model.axioms(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM374.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM374.class deleted file mode 100644 index 5b25b0ae8..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM374.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM374.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM374.java deleted file mode 100644 index aa2ca7ec5..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM374.java +++ /dev/null @@ -1,342 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KK encoding of NUM374+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class NUM374 { - - private final Relation sum, product, exponent, n1; - - /** - * Constructs a new instance of NUM374. - */ - public NUM374() { - n1 = Relation.unary("n1"); - sum = Relation.ternary("sum"); - product = Relation.ternary("product"); - exponent = Relation.ternary("exponent"); - } - - /** - * Returns op[X][Y]. - * - * @return op[X][Y] - */ - final Expression apply(Relation op, Expression X, Expression Y) { - return Y.join(X.join(op)); - } - - /** - * Returns sum[X][Y]. - * - * @return sum[X][Y] - */ - final Expression sum(Expression X, Expression Y) { - return Y.join(X.join(sum)); - } - - /** - * Returns product[X][Y]. - * - * @return product[X][Y] - */ - final Expression product(Expression X, Expression Y) { - return Y.join(X.join(product)); - } - - /** - * Returns exponent[X][Y]. - * - * @return exponent[X][Y] - */ - final Expression exponent(Expression X, Expression Y) { - return Y.join(X.join(exponent)); - } - - /** - * Returns the declarations. - * - * @return declarations. - */ - public final Formula decls() { - final Formula f0 = n1.one(); - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - final Formula f1 = sum(x, y).one().and(product(x, y).one()).and(exponent(x, y).one()); - return f0.and(f1.forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)))); - } - - /** - * Returns all X, Y: Num | op[X][Y] = op[Y][X] - * - * @return all X, Y: Num | op[X][Y] = op[Y][X] - */ - final Formula symmetric(Relation op) { - // all X, Y: Num | op[X][Y] = op[Y][X] - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - return apply(op, x, y).eq(apply(op, y, x)).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV))); - } - - /** - * Returns all X, Y, Z: Num | op[X][op[Y][Z]] = op[op[X][Y]][Z] - * - * @return all X, Y, Z: Num | op[X][op[Y][Z]] = op[op[X][Y]][Z] - */ - final Formula associative(Relation op) { - // all X, Y, Z: Num | op[X][op[Y][Z]] = op[op[X][Y]][Z] - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - final Variable z = Variable.unary("Z"); - return apply(op, x, apply(op, y, z)).eq(apply(op, apply(op, x, y), z)).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the sum_symmetry axiom. - * - * @return sum_symmetry - */ - public final Formula sumSymmetry() { - return symmetric(sum); - } - - /** - * Returns the sum_associativity axiom. - * - * @return sum_associativity - */ - public final Formula sumAssociativity() { - return associative(sum); - } - - /** - * Returns the product_identity axiom. - * - * @return product_identity - */ - public final Formula productIdentity() { - // ! [X] : product(X,n1) = X - final Variable x = Variable.unary("X"); - return product(x, n1).eq(x).forAll(x.oneOf(UNIV)); - } - - /** - * Returns the product_symmetry axiom. - * - * @return product_symmetry - */ - public final Formula productSymmetry() { - return symmetric(product); - } - - /** - * Returns the product_associativity axiom. - * - * @return product_associativity - */ - public final Formula productAssociativity() { - return associative(product); - } - - /** - * Returns the sum_product_distribution axiom. - * - * @return sum_product_distribution - */ - public final Formula sumProductDistribution() { - // ! [X,Y,Z] : product(X,sum(Y,Z)) = sum(product(X,Y),product(X,Z)) )). - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - final Variable z = Variable.unary("Z"); - return product(x, sum(y, z)).eq(sum(product(x, y), product(x, z))).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the exponent_n1 axiom. - * - * @return exponent_n1 - */ - public final Formula exponentN1() { - // ! [X] : exponent(n1,X) = n1 - final Variable x = Variable.unary("X"); - return exponent(n1, x).eq(n1).forAll(x.oneOf(UNIV)); - } - - /** - * Returns the exponent_identity axiom. - * - * @return exponent_identity - */ - public final Formula exponentIdentity() { - // ! [X] : exponent(X,n1) = X - final Variable x = Variable.unary("X"); - return exponent(x, n1).eq(x).forAll(x.oneOf(UNIV)); - } - - /** - * Returns the exponent_sum_product axiom. - * - * @return exponent_sum_product - */ - public final Formula exponentSumProduct() { - // ! [X,Y,Z] : exponent(X,sum(Y,Z)) = - // product(exponent(X,Y),exponent(X,Z)) - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - final Variable z = Variable.unary("Z"); - return exponent(x, sum(y, z)).eq(product(exponent(x, y), exponent(x, z))).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the exponent_product_distribution axiom. - * - * @return exponent_product_distribution - */ - public final Formula exponentProductDistribution() { - // ! [X,Y,Z] : exponent(product(X,Y),Z) = - // product(exponent(X,Z),exponent(Y,Z)) - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - final Variable z = Variable.unary("Z"); - return exponent(product(x, y), z).eq(product(exponent(x, z), exponent(y, z))).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the exponent_exponent axiom. - * - * @return exponent_exponent - */ - public final Formula exponentExponent() { - // ! [X,Y,Z] : exponent(exponent(X,Y),Z) = exponent(X,product(Y,Z)) - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - final Variable z = Variable.unary("Z"); - return exponent(exponent(x, y), z).eq(exponent(x, product(y, z))).forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)).and(z.oneOf(UNIV))); - } - - /** - * Returns the conjuction of all axioms. - * - * @return axioms - */ - public final Formula axioms() { - return decls().and(sumSymmetry()).and(sumAssociativity()).and(productIdentity()).and(productSymmetry()).and(productAssociativity()).and(sumProductDistribution()).and(exponentN1()).and(exponentIdentity()).and(exponentSumProduct()).and(exponentProductDistribution()).and(exponentExponent()); - } - - /** - * Returns the wilkie conjecture. - * - * @return wilkie - */ - public final Formula wilkie() { - // ! [C,P,Q,R,S,A,B] : - // ( ( C = product(A,A) - // & P = sum(n1,A) - // & Q = sum(P,C) - // & R = sum(n1,product(A,C)) - // & S = sum(sum(n1,C),product(C,C)) ) - // => - // product(exponent(sum(exponent(P,A),exponent(Q,A)),B),exponent(sum(exponent(R,B),exponent(S,B)),A)) - // = - // product(exponent(sum(exponent(P,B),exponent(Q,B)),A),exponent(sum(exponent(R,A),exponent(S,A)),B)) - // ) )). - final Variable c = Variable.unary("C"); - final Variable p = Variable.unary("P"); - final Variable q = Variable.unary("Q"); - final Variable r = Variable.unary("R"); - final Variable s = Variable.unary("S"); - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Formula f0 = c.eq(product(a, a)); - final Formula f1 = p.eq(sum(n1, a)); - final Formula f2 = q.eq(sum(p, c)); - final Formula f3 = r.eq(sum(n1, product(a, c))); - final Formula f4 = s.eq(sum(sum(n1, c), product(c, c))); - final Expression e0 = product(exponent(sum(exponent(p, a), exponent(q, a)), b), exponent(sum(exponent(r, b), exponent(s, b)), a)); - final Expression e1 = product(exponent(sum(exponent(p, b), exponent(q, b)), a), exponent(sum(exponent(r, a), exponent(s, a)), b)); - final Formula f5 = e0.eq(e1); - return (f0.and(f1).and(f2).and(f3).and(f4)).implies(f5).forAll(c.oneOf(UNIV).and(p.oneOf(UNIV)).and(q.oneOf(UNIV)).and(r.oneOf(UNIV)).and(s.oneOf(UNIV)).and(a.oneOf(UNIV)).and(b.oneOf(UNIV))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !wilkie() - */ - public final Formula checkWilkie() { - return axioms().and(wilkie().not()); - } - - /** - * Returns the bounds for the given scope. - * - * @return bounds for the given scope - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - final TupleSet all3 = f.allOf(3); - b.bound(sum, all3); - b.bound(product, all3); - b.bound(exponent, all3); - b.bound(n1, f.allOf(1)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.NUM374 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.NUM374 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final NUM374 model = new NUM374(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setSymmetryBreaking(n * n); - final Formula f = model.checkWilkie(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM378.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM378.class deleted file mode 100644 index 458f98c36..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM378.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM378.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM378.java deleted file mode 100644 index f986f62f4..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/NUM378.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * A KK encoding of NUM378+1.020.015.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class NUM378 { - - private final Relation succ, sum; - - /** - * Constructs a new instance of NUM378. - */ - public NUM378() { - succ = Relation.binary("succ"); - sum = Relation.ternary("sum"); - } - - /** - * Returns the expression y.(x.sum) - * - * @return y.(x.sum) - */ - final Expression sum(Expression x, Expression y) { - return y.join(x.join(sum)); - } - - /** - * Returns the successor of x. - * - * @return x.succ - */ - final Expression succ(Expression x) { - return x.join(succ); - } - - /** - * Returns the predecessor of x. - * - * @return succ.x - */ - final Expression pred(Expression x) { - return succ.join(x); - } - - /** - * Returns the declarations. - * - * @return one a && one b && one c - */ - public final Formula decls() { - final Variable x = Variable.unary("X"); - final Variable y = Variable.unary("Y"); - return succ.function(UNIV, UNIV).and(sum(x, y).one().forAll(x.oneOf(UNIV).and(y.oneOf(UNIV)))); - } - - private final Variable[] vars(String name, int size) { - final Variable[] vars = new Variable[size]; - for (int i = 0; i < size; i++) { - vars[i] = Variable.unary(name + i); - } - return vars; - } - - private final Decls decls(Variable[] vars) { - Decls d = vars[0].oneOf(UNIV); - for (int i = 1; i < vars.length; i++) { - d = d.and(vars[i].oneOf(UNIV)); - } - return d; - } - - /** - * Returns the try_satisfy_this axiom. - * - * @return try_satisfy_this - */ - public final Formula inequalities() { - final Variable[] x = vars("X", 16); - final Variable[] y = vars("Y", 16); - final Variable[] npx = vars("NPX", 15); - final Variable[] nsx = vars("NSX", 15); - final Variable[] npy = vars("NPY", 15); - final Variable[] nsy = vars("NSY", 15); - - Expression s21 = succ; - for (int i = 1; i < 21; i++) { - s21 = s21.join(succ); - } - - Formula f = Formula.TRUE; - - for (int i = 0; i < 15; i++) { - Formula f0 = npx[i].eq(s21.join(x[i])); - Formula f1 = nsx[i].eq(x[i].join(s21)); - Formula f2 = npy[i].eq(s21.join(y[i])); - Formula f3 = nsy[i].eq(y[i].join(s21)); - f = f.and(f0).and(f1).and(f2).and(f3); - } - - for (int i = 1; i < 16; i++) { - Formula f0 = x[i].eq(sum(sum(pred(x[i - 1]), succ(y[i - 1])), sum(pred(y[i - 1]), succ(x[i - 1])))); - Formula f1 = y[i].eq(sum(pred(nsx[i - 1]), sum(succ(npx[i - 1]), sum(pred(nsy[i - 1]), succ(npy[i - 1]))))); - f = f.and(f0).and(f1); - } - - Formula g = Formula.FALSE; - for (int i = 12; i < 16; i++) { - g = g.or(x[i].eq(y[i]).not()); - } - - return f.and(g).forSome(decls(x).and(decls(y)).and(decls(npx)).and(decls(nsx)).and(decls(npy)).and(decls(nsy))); - } - - /** - * Returns the conjunction of the axioms and the hypothesis. - * - * @return axioms() && inequalities() - */ - public final Formula checkInequalities() { - return decls().and(inequalities()); - } - - /** - * Returns bounds for the problem. - * - * @return bounds for the problem. - */ - public final Bounds bounds() { - final int n = 21; - final List atoms = new ArrayList(n); - atoms.add("goal"); - for (int i = 0; i < n; i++) - atoms.add("n" + i); - final Universe u = new Universe(atoms); - final Bounds bound = new Bounds(u); - final TupleFactory f = u.factory(); - - final TupleSet succBound = f.noneOf(2); - for (int i = 0; i < n; i++) { - succBound.add(f.tuple("n" + i, "n" + ((i + 1) % n))); - } - bound.boundExactly(succ, succBound); - - final TupleSet sumBound = f.noneOf(3); - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { - sumBound.add(f.tuple("n" + i, "n" + j, "n" + ((i + j) % n))); - } - } - bound.boundExactly(sum, sumBound); - return bound; - } - - private static void usage() { - System.out.println("java examples.tptp.NUM378"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.NUM378 - */ - public static void main(String[] args) { - - try { - - final NUM378 model = new NUM378(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Formula f = model.decls().and(model.inequalities()); - final Bounds b = model.bounds(); - // System.out.println(f); - // System.out.println(b); - final Solution sol = solver.solve(f, b); - System.out.println(sol.outcome()); - System.out.println(sol.stats()); - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/Quasigroups7.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/Quasigroups7.class deleted file mode 100644 index b4d998af3..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/Quasigroups7.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/Quasigroups7.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/Quasigroups7.java deleted file mode 100644 index dae0a95ec..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/Quasigroups7.java +++ /dev/null @@ -1,290 +0,0 @@ -package examples.tptp; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Contains the relations/axioms common to the problems ALG195+1.p and - * ALG197+1.p from from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public abstract class Quasigroups7 { - - final Relation[] e1, e2, h; - final Relation op1, op2, s1, s2; - - /** - * Constructs a new instance of Quasigroups7. - */ - Quasigroups7() { - op1 = Relation.ternary("op1"); - op2 = Relation.ternary("op2"); - s1 = Relation.unary("e1"); - s2 = Relation.unary("e2"); - e1 = new Relation[7]; - e2 = new Relation[7]; - h = new Relation[7]; - for (int i = 0; i < 7; i++) { - e1[i] = Relation.unary("e1" + i); - e2[i] = Relation.unary("e2" + i); - h[i] = Relation.binary("h" + (i + 1)); - } - } - - private static Formula function(Relation s, Relation op) { - final Variable x = Variable.unary("x"), y = Variable.unary("y"); - return y.join(x.join(op)).one().forAll(x.oneOf(s).and(y.oneOf(s))); - } - - /** - * Returns the relation constraints. - * - * @returns the relation constraints. - */ - public final Formula decls() { - final List formulas = new ArrayList(2 + h.length); - formulas.add(function(s1, op1)); - formulas.add(function(s2, op2)); - for (Relation x : h) { - formulas.add(x.function(s1, s2)); - } - return Formula.and(formulas); - } - - private Expression op1(Expression arg1, Expression arg2) { - return arg1.join(arg2.join(op1)); - } - - private Expression op2(Expression arg1, Expression arg2) { - return arg1.join(arg2.join(op2)); - } - - /** - * Returns axioms 2 and 7. - * - * @return ax2 and ax7 - */ - public final Formula ax2ax7() { - final Variable x = Variable.unary("x"); - return s1.eq(op1(x, s1)).and(s1.eq(op1(s1, x))).forAll(x.oneOf(s1)); - } - - /** - * Returns axiom 3. - * - * @return ax3 - */ - public final Formula ax3() { - final Variable x = Variable.unary("x"), y = Variable.unary("y"); - return x.eq(op1(op1(op1(y, x), y), y)).forAll(x.oneOf(s1).and(y.oneOf(s1))); - } - - /** - * Returns axioms 5 and 8. - * - * @return ax5 and ax8 - */ - public final Formula ax5ax8() { - final Variable x = Variable.unary("x"); - return s2.eq(op2(x, s2)).and(s2.eq(op2(s2, x))).forAll(x.oneOf(s2)); - } - - /** - * Returns axiom 6. - * - * @return ax6 - */ - public final Formula ax6() { - final Variable x = Variable.unary("x"), y = Variable.unary("y"); - return x.eq(op2(op2(op2(y, x), y), y)).forAll(x.oneOf(s2).and(y.oneOf(s2))); - } - - /** - * Parametrization of axioms 12 and 13. - * - * @requires e's are unary, op is ternary - */ - abstract Formula ax12and13(Relation[] e, Relation op); - - /** - * Returns axiom 12. - * - * @return ax12 - */ - public final Formula ax12() { - return ax12and13(e1, op1); - } - - /** - * Returns axiom 13. - * - * @return ax13 - */ - public final Formula ax13() { - return ax12and13(e2, op2); - } - - /** - * Parametrization of axioms 14 and 15. - * - * @requires e's are unary, op is ternary - */ - abstract Formula ax14and15(Relation[] e, Relation op); - - /** - * Returns lines 1 and 3-6 of axiom 14. - * - * @return ax14 - */ - public final Formula ax14() { - return ax14and15(e1, op1); - } - - /** - * Returns lines 1 and 3-6 of axiom 15. - * - * @return ax15 - */ - public final Formula ax15() { - return ax14and15(e2, op2); - } - - /** - * Parametrization of axioms 16-22. - * - * @requires e is unary, h is binary - */ - abstract Formula ax16_22(Relation e, Relation h); - - /** - * Returns lines 2-7 of axioms 16-22. - * - * @return lines 2-7 of axioms 16-22. - */ - public final Formula ax16_22() { - final List formulas = new ArrayList(); - for (int i = 0; i < 7; i++) { - formulas.add(ax16_22(e2[i], h[i])); - } - return Formula.and(formulas); - } - - /** - * Returns the conjunction of all axioms and implicit constraints (decls()). - * - * @return the conjunction of all axioms and implicit constraints - */ - public final Formula axioms() { - final List formulas = new ArrayList(); - formulas.add(decls()); - formulas.add(ax2ax7()); - formulas.add(ax3()); - formulas.add(ax5ax8()); - formulas.add(ax6()); - formulas.add(ax12()); - formulas.add(ax13()); - formulas.add(ax14()); - formulas.add(ax15()); - formulas.add(ax16_22()); - return Formula.and(formulas); - } - - /** - * Returns the part of the conjecture 1 that applies to the given h. - * - * @return the part of the conjecture 1 that applies to the given h. - */ - private final Formula co1h(Relation h) { - final Variable x = Variable.unary("x"), y = Variable.unary("y"); - return op1(x, y).join(h).eq(op2(x.join(h), y.join(h))).forAll(x.oneOf(s1).and(y.oneOf(s1))); - } - - /** - * Returns conjecture 1. - * - * @return co1 - */ - public final Formula co1() { - - final List formulas = new ArrayList(); - for (int i = 0; i < 7; i++) { - formulas.add(co1h(h[i])); - } - - return Formula.or(formulas); - } - - /** - * Returns the partial bounds the problem (axioms 1, 4, 9-11). - * - * @return the partial bounds for the problem - */ - public Bounds bounds() { - final List atoms = new ArrayList(14); - for (int i = 0; i < 7; i++) - atoms.add("e1" + i); - for (int i = 0; i < 7; i++) - atoms.add("e2" + i); - - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - - b.boundExactly(s1, f.range(f.tuple("e10"), f.tuple("e16"))); - b.boundExactly(s2, f.range(f.tuple("e20"), f.tuple("e26"))); - - // axioms 9, 10, 11 - for (int i = 0; i < 7; i++) { - b.boundExactly(e1[i], f.setOf("e1" + i)); - b.boundExactly(e2[i], f.setOf("e2" + i)); - } - - // axom 1 - final TupleSet op1h = f.area(f.tuple("e10", "e10", "e10"), f.tuple("e16", "e16", "e16")); - // axiom 4 - final TupleSet op2h = f.area(f.tuple("e20", "e20", "e20"), f.tuple("e26", "e26", "e26")); - - b.bound(op1, op1h); - b.bound(op2, op2h); - - return b; - } - - private static void displayOp(Instance instance, Relation op) { - System.out.println("\n" + op + ":"); - final Iterator iter = instance.tuples(op).iterator(); - for (int i = 0; i < 7; i++) { - for (int j = 0; j < 7; j++) { - System.out.print(iter.next().atom(2)); - System.out.print("\t"); - } - System.out.println(); - } - } - - /** - * Prints the values of the op1, op2, and h1-h7 relations to standard out. - */ - void display(Instance instance) { - displayOp(instance, op1); - displayOp(instance, op2); - for (int i = 0; i < 7; i++) { - System.out.println("\n" + h[i] + ":"); - System.out.println(instance.tuples(h[i])); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET943.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET943.class deleted file mode 100644 index 7115521a8..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET943.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET943.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET943.java deleted file mode 100644 index 764fb4fbd..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET943.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of SET943+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class SET943 { - - private final Relation empty; - private final Relation subset, in, union; - private final Relation union2; - - /** - * Constructs a new instance of SET943. - */ - public SET943() { - empty = Relation.unary("empty"); - subset = Relation.binary("subset"); - in = Relation.binary("in"); - union = Relation.binary("union"); - union2 = Relation.ternary("set_union2"); - } - - /** - * Returns set_union2[A][B] - * - * @return set_union2[A][B] - */ - final Expression set_union2(Expression a, Expression b) { - return b.join(a.join(union2)); - } - - /** - * Returns union[a] - * - * @return union[a] - */ - final Expression union(Expression a) { - return a.join(union); - } - - /** - * Returns a in empty - * - * @return a in empty - */ - final Formula empty(Expression a) { - return a.in(empty); - } - - /** - * Returns a->b in subset. - * - * @return a->b in subset. - */ - final Formula subset(Expression a, Expression b) { - return a.product(b).in(subset); - } - - /** - * Returns a->b in in. - * - * @return a->b in in - */ - final Formula in(Expression a, Expression b) { - return a.product(b).in(in); - } - - /** - * Returns the declarations. - * - * @return declarations - */ - public final Formula decls() { - final Formula f0 = union.function(UNIV, UNIV); - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Formula f1 = set_union2(a, b).one(); - return f0.and(f1.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)))); - } - - /** - * Returns antisymmetry_r2_hidden axiom. - * - * @return antisymmetry_r2_hidden - */ - public final Formula antisymmetry_r2_hidden() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return in(a, b).implies(in(b, a).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns commutativity_k2_xboole_0 axiom. - * - * @return commutativity_k2_xboole_0 - */ - public final Formula commutativity_k2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return set_union2(a, b).eq(set_union2(b, a)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d10_xboole_0 axiom. - * - * @return d10_xboole_0 - */ - public final Formula d10_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return a.eq(b).iff(subset(a, b).and(subset(b, a))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d2_xboole_0 axiom. - * - * @return d2_xboole_0 - */ - public final Formula d2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - return c.eq(set_union2(a, b)).iff(in.join(c).eq(in.join(a).union(in.join(b)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns d3_tarski axiom. - * - * @return d3_tarski - */ - public final Formula d3_tarski() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return subset(a, b).iff(in.join(a).in(in.join(b))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d4_tarski axiom. - * - * @return d4_tarski - */ - public final Formula d4_tarski() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return b.eq(union(a)).iff(in.join(b).eq(in.join(in.join(a)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc2_xboole_0 axiom. - * - * @return fc2_xboole_0 - */ - public final Formula fc2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(a).not().implies(empty(set_union2(a, b)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc3_xboole_0 axiom. - * - * @return fc3_xboole_0 - */ - public final Formula fc3_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(a).not().implies(empty(set_union2(b, a)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns idempotence_k2_xboole_0 axiom. - * - * @return idempotence_k2_xboole_0 - */ - public final Formula idempotence_k2_xboole_0() { - final Variable a = Variable.unary("A"); - return set_union2(a, a).eq(a).forAll(a.oneOf(UNIV)); - } - - /** - * Returns rc1_xboole_0 axiom. - * - * @return rc1_xboole_0 - */ - public final Formula rc1_xboole_0() { - return empty.some(); - } - - /** - * Returns rc2_xboole_0 axiom. - * - * @return rc2_xboole_0 - */ - public final Formula rc2_xboole_0() { - return UNIV.difference(empty).some(); - } - - /** - * Returns reflexivity_r1_tarski axiom. - * - * @return reflexivity_r1_tarski - */ - public final Formula reflexivity_r1_tarski() { - final Variable a = Variable.unary("A"); - return subset(a, a).forAll(a.oneOf(UNIV)); - } - - // all A, B: Atom | subset(A,set_union2(A,B)) - - /** - * Returns t7_xboole_1 axiom. - * - * @return t7_xboole_1 - */ - public final Formula t7_xboole_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return subset(a, set_union2(a, b)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns t8_xboole_1 axiom. - * - * @return t8_xboole_1 - */ - public final Formula t8_xboole_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - return subset(a, b).and(subset(c, b)).implies(subset(set_union2(a, c), b)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns t95_zfmisc_1 axiom. - * - * @return t95_zfmisc_1 - */ - public final Formula t95_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return subset(a, b).implies(subset(union(a), union(b))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms. - */ - public final Formula axioms() { - return decls().and(antisymmetry_r2_hidden()).and(commutativity_k2_xboole_0()).and(d10_xboole_0()).and(d2_xboole_0()).and(d3_tarski()).and(d4_tarski()).and(fc2_xboole_0()).and(fc3_xboole_0()).and(idempotence_k2_xboole_0()).and(rc1_xboole_0()).and(rc2_xboole_0()).and(reflexivity_r1_tarski()).and(t7_xboole_1()).and(t8_xboole_1()).and(t95_zfmisc_1()); - } - - /** - * Returns t96_zfmisc_1 conjecture. - * - * @return t96_zfmisc_1 - */ - public final Formula t96_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return union(set_union2(a, b)).eq(set_union2(union(a), union(b))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !t96_zfmisc_1() - */ - public final Formula checkT96_zfmisc_1() { - return axioms().and(t96_zfmisc_1().not()); - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - b.bound(empty, f.allOf(1)); - b.bound(subset, f.allOf(2)); - b.bound(in, f.allOf(2)); - b.bound(union, f.allOf(2)); - b.bound(union2, f.allOf(3)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.SET943 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.SET943 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final SET943 model = new SET943(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(1000); - // solver.options().setFlatten(false); - final Formula f = model.checkT96_zfmisc_1(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET948.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET948.class deleted file mode 100644 index 917a39ce4..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET948.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET948.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET948.java deleted file mode 100644 index 12317b930..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET948.java +++ /dev/null @@ -1,391 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of SET948+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class SET948 { - - private final Relation empty; - private final Relation subset, in, disjoint, union; - private final Relation intersect2, union2; - - /** - * Constructs a new instance of SET948. - */ - public SET948() { - empty = Relation.unary("empty"); - subset = Relation.binary("subset"); - in = Relation.binary("in"); - disjoint = Relation.binary("disjoint"); - union = Relation.binary("union"); - intersect2 = Relation.ternary("set_intersection2"); - union2 = Relation.ternary("set_union2"); - } - - /** - * Returns set_intersection2[A][B] - * - * @return set_intersection2[A][B] - */ - final Expression set_intersection2(Expression a, Expression b) { - return b.join(a.join(intersect2)); - } - - /** - * Returns set_union2[A][B] - * - * @return set_union2[A][B] - */ - final Expression set_union2(Expression a, Expression b) { - return b.join(a.join(union2)); - } - - /** - * Returns union[a] - * - * @return union[a] - */ - final Expression union(Expression a) { - return a.join(union); - } - - /** - * Returns a in empty - * - * @return a in empty - */ - final Formula empty(Expression a) { - return a.in(empty); - } - - /** - * Returns a->b in subset. - * - * @return a->b in subset. - */ - final Formula subset(Expression a, Expression b) { - return a.product(b).in(subset); - } - - /** - * Returns a->b in in. - * - * @return a->b in in - */ - final Formula in(Expression a, Expression b) { - return a.product(b).in(in); - } - - /** - * Returns a->b in disjoint. - * - * @return a->b in disjoint - */ - final Formula disjoint(Expression a, Expression b) { - return a.product(b).in(disjoint); - } - - /** - * Returns the declarations. - * - * @return declarations - */ - public final Formula decls() { - final Formula f0 = union.function(UNIV, UNIV); - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Formula f1 = set_intersection2(a, b).one(); - final Formula f2 = set_union2(a, b).one(); - return f0.and(f1.and(f2).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)))); - } - - /** - * Returns antisymmetry_r2_hidden axiom. - * - * @return antisymmetry_r2_hidden - */ - public final Formula antisymmetry_r2_hidden() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return in(a, b).implies(in(b, a).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns commutativity_k2_xboole_0 axiom. - * - * @return commutativity_k2_xboole_0 - */ - public final Formula commutativity_k2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return set_union2(a, b).eq(set_union2(b, a)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d10_xboole_0 axiom. - * - * @return d10_xboole_0 - */ - public final Formula d10_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return a.eq(b).iff(subset(a, b).and(subset(b, a))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d2_xboole_0 axiom. - * - * @return d2_xboole_0 - */ - public final Formula d2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - return c.eq(set_union2(a, b)).iff(in.join(c).eq(in.join(a).union(in.join(b)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns d3_tarski axiom. - * - * @return d3_tarski - */ - public final Formula d3_tarski() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return subset(a, b).iff(in.join(a).in(in.join(b))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d3_xboole_0 axiom. - * - * @return d3_xboole_0 - */ - public final Formula d3_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - return c.eq(set_intersection2(a, b)).iff(in.join(c).eq(in.join(a).intersection(in.join(b)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns d4_tarski axiom. - * - * @return d4_tarski - */ - public final Formula d4_tarski() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return b.eq(union(a)).iff(in.join(b).eq(in.join(in.join(a)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc2_xboole_0 axiom. - * - * @return fc2_xboole_0 - */ - public final Formula fc2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(a).not().implies(empty(set_union2(a, b)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc3_xboole_0 axiom. - * - * @return fc3_xboole_0 - */ - public final Formula fc3_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(a).not().implies(empty(set_union2(b, a)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns idempotence_k2_xboole_0 axiom. - * - * @return idempotence_k2_xboole_0 - */ - public final Formula idempotence_k2_xboole_0() { - final Variable a = Variable.unary("A"); - return set_union2(a, a).eq(a).forAll(a.oneOf(UNIV)); - } - - /** - * Returns idempotence_k3_xboole_0 axiom. - * - * @return idempotence_k3_xboole_0 - */ - public final Formula idempotence_k3_xboole_0() { - final Variable a = Variable.unary("A"); - return set_intersection2(a, a).eq(a).forAll(a.oneOf(UNIV)); - } - - /** - * Returns rc1_xboole_0 axiom. - * - * @return rc1_xboole_0 - */ - public final Formula rc1_xboole_0() { - return empty.some(); - } - - /** - * Returns rc2_xboole_0 axiom. - * - * @return rc2_xboole_0 - */ - public final Formula rc2_xboole_0() { - return UNIV.difference(empty).some(); - } - - /** - * Returns reflexivity_r1_tarski axiom. - * - * @return reflexivity_r1_tarski - */ - public final Formula reflexivity_r1_tarski() { - final Variable a = Variable.unary("A"); - return subset(a, a).forAll(a.oneOf(UNIV)); - } - - /** - * Returns symmetry_r1_xboole_0 axiom. - * - * @return symmetry_r1_xboole_0 - */ - public final Formula symmetry_r1_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return disjoint(a, b).implies(disjoint(b, a)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns t4_xboole_0 axiom. - * - * @return t4_xboole_0 - */ - public final Formula t4_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return disjoint(a, b).not().implies(set_intersection2(a, b).some()).and(disjoint(a, b).implies(set_intersection2(a, b).no())).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns t97_zfmisc_1 axiom. - * - * @return t97_zfmisc_1 - */ - public final Formula t97_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return subset(union(set_intersection2(a, b)), set_intersection2(union(a), union(b))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms. - */ - public final Formula axioms() { - return decls().and(antisymmetry_r2_hidden()).and(commutativity_k2_xboole_0()).and(d10_xboole_0()).and(d2_xboole_0()).and(d3_tarski()).and(d3_xboole_0()).and(d4_tarski()).and(fc2_xboole_0()).and(fc3_xboole_0()).and(idempotence_k2_xboole_0()).and(idempotence_k3_xboole_0()).and(rc1_xboole_0()).and(rc2_xboole_0()).and(reflexivity_r1_tarski()).and(symmetry_r1_xboole_0()).and(t4_xboole_0()).and(t97_zfmisc_1()); - } - - /** - * Returns t101_zfmisc_1 conjecture. - * - * @return t101_zfmisc_1 - */ - public final Formula t101_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Variable d = Variable.unary("D"); - final Formula f0 = in(c.union(d), set_union2(a, b)).implies(c.eq(d).or(disjoint(c, c))).forAll(c.oneOf(UNIV).and(d.oneOf(UNIV))); - final Formula f1 = union(set_intersection2(a, b)).eq(set_intersection2(union(a), union(b))); - return f0.implies(f1).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !t101_zfmisc_1() - */ - public final Formula checkT101_zfmisc_1() { - return axioms().and(t101_zfmisc_1().not()); - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - b.bound(empty, f.allOf(1)); - b.bound(subset, f.allOf(2)); - b.bound(in, f.allOf(2)); - b.bound(disjoint, f.allOf(2)); - b.bound(union, f.allOf(2)); - b.bound(intersect2, f.allOf(3)); - b.bound(union2, f.allOf(3)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.SET948 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.SET948 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final SET948 model = new SET948(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(n*n); - // solver.options().setFlatten(false); - final Formula f = model.checkT101_zfmisc_1(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET967.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET967.class deleted file mode 100644 index a8289e527..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET967.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET967.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET967.java deleted file mode 100644 index 20bec9ff7..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/SET967.java +++ /dev/null @@ -1,442 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of SET967+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class SET967 { - - private final Relation empty; - private final Relation subset, in, disjoint, union, singleton; - private final Relation intersect2, union2, cartesian2, ordered, unordered; - - /** - * Constructs a new instance of SET967. - */ - public SET967() { - empty = Relation.unary("empty"); - subset = Relation.binary("subset"); - in = Relation.binary("in"); - disjoint = Relation.binary("disjoint"); - union = Relation.binary("union"); - singleton = Relation.binary("singleton"); - intersect2 = Relation.ternary("set_intersection2"); - union2 = Relation.ternary("set_union2"); - cartesian2 = Relation.ternary("cartesian_product2"); - ordered = Relation.ternary("ordered_pair"); - unordered = Relation.ternary("unordered_pair"); - } - - /** - * Returns set_intersection2[A][B] - * - * @return set_intersection2[A][B] - */ - final Expression set_intersection2(Expression a, Expression b) { - return b.join(a.join(intersect2)); - } - - /** - * Returns set_union2[A][B] - * - * @return set_union2[A][B] - */ - final Expression set_union2(Expression a, Expression b) { - return b.join(a.join(union2)); - } - - /** - * Returns cartesian_product2[A][B] - * - * @return cartesian_product2[A][B] - */ - final Expression cartesian_product2(Expression a, Expression b) { - return b.join(a.join(cartesian2)); - } - - /** - * Returns ordered_pair[A][B] - * - * @return ordered_pair[A][B] - */ - final Expression ordered_pair(Expression a, Expression b) { - return b.join(a.join(ordered)); - } - - /** - * Returns unordered_pair[A][B] - * - * @return unordered_pair[A][B] - */ - final Expression unordered_pair(Expression a, Expression b) { - return b.join(a.join(unordered)); - } - - /** - * Returns union[a] - * - * @return union[a] - */ - final Expression union(Expression a) { - return a.join(union); - } - - /** - * Returns singleton[a] - * - * @return singleton[a] - */ - final Expression singleton(Expression a) { - return a.join(singleton); - } - - /** - * Returns a in empty - * - * @return a in empty - */ - final Formula empty(Expression a) { - return a.in(empty); - } - - /** - * Returns a->b in subset. - * - * @return a->b in subset. - */ - final Formula subset(Expression a, Expression b) { - return a.product(b).in(subset); - } - - /** - * Returns a->b in in. - * - * @return a->b in in - */ - final Formula in(Expression a, Expression b) { - return a.product(b).in(in); - } - - /** - * Returns a->b in disjoint. - * - * @return a->b in disjoint - */ - final Formula disjoint(Expression a, Expression b) { - return a.product(b).in(disjoint); - } - - /** - * Returns the declarations. - * - * @return declarations - */ - public final Formula decls() { - final Formula f0 = union.function(UNIV, UNIV); - final Formula f1 = singleton.function(UNIV, UNIV); - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Formula f2 = set_intersection2(a, b).one(); - final Formula f3 = set_union2(a, b).one(); - final Formula f4 = cartesian_product2(a, b).one(); - final Formula f5 = ordered_pair(a, b).one(); - final Formula f6 = unordered_pair(a, b).one(); - return f0.and(f1).and(f2.and(f3).and(f4).and(f5).and(f6).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)))); - } - - /** - * Returns antisymmetry_r2_hidden axiom. - * - * @return antisymmetry_r2_hidden - */ - public final Formula antisymmetry_r2_hidden() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return in(a, b).implies(in(b, a).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns commutativity_k2_tarski axiom. - * - * @return commutativity_k2_tarski - */ - public final Formula commutativity_k2_tarski() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return unordered_pair(a, b).eq(unordered_pair(b, a)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns commutativity_k2_xboole_0 axiom. - * - * @return commutativity_k2_xboole_0 - */ - public final Formula commutativity_k2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return set_union2(a, b).eq(set_union2(b, a)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns d2_xboole_0 axiom. - * - * @return d2_xboole_0 - */ - public final Formula d2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - return c.eq(set_union2(a, b)).iff(in.join(c).eq(in.join(a).union(in.join(b)))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns d5_tarski axiom. - * - * @return d5_tarski - */ - public final Formula d5_tarski() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return ordered_pair(a, b).eq(unordered_pair(unordered_pair(a, b), singleton(a))).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc1_misc_1 axiom. - * - * @return fc1_misc_1 - */ - public final Formula fc1_misc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(ordered_pair(a, b)).not().forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc2_xboole_0 axiom. - * - * @return fc2_xboole_0 - */ - public final Formula fc2_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(a).not().implies(empty(set_union2(a, b)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns fc3_xboole_0 axiom. - * - * @return fc3_xboole_0 - */ - public final Formula fc3_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return empty(a).not().implies(empty(set_union2(b, a)).not()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns idempotence_k2_xboole_0 axiom. - * - * @return idempotence_k2_xboole_0 - */ - public final Formula idempotence_k2_xboole_0() { - final Variable a = Variable.unary("A"); - return set_union2(a, a).eq(a).forAll(a.oneOf(UNIV)); - } - - /** - * Returns 155_zfmisc_1 axiom. - * - * @return 155_zfmisc_1 - */ - public final Formula a155_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Variable d = Variable.unary("D"); - final Formula f0 = in(ordered_pair(a, b), cartesian_product2(c, d)); - final Formula f1 = in(a, c).and(in(b, d)); - return f0.iff(f1).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV)).and(d.oneOf(UNIV))); - } - - /** - * Returns rc1_xboole_0 axiom. - * - * @return rc1_xboole_0 - */ - public final Formula rc1_xboole_0() { - return empty.some(); - } - - /** - * Returns rc2_xboole_0 axiom. - * - * @return rc2_xboole_0 - */ - public final Formula rc2_xboole_0() { - return UNIV.difference(empty).some(); - } - - /** - * Returns t102_zfmisc_1 axiom. - * - * @return t102_zfmisc_1 - */ - public final Formula t102_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - return in(a, cartesian_product2(b, c)).implies(ordered.join(a).some()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns t107_zfmisc_1 axiom. - * - * @return t107_zfmisc_1 - */ - public final Formula t107_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Variable d = Variable.unary("D"); - final Formula f0 = in(ordered_pair(a, b), cartesian_product2(c, d)); - final Formula f1 = in(ordered_pair(b, a), cartesian_product2(d, c)); - return f0.iff(f1).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV)).and(d.oneOf(UNIV))); - } - - /** - * Returns t4_xboole_0 axiom. - * - * @return t4_xboole_0 - */ - public final Formula t4_xboole_0() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return disjoint(a, b).not().implies(set_intersection2(a, b).some()).and(disjoint(a, b).implies(set_intersection2(a, b).no())).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns t112_zfmisc_1 axiom. - * - * @return t112_zfmisc_1 - */ - public final Formula t112_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Variable d = Variable.unary("D"); - final Formula f0 = in(c, a).implies(ordered.join(c).some()).forAll(c.oneOf(UNIV)); - final Formula f1 = in(c, b).implies(ordered.join(c).some()).forAll(c.oneOf(UNIV)); - final Formula f2 = in(ordered_pair(c, d), a).iff(in(ordered_pair(c, d), b)).forAll(c.oneOf(UNIV).and(d.oneOf(UNIV))); - return f0.and(f1).and(f2).implies(a.eq(b)).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms. - */ - public final Formula axioms() { - return decls().and(antisymmetry_r2_hidden()).and(commutativity_k2_xboole_0()).and(commutativity_k2_tarski()).and(d2_xboole_0()).and(d5_tarski()).and(fc1_misc_1()).and(fc2_xboole_0()).and(fc3_xboole_0()).and(idempotence_k2_xboole_0()).and(a155_zfmisc_1()).and(rc1_xboole_0()).and(rc2_xboole_0()).and(t102_zfmisc_1()).and(t107_zfmisc_1()).and(t4_xboole_0()).and(t112_zfmisc_1()); - } - - /** - * Returns t120_zfmisc_1 conjecture. - * - * @return t120_zfmisc_1 - */ - public final Formula t120_zfmisc_1() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Formula f0 = cartesian_product2(set_union2(a, b), c).eq(set_union2(cartesian_product2(a, c), cartesian_product2(b, c))); - final Formula f1 = cartesian_product2(c, set_union2(a, b)).eq(set_union2(cartesian_product2(c, a), cartesian_product2(c, b))); - return f0.and(f1).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV))); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !t120_zfmisc_1() - */ - public final Formula checkT120_zfmisc_1() { - return axioms().and(t120_zfmisc_1().not()); - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - b.bound(empty, f.allOf(1)); - b.bound(subset, f.allOf(2)); - b.bound(in, f.allOf(2)); - b.bound(disjoint, f.allOf(2)); - b.bound(union, f.allOf(2)); - b.bound(singleton, f.allOf(2)); - b.bound(intersect2, f.allOf(3)); - b.bound(cartesian2, f.allOf(3)); - b.bound(union2, f.allOf(3)); - b.bound(ordered, f.allOf(3)); - b.bound(unordered, f.allOf(3)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.SET967 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.SET967 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final SET967 model = new SET967(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(n*n); - // solver.options().setFlatten(false); - final Formula f = model.checkT120_zfmisc_1(); - final Bounds b = model.bounds(n); - System.out.println(f); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/TOP020.class b/org.alloytools.kodkod.core/src/test/java/examples/tptp/TOP020.class deleted file mode 100644 index 6ed39b83f..000000000 Binary files a/org.alloytools.kodkod.core/src/test/java/examples/tptp/TOP020.class and /dev/null differ diff --git a/org.alloytools.kodkod.core/src/test/java/examples/tptp/TOP020.java b/org.alloytools.kodkod.core/src/test/java/examples/tptp/TOP020.java deleted file mode 100644 index 21b4f44b0..000000000 --- a/org.alloytools.kodkod.core/src/test/java/examples/tptp/TOP020.java +++ /dev/null @@ -1,353 +0,0 @@ -/** - * - */ -package examples.tptp; - -import static kodkod.ast.Expression.IDEN; -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.List; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * A KK encoding of TOP020+1.p from http://www.cs.miami.edu/~tptp/ - * - * @author Emina Torlak - */ -public final class TOP020 { - - private final Relation hausdorff; - private final Relation member, open, disjoint, closed; - private final Relation coerce, diagonal; - private final Relation product, tsproduct, ordered; - - /** - * Constructs a new instance of TOP020. - */ - public TOP020() { - hausdorff = Relation.unary("a_hausdorff_top_space"); - member = Relation.binary("a_member_of"); - open = Relation.binary("open_in"); - disjoint = Relation.binary("disjoint"); - closed = Relation.binary("closed_in"); - coerce = Relation.binary("coerce_to_class"); - diagonal = Relation.binary("the_diagonal_top"); - product = Relation.ternary("the_product_of"); - tsproduct = Relation.ternary("the_product_top_space_of"); - ordered = Relation.ternary("ordered_pair"); - } - - /** - * Returns the_product_top_space_of[A][B]. - * - * @return the_product_top_space_of[A][B] - */ - final Expression the_product_top_space_of(Expression a, Expression b) { - return b.join(a.join(tsproduct)); - } - - /** - * Returns the_product_of[A][B]. - * - * @return the_product_of[A][B] - */ - final Expression the_product_of(Expression a, Expression b) { - return b.join(a.join(product)); - } - - /** - * Returns the_ordered_pair[A][B]. - * - * @return the_ordered_pair[A][B] - */ - final Expression the_ordered_pair(Expression a, Expression b) { - return b.join(a.join(ordered)); - } - - /** - * Returns coerce_to_class[A]. - * - * @return coerce_to_class[A] - */ - final Expression coerce_to_class(Expression a) { - return a.join(coerce); - } - - /** - * Returns the_diagonal_top[A]. - * - * @return the_diagonal_top[A] - */ - final Expression the_diagonal_top(Expression a) { - return a.join(diagonal); - } - - /** - * Returns a->b in a_member_of. - * - * @return a->b in a_member_of - */ - final Formula a_member_of(Expression a, Expression b) { - return a.product(b).in(member); - } - - /** - * Returns a->b in open_in. - * - * @return a->b in open_in - */ - final Formula open_in(Expression a, Expression b) { - return a.product(b).in(open); - } - - /** - * Returns a->b in closed_in. - * - * @return a->b in closed_in - */ - final Formula closed_in(Expression a, Expression b) { - return a.product(b).in(closed); - } - - /** - * Returns a->b in disjoint. - * - * @return a->b in disjoint - */ - final Formula disjoint(Expression a, Expression b) { - return a.product(b).in(disjoint); - } - - /** - * Returns the declarations. - * - * @return declarations - */ - public final Formula decls() { - - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - - final List decls = new ArrayList(); - decls.add(coerce.function(UNIV, UNIV)); - decls.add(diagonal.function(UNIV, UNIV)); - decls.add(the_product_top_space_of(a, b).one().forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)))); - decls.add(the_product_of(a, b).one().forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)))); - decls.add(the_ordered_pair(a, b).one().forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)))); - - return Formula.and(decls); - } - - /** - * Returns closed_subset_thm axiom. - * - * @return closed_subset_thm - */ - public final Formula closed_subset_thm() { - final Variable x = Variable.unary("X"); - final Variable a = Variable.unary("A"); - final Variable y = Variable.unary("Y"); - final Formula f0 = a_member_of(y, coerce_to_class(x)).and(a_member_of(y, a).not()); - final Formula f1 = y.join(member).intersection(open.join(x)).intersection(disjoint.join(a)).some(); - final Formula f2 = f0.implies(f1).forAll(y.oneOf(UNIV)); - return f2.implies(closed_in(a, x)).forAll(x.oneOf(UNIV).and(a.oneOf(UNIV))); - } - - /** - * Returns hausdorff axiom. - * - * @return hausdorff - */ - public final Formula hausdorff() { - final Variable x = Variable.unary("X"); - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Expression g1 = open.join(x).intersection(a.join(member)); - final Expression g2 = open.join(x).intersection(b.join(member)); - final Expression abrange = member.join(coerce_to_class(x)); - return a.eq(b).not().implies(g1.product(g2).intersection(disjoint).some()).forAll(a.oneOf(abrange).and(b.oneOf(abrange))).forAll(x.oneOf(hausdorff)); - } - - /** - * Returns product_of_open_sets axiom. - * - * @return product_of_open_sets - */ - public final Formula product_of_open_sets() { - final Variable a = Variable.unary("A"); - final Variable x = Variable.unary("X"); - final Variable b = Variable.unary("B"); - final Variable y = Variable.unary("Y"); - final Formula f0 = open_in(a, x).and(open_in(b, y)); - final Formula f1 = open_in(the_product_of(a, b), the_product_top_space_of(x, y)); - return f0.implies(f1).forAll(a.oneOf(UNIV).and(x.oneOf(UNIV)).and(b.oneOf(UNIV)).and(y.oneOf(UNIV))); - } - - /** - * Returns product_top axiom. - * - * @return product_top - */ - public final Formula product_top() { - final Variable s = Variable.unary("S"); - final Variable t = Variable.unary("T"); - final Variable x = Variable.unary("X"); - final Formula f0 = a_member_of(x, coerce_to_class(the_product_top_space_of(s, t))); - final Expression e0 = member.join(coerce_to_class(s)); - final Expression e1 = member.join(coerce_to_class(t)); - final Formula f1 = ordered.intersection(e0.product(e1).product(x)).some(); - return f0.implies(f1).forAll(s.oneOf(UNIV).and(t.oneOf(UNIV)).and(x.oneOf(UNIV))); - } - - /** - * Returns product axiom. - * - * @return product - */ - public final Formula product() { - final Variable x = Variable.unary("X"); - final Variable s = Variable.unary("S"); - final Variable t = Variable.unary("T"); - final Formula f0 = a_member_of(x, the_product_of(s, t)); - final Expression e0 = member.join(s); - final Expression e1 = member.join(t); - final Formula f1 = ordered.intersection(e0.product(e1).product(x)).some(); - return f0.iff(f1).forAll(x.oneOf(UNIV).and(s.oneOf(UNIV)).and(t.oneOf(UNIV))); - } - - /** - * Returns disjoint_defn axiom. - * - * @return disjoint_defn - */ - public final Formula disjoint_defn() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - return disjoint(a, b).iff(member.join(a).intersection(member.join(b)).no()).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV))); - } - - /** - * Returns ordered_pair axiom. - * - * @return ordered_pair - */ - public final Formula ordered_pair() { - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Variable d = Variable.unary("D"); - final Formula f0 = the_ordered_pair(a, b).eq(the_ordered_pair(c, d)); - final Formula f1 = a.eq(c).and(b.eq(d)); - return f0.implies(f1).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV)).and(d.oneOf(UNIV))); - } - - /** - * Returns diagonal_top axiom. - * - * @return diagonal_top - */ - public final Formula diagonal_top() { - final Variable x = Variable.unary("X"); - final Variable s = Variable.unary("S"); - final Formula f0 = a_member_of(x, coerce_to_class(the_diagonal_top(s))); - final Expression a = member.join(coerce_to_class(s)); - final Formula f1 = ordered.intersection((a.product(a).intersection(IDEN)).product(x)).some(); - return f0.iff(f1).forAll(x.oneOf(UNIV).and(s.oneOf(UNIV))); - } - - /** - * Returns the conjunction of all axioms. - * - * @return conjunction of all axioms. - */ - public final Formula axioms() { - return decls().and(closed_subset_thm()).and(hausdorff()).and(product_of_open_sets()).and(product_top()).and(product()).and(disjoint_defn()).and(ordered_pair()).and(diagonal_top()); - } - - /** - * Returns challenge_AMR_1_4_4 conjecture. - * - * @return challenge_AMR_1_4_4 - */ - public final Formula challenge_AMR_1_4_4() { - final Variable s = Variable.unary("S"); - return closed_in(coerce_to_class(the_diagonal_top(s)), the_product_top_space_of(s, s)).forAll(s.oneOf(hausdorff)); - } - - /** - * Returns the conjunction of the axioms and the negation of the hypothesis. - * - * @return axioms() && !challenge_AMR_1_4_4() - */ - public final Formula checkChallenge_AMR_1_4_4() { - return axioms().and(challenge_AMR_1_4_4().not()); - } - - /** - * Returns bounds for the given scope. - * - * @return bounds for the given scope. - */ - public final Bounds bounds(int n) { - assert n > 0; - final List atoms = new ArrayList(n); - for (int i = 0; i < n; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - b.bound(hausdorff, f.allOf(1)); - b.bound(member, f.allOf(2)); - b.bound(open, f.allOf(2)); - b.bound(disjoint, f.allOf(2)); - b.bound(closed, f.allOf(2)); - b.bound(coerce, f.allOf(2)); - b.bound(diagonal, f.allOf(2)); - b.bound(product, f.allOf(3)); - b.bound(tsproduct, f.allOf(3)); - b.bound(ordered, f.allOf(3)); - return b; - } - - private static void usage() { - System.out.println("java examples.tptp.TOP020 [univ size]"); - System.exit(1); - } - - /** - * Usage: java examples.tptp.TOP020 [univ size] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - try { - final int n = Integer.parseInt(args[0]); - if (n < 1) - usage(); - final TOP020 model = new TOP020(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Formula f = model.checkChallenge_AMR_1_4_4(); - final Bounds b = model.bounds(n); - // System.out.println(f); - // System.out.println(b); - final Solution sol = solver.solve(f, b); - System.out.println(sol); - } catch (NumberFormatException nfe) { - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/AllTests.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/AllTests.java deleted file mode 100644 index a8ea60642..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -package tests.basic; - -// import junit.framework.Test; -// import junit.framework.TestSuite; -// -// public class AllTests { -// -// public static Test suite() { -// TestSuite suite = new TestSuite("Test for tests"); -// //$JUnit-BEGIN$ -// suite.addTestSuite(BooleanMatrixTest.class); -// suite.addTestSuite(TranslatorTest.class); -// suite.addTestSuite(EvaluatorTest.class); -// suite.addTestSuite(BooleanCircuitTest.class); -// suite.addTestSuite(SymmetryBreakingTest.class); -// suite.addTestSuite(SkolemizationTest.class); -// suite.addTestSuite(BugTests.class); -// suite.addTestSuite(ReductionAndProofTest.class); -// suite.addTestSuite(ExamplesTest.class); -//// suite.addTestSuite(MinCostTest.class); -// suite.addTestSuite(IntTest.class); -// suite.addTestSuite(UCoreTest.class); -// //$JUnit-END$ -// return suite; -// } -// -// } diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/BGPTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/BGPTest.java deleted file mode 100644 index 5c9909487..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/BGPTest.java +++ /dev/null @@ -1,1656 +0,0 @@ -package tests.basic; - -import java.util.Arrays; -import java.util.List; - -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.FormulaOperator; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.ConsoleReporter; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; -import kodkod.util.nodes.PrettyPrinter; - -public final class BGPTest { - - public static void main(String[] args) throws Exception { - - Relation x0 = Relation.unary("Int/min"); - Relation x1 = Relation.unary("Int/zero"); - Relation x2 = Relation.unary("Int/max"); - Relation x3 = Relation.nary("Int/next", 2); - Relation x4 = Relation.unary("seq/Int"); - Relation x5 = Relation.unary("String"); - Relation x6 = Relation.unary("this/Natural"); - Relation x7 = Relation.unary("ord/Ord"); - Relation x8 = Relation.unary("this/Zero"); - Relation x9 = Relation.unary("this/One"); - Relation x10 = Relation.nary("this/Natural.data", 4); - Relation x11 = Relation.unary("ord/Ord.First"); - Relation x12 = Relation.nary("ord/Ord.Next", 2); - Relation x13 = Relation.unary(""); - - List atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7", "Natural$0", "Natural$1", "Natural$2", "Natural$3", "ord/Ord$0"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("-8")); - bounds.boundExactly(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("0")); - bounds.boundExactly(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("7")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(2); - x3_upper.add(factory.tuple("-8").product(factory.tuple("-7"))); - x3_upper.add(factory.tuple("-7").product(factory.tuple("-6"))); - x3_upper.add(factory.tuple("-6").product(factory.tuple("-5"))); - x3_upper.add(factory.tuple("-5").product(factory.tuple("-4"))); - x3_upper.add(factory.tuple("-4").product(factory.tuple("-3"))); - x3_upper.add(factory.tuple("-3").product(factory.tuple("-2"))); - x3_upper.add(factory.tuple("-2").product(factory.tuple("-1"))); - x3_upper.add(factory.tuple("-1").product(factory.tuple("0"))); - x3_upper.add(factory.tuple("0").product(factory.tuple("1"))); - x3_upper.add(factory.tuple("1").product(factory.tuple("2"))); - x3_upper.add(factory.tuple("2").product(factory.tuple("3"))); - x3_upper.add(factory.tuple("3").product(factory.tuple("4"))); - x3_upper.add(factory.tuple("4").product(factory.tuple("5"))); - x3_upper.add(factory.tuple("5").product(factory.tuple("6"))); - x3_upper.add(factory.tuple("6").product(factory.tuple("7"))); - bounds.boundExactly(x3, x3_upper); - - TupleSet x4_upper = factory.noneOf(1); - x4_upper.add(factory.tuple("0")); - x4_upper.add(factory.tuple("1")); - x4_upper.add(factory.tuple("2")); - x4_upper.add(factory.tuple("3")); - bounds.boundExactly(x4, x4_upper); - - TupleSet x5_upper = factory.noneOf(1); - bounds.boundExactly(x5, x5_upper); - - TupleSet x6_upper = factory.noneOf(1); - x6_upper.add(factory.tuple("Natural$0")); - x6_upper.add(factory.tuple("Natural$1")); - x6_upper.add(factory.tuple("Natural$2")); - x6_upper.add(factory.tuple("Natural$3")); - bounds.boundExactly(x6, x6_upper); - - TupleSet x7_upper = factory.noneOf(1); - x7_upper.add(factory.tuple("ord/Ord$0")); - bounds.boundExactly(x7, x7_upper); - - TupleSet x8_upper = factory.noneOf(1); - x8_upper.add(factory.tuple("Natural$0")); - x8_upper.add(factory.tuple("Natural$1")); - x8_upper.add(factory.tuple("Natural$2")); - x8_upper.add(factory.tuple("Natural$3")); - bounds.bound(x8, x8_upper); - - TupleSet x9_upper = factory.noneOf(1); - x9_upper.add(factory.tuple("Natural$0")); - x9_upper.add(factory.tuple("Natural$1")); - x9_upper.add(factory.tuple("Natural$2")); - x9_upper.add(factory.tuple("Natural$3")); - bounds.bound(x9, x9_upper); - - TupleSet x10_upper = factory.noneOf(4); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2")).product(factory.tuple("Natural$3"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$0"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$1"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$2"))); - x10_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3")).product(factory.tuple("Natural$3"))); - bounds.bound(x10, x10_upper); - - TupleSet x11_upper = factory.noneOf(1); - x11_upper.add(factory.tuple("Natural$0")); - x11_upper.add(factory.tuple("Natural$1")); - x11_upper.add(factory.tuple("Natural$2")); - x11_upper.add(factory.tuple("Natural$3")); - bounds.bound(x11, x11_upper); - - TupleSet x12_upper = factory.noneOf(2); - x12_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$0"))); - x12_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$1"))); - x12_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$2"))); - x12_upper.add(factory.tuple("Natural$0").product(factory.tuple("Natural$3"))); - x12_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$0"))); - x12_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$1"))); - x12_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$2"))); - x12_upper.add(factory.tuple("Natural$1").product(factory.tuple("Natural$3"))); - x12_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$0"))); - x12_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$1"))); - x12_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$2"))); - x12_upper.add(factory.tuple("Natural$2").product(factory.tuple("Natural$3"))); - x12_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$0"))); - x12_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$1"))); - x12_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$2"))); - x12_upper.add(factory.tuple("Natural$3").product(factory.tuple("Natural$3"))); - bounds.bound(x12, x12_upper); - - TupleSet x13_upper = factory.noneOf(1); - x13_upper.add(factory.tuple("Natural$0")); - x13_upper.add(factory.tuple("Natural$1")); - x13_upper.add(factory.tuple("Natural$2")); - x13_upper.add(factory.tuple("Natural$3")); - bounds.bound(x13, x13_upper); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Formula x15 = x8.in(x6); - Formula x16 = x9.in(x6); - Formula x17 = x8.one(); - Formula x18 = x9.lone(); - Variable x21 = Variable.unary("checkOneSolvable3ToNinjaWheel_this"); - Decls x20 = x21.oneOf(x6); - Expression x23 = x21.join(x10); - Expression x25 = x6.product(x6); - Expression x24 = x6.product(x25); - Formula x22 = x23.in(x24); - Formula x19 = x22.forAll(x20); - Expression x29 = x10.join(Expression.UNIV); - Expression x28 = x29.join(Expression.UNIV); - Expression x27 = x28.join(Expression.UNIV); - Formula x26 = x27.in(x6); - Expression x33 = x7.product(x11); - Expression x32 = x7.join(x33); - Formula x31 = x32.in(x6); - Expression x36 = x7.product(x12); - Expression x35 = x7.join(x36); - Expression x37 = x6.product(x6); - Formula x34 = x35.in(x37); - Formula x38 = x12.totalOrder(x6, x11, x13); - Formula x39 = x11.in(x8); - Expression x41 = x11.join(x12); - Formula x40 = x41.in(x9); - Expression x46 = x10.join(x6); - Expression x45 = x46.join(x6); - Expression x44 = x45.join(x6); - Expression x47 = x44.join(x12); - Expression x43 = x44.difference(x47); - Formula x42 = x43.in(x11); - Variable x50 = Variable.unary("checkOneSolvable3ToNinjaWheel_node"); - Decls x49 = x50.oneOf(x6); - Expression x55 = x50.join(x10); - Expression x54 = x55.join(x6); - Expression x53 = x54.join(x6); - Expression x56 = x53.join(x12); - Expression x52 = x53.difference(x56); - Formula x51 = x52.in(x11); - Formula x48 = x51.forAll(x49); - Variable x59 = Variable.unary("checkOneSolvable3ToNinjaWheel_node"); - Decls x58 = x59.oneOf(x6); - Variable x62 = Variable.unary("checkOneSolvable3ToNinjaWheel_pathPref"); - Decls x61 = x62.oneOf(x6); - Expression x67 = x59.join(x10); - Expression x66 = x62.join(x67); - Expression x65 = x66.join(x6); - Expression x68 = x65.join(x12); - Expression x64 = x65.difference(x68); - Formula x63 = x64.in(x11); - Formula x60 = x63.forAll(x61); - Formula x57 = x60.forAll(x58); - Variable x71 = Variable.unary("checkOneSolvable3ToNinjaWheel_node"); - Decls x70 = x71.oneOf(x6); - Variable x74 = Variable.unary("checkOneSolvable3ToNinjaWheel_pathPref"); - Decls x73 = x74.oneOf(x6); - Variable x77 = Variable.unary("checkOneSolvable3ToNinjaWheel_pathIndex"); - Decls x76 = x77.oneOf(x6); - Expression x81 = x71.join(x10); - Expression x80 = x74.join(x81); - Expression x79 = x77.join(x80); - Formula x78 = x79.lone(); - Formula x75 = x78.forAll(x76); - Formula x72 = x75.forAll(x73); - Formula x69 = x72.forAll(x70); - Variable x84 = Variable.unary("checkOneSolvable3ToNinjaWheel_node"); - Decls x83 = x84.oneOf(x44); - Expression x86 = x84.join(x10); - Formula x85 = x86.some(); - Formula x82 = x85.forAll(x83); - Variable x89 = Variable.unary("checkOneSolvable3ToNinjaWheel_node"); - Decls x88 = x89.oneOf(x44); - Variable x92 = Variable.unary("checkOneSolvable3ToNinjaWheel_pathPref"); - Expression x95 = x89.join(x10); - Expression x94 = x95.join(x6); - Expression x93 = x94.join(x6); - Decls x91 = x92.oneOf(x93); - Expression x101 = x89.join(x10); - Expression x100 = x92.join(x101); - Expression x99 = x6.join(x100); - Formula x98 = x99.in(x44); - Expression x104 = x100.join(x6); - IntExpression x103 = x104.count(); - Expression x106 = x6.join(x100); - IntExpression x105 = x106.count(); - Formula x102 = x103.eq(x105); - Formula x97 = x98.and(x102); - Expression x108 = x8.join(x100); - Formula x107 = x108.eq(x89); - Formula x96 = x97.and(x107); - Formula x90 = x96.forAll(x91); - Formula x87 = x90.forAll(x88); - Variable x111 = Variable.unary("checkOneSolvable3ToNinjaWheel_node"); - Decls x110 = x111.oneOf(x44); - Variable x115 = Variable.unary("checkOneSolvable3ToNinjaWheel_i"); - Expression x118 = x111.join(x10); - Expression x117 = x118.join(x6); - Expression x116 = x117.join(x6); - Decls x114 = x115.oneOf(x116); - Variable x120 = Variable.unary("checkOneSolvable3ToNinjaWheel_j"); - Decls x119 = x120.oneOf(x116); - Decls x113 = x114.and(x119); - Expression x124 = x115.intersection(x120); - Formula x123 = x124.no(); - Expression x127 = x111.join(x10); - Expression x126 = x115.join(x127); - Expression x129 = x111.join(x10); - Expression x128 = x120.join(x129); - Formula x125 = x126.eq(x128); - Formula x122 = x123.and(x125); - Formula x121 = x122.not(); - Formula x112 = x121.forAll(x113); - Formula x109 = x112.forAll(x110); - Expression x134 = x6.join(x10); - Expression x133 = x134.join(x6); - Expression x132 = x133.join(x6); - IntExpression x131 = x132.count(); - IntExpression x135 = x6.count(); - Formula x130 = x131.lt(x135); - IntExpression x141 = x44.count(); - Expression x140 = x141.toExpression(); - IntExpression x143 = IntConstant.constant(3); - Expression x142 = x143.toExpression(); - Formula x139 = x140.eq(x142); - Formula x138 = x139.not(); - Variable x149 = Variable.unary("oneSolvableFun3_i1"); - Decls x148 = x149.oneOf(x6); - Variable x151 = Variable.unary("oneSolvableFun3_i2"); - Decls x150 = x151.oneOf(x6); - Variable x153 = Variable.unary("oneSolvableFun3_i3"); - Decls x152 = x153.oneOf(x6); - Decls x147 = x148.and(x150).and(x152); - Expression x160 = x8.join(x10); - Expression x159 = x160.join(x6); - Expression x158 = x159.join(x6); - Expression x165 = x8.join(x10); - Expression x164 = x165.join(x6); - Expression x163 = x164.join(x6); - Expression x168 = x12.transpose(); - Expression x167 = x168.closure(); - Expression x166 = x163.join(x167); - Expression x162 = x163.difference(x166); - Expression x161 = x162.join(x12); - Expression x157 = x158.union(x161); - Formula x156 = x149.in(x157); - Expression x174 = x9.join(x10); - Expression x173 = x174.join(x6); - Expression x172 = x173.join(x6); - Expression x179 = x9.join(x10); - Expression x178 = x179.join(x6); - Expression x177 = x178.join(x6); - Expression x182 = x12.transpose(); - Expression x181 = x182.closure(); - Expression x180 = x177.join(x181); - Expression x176 = x177.difference(x180); - Expression x175 = x176.join(x12); - Expression x171 = x172.union(x175); - Formula x170 = x151.in(x171); - Expression x186 = x8.product(x149); - Expression x187 = x9.product(x151); - Expression x185 = x186.union(x187); - Expression x189 = x9.join(x12); - Expression x188 = x189.product(x153); - Expression x184 = x185.union(x188); - Variable x193 = Variable.unary("ValidBest_node"); - Decls x192 = x193.oneOf(x6); - Variable x195 = Variable.unary("ValidBest_pref"); - Decls x194 = x195.oneOf(x6); - Decls x191 = x192.and(x194); - Variable x202 = Variable.unary("ValidChoices_n"); - Decls x201 = x202.oneOf(x6); - Variable x204 = Variable.unary("ValidChoices_p"); - Decls x203 = x204.oneOf(x6); - Decls x200 = x201.and(x203); - Expression x210 = x202.join(x10); - Expression x209 = x210.join(x6); - Expression x208 = x209.join(x6); - Expression x215 = x202.join(x10); - Expression x214 = x215.join(x6); - Expression x213 = x214.join(x6); - Expression x218 = x12.transpose(); - Expression x217 = x218.closure(); - Expression x216 = x213.join(x217); - Expression x212 = x213.difference(x216); - Expression x211 = x212.join(x12); - Expression x207 = x208.union(x211); - Formula x206 = x204.in(x207); - Expression x224 = x202.join(x10); - Expression x223 = x224.join(x6); - Expression x222 = x223.join(x6); - Formula x221 = x204.in(x222); - Formula x220 = x221.not(); - Expression x230 = x202.join(x10); - Expression x229 = x204.join(x230); - Expression x228 = x9.join(x229); - Formula x227 = x228.some(); - Formula x226 = x227.not(); - Expression x237 = x202.join(x10); - Expression x236 = x237.join(x6); - Expression x235 = x236.join(x6); - Formula x234 = x204.in(x235); - Formula x233 = x234.not(); - Formula x232 = x233.not(); - Expression x241 = x202.join(x10); - Expression x240 = x204.join(x241); - Expression x239 = x12.join(x240); - Expression x243 = x228.join(x184); - Expression x244 = x228.join(x10); - Expression x242 = x243.join(x244); - Formula x238 = x239.eq(x242); - Formula x231 = x232.and(x238); - Formula x225 = x226.or(x231); - Formula x219 = x220.or(x225); - Formula x205 = x206.and(x219); - Expression x199 = x205.comprehension(x200); - Expression x198 = x193.join(x199); - Formula x197 = x195.in(x198); - Variable x247 = Variable.unary("ValidBest_j"); - Expression x248 = x193.join(x199); - Decls x246 = x247.oneOf(x248); - Expression x253 = x12.transpose(); - Expression x252 = x253.closure(); - Expression x251 = x195.join(x252); - Formula x250 = x247.in(x251); - Formula x249 = x250.not(); - Formula x245 = x249.forAll(x246); - Formula x196 = x197.and(x245); - Expression x190 = x196.comprehension(x191); - Formula x183 = x184.eq(x190); - Formula x169 = x170.and(x183); - Formula x155 = x156.and(x169); - Expression x258 = x189.join(x10); - Expression x257 = x258.join(x6); - Expression x256 = x257.join(x6); - Expression x263 = x189.join(x10); - Expression x262 = x263.join(x6); - Expression x261 = x262.join(x6); - Expression x266 = x12.transpose(); - Expression x265 = x266.closure(); - Expression x264 = x261.join(x265); - Expression x260 = x261.difference(x264); - Expression x259 = x260.join(x12); - Expression x255 = x256.union(x259); - Formula x254 = x153.in(x255); - Formula x154 = x155.and(x254); - Expression x146 = x154.comprehension(x147); - Formula x145 = x146.one(); - Variable x272 = Variable.unary("DW3NE_p1"); - Expression x276 = x8.join(x10); - Expression x275 = x276.join(x6); - Expression x274 = x275.join(x6); - Expression x281 = x8.join(x10); - Expression x280 = x281.join(x6); - Expression x279 = x280.join(x6); - Expression x284 = x12.transpose(); - Expression x283 = x284.closure(); - Expression x282 = x279.join(x283); - Expression x278 = x279.difference(x282); - Expression x277 = x278.join(x12); - Expression x273 = x274.union(x277); - Decls x271 = x272.oneOf(x273); - Variable x286 = Variable.unary("DW3NE_p2"); - Expression x290 = x9.join(x10); - Expression x289 = x290.join(x6); - Expression x288 = x289.join(x6); - Expression x295 = x9.join(x10); - Expression x294 = x295.join(x6); - Expression x293 = x294.join(x6); - Expression x298 = x12.transpose(); - Expression x297 = x298.closure(); - Expression x296 = x293.join(x297); - Expression x292 = x293.difference(x296); - Expression x291 = x292.join(x12); - Expression x287 = x288.union(x291); - Decls x285 = x286.oneOf(x287); - Variable x300 = Variable.unary("DW3NE_p3"); - Expression x305 = x9.join(x12); - Expression x304 = x305.join(x10); - Expression x303 = x304.join(x6); - Expression x302 = x303.join(x6); - Expression x310 = x305.join(x10); - Expression x309 = x310.join(x6); - Expression x308 = x309.join(x6); - Expression x313 = x12.transpose(); - Expression x312 = x313.closure(); - Expression x311 = x308.join(x312); - Expression x307 = x308.difference(x311); - Expression x306 = x307.join(x12); - Expression x301 = x302.union(x306); - Decls x299 = x300.oneOf(x301); - Decls x270 = x271.and(x285).and(x299); - Variable x316 = Variable.unary("DW3NE_p1h"); - Variable x319 = Variable.unary("DW3NE_i"); - Decls x318 = x319.oneOf(x6); - Expression x323 = x12.transpose(); - Expression x322 = x323.closure(); - Expression x321 = x272.join(x322); - Formula x320 = x319.in(x321); - Expression x317 = x320.comprehension(x318); - Decls x315 = x316.oneOf(x317); - Variable x326 = Variable.unary("DW3NE_p2h"); - Variable x329 = Variable.unary("DW3NE_i"); - Decls x328 = x329.oneOf(x6); - Expression x333 = x12.transpose(); - Expression x332 = x333.closure(); - Expression x331 = x286.join(x332); - Formula x330 = x329.in(x331); - Expression x327 = x330.comprehension(x328); - Decls x325 = x326.oneOf(x327); - Variable x336 = Variable.unary("DW3NE_p3h"); - Variable x339 = Variable.unary("DW3NE_i"); - Decls x338 = x339.oneOf(x6); - Expression x343 = x12.transpose(); - Expression x342 = x343.closure(); - Expression x341 = x300.join(x342); - Formula x340 = x339.in(x341); - Expression x337 = x340.comprehension(x338); - Decls x335 = x336.oneOf(x337); - Variable x347 = Variable.unary("DW3NE_pa2h"); - Expression x349 = x9.union(x8); - Expression x350 = x9.join(x12); - Expression x348 = x349.union(x350); - Decls x346 = x347.oneOf(x348); - Variable x352 = Variable.unary("DW3NE_pa3h"); - Decls x351 = x352.oneOf(x348); - Decls x345 = x346.and(x351); - Variable x355 = Variable.unary("DW3NE_pa2l"); - Expression x358 = x9.union(x8); - Expression x359 = x9.join(x12); - Expression x357 = x358.union(x359); - Expression x356 = x357.difference(x347); - Decls x354 = x355.oneOf(x356); - Variable x362 = Variable.unary("DW3NE_pa3l"); - Expression x365 = x9.union(x8); - Expression x366 = x9.join(x12); - Expression x364 = x365.union(x366); - Expression x363 = x364.difference(x352); - Decls x361 = x362.oneOf(x363); - Variable x373 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x379 = x8.join(x10); - Expression x378 = x316.join(x379); - Expression x377 = x9.join(x378); - Expression x376 = x377.join(x10); - Expression x375 = x376.join(x6); - Expression x374 = x375.join(x6); - Decls x372 = x373.oneOf(x374); - Expression x384 = x8.join(x10); - Expression x383 = x316.join(x384); - Expression x382 = x12.join(x383); - Expression x386 = x377.join(x10); - Expression x385 = x373.join(x386); - Formula x381 = x382.eq(x385); - Expression x396 = x272.product(x9); - Expression x395 = x8.product(x396); - Expression x398 = x316.product(x8); - Expression x397 = x8.product(x398); - Expression x394 = x395.union(x397); - Expression x400 = x286.product(x355); - Expression x399 = x9.product(x400); - Expression x393 = x394.union(x399); - Expression x402 = x326.product(x347); - Expression x401 = x9.product(x402); - Expression x392 = x393.union(x401); - Expression x404 = x300.product(x362); - Expression x403 = x305.product(x404); - Expression x391 = x392.union(x403); - Expression x406 = x336.product(x352); - Expression x405 = x305.product(x406); - Expression x390 = x391.union(x405); - Expression x389 = x8.join(x390); - Expression x388 = x316.join(x389); - Expression x408 = x377.join(x390); - Expression x407 = x373.join(x408); - Formula x387 = x388.eq(x407); - Formula x380 = x381.and(x387); - Formula x371 = x380.forSome(x372); - Expression x415 = x8.join(x10); - Expression x414 = x415.join(x6); - Expression x413 = x414.join(x6); - Formula x412 = x272.in(x413); - Formula x411 = x412.not(); - Expression x419 = x8.join(x10); - Expression x418 = x272.join(x419); - Expression x417 = x9.join(x418); - Formula x416 = x417.no(); - Formula x410 = x411.or(x416); - Variable x422 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x428 = x8.join(x10); - Expression x427 = x272.join(x428); - Expression x426 = x9.join(x427); - Expression x425 = x426.join(x10); - Expression x424 = x425.join(x6); - Expression x423 = x424.join(x6); - Decls x421 = x422.oneOf(x423); - Expression x433 = x8.join(x10); - Expression x432 = x272.join(x433); - Expression x431 = x12.join(x432); - Expression x435 = x426.join(x10); - Expression x434 = x422.join(x435); - Formula x430 = x431.eq(x434); - Expression x438 = x8.join(x390); - Expression x437 = x272.join(x438); - Expression x440 = x426.join(x390); - Expression x439 = x422.join(x440); - Formula x436 = x437.eq(x439); - Formula x429 = x430.and(x436); - Formula x420 = x429.forSome(x421); - Formula x409 = x410.or(x420); - Formula x370 = x371.and(x409); - Variable x443 = Variable.unary("DWNodeCheckNE_k"); - Variable x446 = Variable.unary("DWNodeCheckNE_i"); - Decls x445 = x446.oneOf(x6); - Expression x451 = x12.transpose(); - Expression x450 = x451.closure(); - Expression x449 = x272.join(x450); - Formula x448 = x446.in(x449); - Formula x453 = x446.eq(x316); - Formula x452 = x453.not(); - Formula x447 = x448.and(x452); - Expression x444 = x447.comprehension(x445); - Decls x442 = x443.oneOf(x444); - Expression x459 = x8.join(x10); - Expression x458 = x443.join(x459); - Expression x457 = x9.join(x458); - Formula x456 = x457.no(); - Formula x455 = x456.not(); - Variable x462 = Variable.unary("DWNodeCheckNE_first_hop_k_pref"); - Expression x466 = x8.join(x10); - Expression x465 = x443.join(x466); - Expression x464 = x9.join(x465); - Expression x472 = x8.product(x272); - Expression x473 = x8.product(x316); - Expression x471 = x472.union(x473); - Expression x474 = x9.product(x286); - Expression x470 = x471.union(x474); - Expression x475 = x9.product(x326); - Expression x469 = x470.union(x475); - Expression x476 = x305.product(x300); - Expression x468 = x469.union(x476); - Expression x477 = x305.product(x336); - Expression x467 = x468.union(x477); - Expression x463 = x464.join(x467); - Decls x461 = x462.oneOf(x463); - Expression x486 = x8.join(x10); - Expression x485 = x486.join(x6); - Expression x484 = x485.join(x6); - Formula x483 = x443.in(x484); - Formula x482 = x483.not(); - Formula x481 = x482.not(); - Expression x490 = x8.join(x10); - Expression x489 = x443.join(x490); - Expression x488 = x12.join(x489); - Expression x492 = x464.join(x10); - Expression x491 = x462.join(x492); - Formula x487 = x488.eq(x491); - Formula x480 = x481.and(x487); - Formula x479 = x480.not(); - Expression x496 = x464.join(x390); - Expression x495 = x462.join(x496); - Expression x498 = x8.join(x390); - Expression x497 = x316.join(x498); - Formula x494 = x495.eq(x497); - Expression x501 = x12.closure(); - Expression x500 = x316.join(x501); - Formula x499 = x443.in(x500); - Formula x493 = x494.and(x499); - Formula x478 = x479.or(x493); - Formula x460 = x478.forAll(x461); - Formula x454 = x455.and(x460); - Formula x441 = x454.forAll(x442); - Formula x369 = x370.and(x441); - Variable x506 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x512 = x9.join(x10); - Expression x511 = x326.join(x512); - Expression x510 = x9.join(x511); - Expression x509 = x510.join(x10); - Expression x508 = x509.join(x6); - Expression x507 = x508.join(x6); - Decls x505 = x506.oneOf(x507); - Expression x517 = x9.join(x10); - Expression x516 = x326.join(x517); - Expression x515 = x12.join(x516); - Expression x519 = x510.join(x10); - Expression x518 = x506.join(x519); - Formula x514 = x515.eq(x518); - Expression x522 = x9.join(x390); - Expression x521 = x326.join(x522); - Expression x524 = x510.join(x390); - Expression x523 = x506.join(x524); - Formula x520 = x521.eq(x523); - Formula x513 = x514.and(x520); - Formula x504 = x513.forSome(x505); - Expression x531 = x9.join(x10); - Expression x530 = x531.join(x6); - Expression x529 = x530.join(x6); - Formula x528 = x286.in(x529); - Formula x527 = x528.not(); - Expression x535 = x9.join(x10); - Expression x534 = x286.join(x535); - Expression x533 = x9.join(x534); - Formula x532 = x533.no(); - Formula x526 = x527.or(x532); - Variable x538 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x544 = x9.join(x10); - Expression x543 = x286.join(x544); - Expression x542 = x9.join(x543); - Expression x541 = x542.join(x10); - Expression x540 = x541.join(x6); - Expression x539 = x540.join(x6); - Decls x537 = x538.oneOf(x539); - Expression x549 = x9.join(x10); - Expression x548 = x286.join(x549); - Expression x547 = x12.join(x548); - Expression x551 = x542.join(x10); - Expression x550 = x538.join(x551); - Formula x546 = x547.eq(x550); - Expression x554 = x9.join(x390); - Expression x553 = x286.join(x554); - Expression x556 = x542.join(x390); - Expression x555 = x538.join(x556); - Formula x552 = x553.eq(x555); - Formula x545 = x546.and(x552); - Formula x536 = x545.forSome(x537); - Formula x525 = x526.or(x536); - Formula x503 = x504.and(x525); - Variable x559 = Variable.unary("DWNodeCheckNE_k"); - Variable x562 = Variable.unary("DWNodeCheckNE_i"); - Decls x561 = x562.oneOf(x6); - Expression x567 = x12.transpose(); - Expression x566 = x567.closure(); - Expression x565 = x286.join(x566); - Formula x564 = x562.in(x565); - Formula x569 = x562.eq(x326); - Formula x568 = x569.not(); - Formula x563 = x564.and(x568); - Expression x560 = x563.comprehension(x561); - Decls x558 = x559.oneOf(x560); - Expression x575 = x9.join(x10); - Expression x574 = x559.join(x575); - Expression x573 = x9.join(x574); - Formula x572 = x573.no(); - Formula x571 = x572.not(); - Variable x578 = Variable.unary("DWNodeCheckNE_first_hop_k_pref"); - Expression x582 = x9.join(x10); - Expression x581 = x559.join(x582); - Expression x580 = x9.join(x581); - Expression x579 = x580.join(x467); - Decls x577 = x578.oneOf(x579); - Expression x591 = x9.join(x10); - Expression x590 = x591.join(x6); - Expression x589 = x590.join(x6); - Formula x588 = x559.in(x589); - Formula x587 = x588.not(); - Formula x586 = x587.not(); - Expression x595 = x9.join(x10); - Expression x594 = x559.join(x595); - Expression x593 = x12.join(x594); - Expression x597 = x580.join(x10); - Expression x596 = x578.join(x597); - Formula x592 = x593.eq(x596); - Formula x585 = x586.and(x592); - Formula x584 = x585.not(); - Expression x601 = x580.join(x390); - Expression x600 = x578.join(x601); - Expression x603 = x9.join(x390); - Expression x602 = x326.join(x603); - Formula x599 = x600.eq(x602); - Expression x606 = x12.closure(); - Expression x605 = x326.join(x606); - Formula x604 = x559.in(x605); - Formula x598 = x599.and(x604); - Formula x583 = x584.or(x598); - Formula x576 = x583.forAll(x577); - Formula x570 = x571.and(x576); - Formula x557 = x570.forAll(x558); - Formula x502 = x503.and(x557); - Formula x368 = x369.and(x502); - Variable x611 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x617 = x305.join(x10); - Expression x616 = x336.join(x617); - Expression x615 = x9.join(x616); - Expression x614 = x615.join(x10); - Expression x613 = x614.join(x6); - Expression x612 = x613.join(x6); - Decls x610 = x611.oneOf(x612); - Expression x622 = x305.join(x10); - Expression x621 = x336.join(x622); - Expression x620 = x12.join(x621); - Expression x624 = x615.join(x10); - Expression x623 = x611.join(x624); - Formula x619 = x620.eq(x623); - Expression x627 = x305.join(x390); - Expression x626 = x336.join(x627); - Expression x629 = x615.join(x390); - Expression x628 = x611.join(x629); - Formula x625 = x626.eq(x628); - Formula x618 = x619.and(x625); - Formula x609 = x618.forSome(x610); - Expression x636 = x305.join(x10); - Expression x635 = x636.join(x6); - Expression x634 = x635.join(x6); - Formula x633 = x300.in(x634); - Formula x632 = x633.not(); - Expression x640 = x305.join(x10); - Expression x639 = x300.join(x640); - Expression x638 = x9.join(x639); - Formula x637 = x638.no(); - Formula x631 = x632.or(x637); - Variable x643 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x649 = x305.join(x10); - Expression x648 = x300.join(x649); - Expression x647 = x9.join(x648); - Expression x646 = x647.join(x10); - Expression x645 = x646.join(x6); - Expression x644 = x645.join(x6); - Decls x642 = x643.oneOf(x644); - Expression x654 = x305.join(x10); - Expression x653 = x300.join(x654); - Expression x652 = x12.join(x653); - Expression x656 = x647.join(x10); - Expression x655 = x643.join(x656); - Formula x651 = x652.eq(x655); - Expression x659 = x305.join(x390); - Expression x658 = x300.join(x659); - Expression x661 = x647.join(x390); - Expression x660 = x643.join(x661); - Formula x657 = x658.eq(x660); - Formula x650 = x651.and(x657); - Formula x641 = x650.forSome(x642); - Formula x630 = x631.or(x641); - Formula x608 = x609.and(x630); - Variable x664 = Variable.unary("DWNodeCheckNE_k"); - Variable x667 = Variable.unary("DWNodeCheckNE_i"); - Decls x666 = x667.oneOf(x6); - Expression x672 = x12.transpose(); - Expression x671 = x672.closure(); - Expression x670 = x300.join(x671); - Formula x669 = x667.in(x670); - Formula x674 = x667.eq(x336); - Formula x673 = x674.not(); - Formula x668 = x669.and(x673); - Expression x665 = x668.comprehension(x666); - Decls x663 = x664.oneOf(x665); - Expression x680 = x305.join(x10); - Expression x679 = x664.join(x680); - Expression x678 = x9.join(x679); - Formula x677 = x678.no(); - Formula x676 = x677.not(); - Variable x683 = Variable.unary("DWNodeCheckNE_first_hop_k_pref"); - Expression x687 = x305.join(x10); - Expression x686 = x664.join(x687); - Expression x685 = x9.join(x686); - Expression x684 = x685.join(x467); - Decls x682 = x683.oneOf(x684); - Expression x696 = x305.join(x10); - Expression x695 = x696.join(x6); - Expression x694 = x695.join(x6); - Formula x693 = x664.in(x694); - Formula x692 = x693.not(); - Formula x691 = x692.not(); - Expression x700 = x305.join(x10); - Expression x699 = x664.join(x700); - Expression x698 = x12.join(x699); - Expression x702 = x685.join(x10); - Expression x701 = x683.join(x702); - Formula x697 = x698.eq(x701); - Formula x690 = x691.and(x697); - Formula x689 = x690.not(); - Expression x706 = x685.join(x390); - Expression x705 = x683.join(x706); - Expression x708 = x305.join(x390); - Expression x707 = x336.join(x708); - Formula x704 = x705.eq(x707); - Expression x711 = x12.closure(); - Expression x710 = x336.join(x711); - Formula x709 = x664.in(x710); - Formula x703 = x704.and(x709); - Formula x688 = x689.or(x703); - Formula x681 = x688.forAll(x682); - Formula x675 = x676.and(x681); - Formula x662 = x675.forAll(x663); - Formula x607 = x608.and(x662); - Formula x367 = x368.and(x607); - Formula x360 = x367.forSome(x361); - Formula x353 = x360.forSome(x354); - Formula x344 = x353.forSome(x345); - Formula x334 = x344.forSome(x335); - Formula x324 = x334.forSome(x325); - Formula x314 = x324.forSome(x315); - Formula x269 = x314.forSome(x270); - Variable x714 = Variable.unary("checkOneSolvable3ToNinjaWheel_n1"); - Expression x716 = x8.union(x9); - Expression x717 = x9.join(x12); - Expression x715 = x716.union(x717); - Decls x713 = x714.oneOf(x715); - Variable x720 = Variable.unary("checkOneSolvable3ToNinjaWheel_n2"); - Expression x723 = x8.union(x9); - Expression x724 = x9.join(x12); - Expression x722 = x723.union(x724); - Expression x721 = x722.difference(x714); - Decls x719 = x720.oneOf(x721); - Variable x727 = Variable.unary("checkOneSolvable3ToNinjaWheel_n3"); - Expression x730 = x8.union(x9); - Expression x731 = x9.join(x12); - Expression x729 = x730.union(x731); - Expression x732 = x714.union(x720); - Expression x728 = x729.difference(x732); - Decls x726 = x727.oneOf(x728); - Variable x735 = Variable.unary("DW2E1_p1"); - Expression x739 = x714.join(x10); - Expression x738 = x739.join(x6); - Expression x737 = x738.join(x6); - Expression x744 = x714.join(x10); - Expression x743 = x744.join(x6); - Expression x742 = x743.join(x6); - Expression x747 = x12.transpose(); - Expression x746 = x747.closure(); - Expression x745 = x742.join(x746); - Expression x741 = x742.difference(x745); - Expression x740 = x741.join(x12); - Expression x736 = x737.union(x740); - Decls x734 = x735.oneOf(x736); - Variable x750 = Variable.unary("DW2E1_p1h"); - Variable x753 = Variable.unary("DW2E1_i"); - Decls x752 = x753.oneOf(x6); - Expression x757 = x12.transpose(); - Expression x756 = x757.closure(); - Expression x755 = x735.join(x756); - Formula x754 = x753.in(x755); - Expression x751 = x754.comprehension(x752); - Decls x749 = x750.oneOf(x751); - Variable x760 = Variable.unary("DW2E1_p2"); - Expression x764 = x720.join(x10); - Expression x763 = x764.join(x6); - Expression x762 = x763.join(x6); - Expression x769 = x720.join(x10); - Expression x768 = x769.join(x6); - Expression x767 = x768.join(x6); - Expression x772 = x12.transpose(); - Expression x771 = x772.closure(); - Expression x770 = x767.join(x771); - Expression x766 = x767.difference(x770); - Expression x765 = x766.join(x12); - Expression x761 = x762.union(x765); - Decls x759 = x760.oneOf(x761); - Variable x775 = Variable.unary("DW2E1_p2h"); - Variable x778 = Variable.unary("DW2E1_i"); - Decls x777 = x778.oneOf(x6); - Expression x782 = x12.transpose(); - Expression x781 = x782.closure(); - Expression x780 = x760.join(x781); - Formula x779 = x778.in(x780); - Expression x776 = x779.comprehension(x777); - Decls x774 = x775.oneOf(x776); - Variable x785 = Variable.unary("DW2E1_p3"); - Expression x789 = x727.join(x10); - Expression x788 = x789.join(x6); - Expression x787 = x788.join(x6); - Expression x794 = x727.join(x10); - Expression x793 = x794.join(x6); - Expression x792 = x793.join(x6); - Expression x797 = x12.transpose(); - Expression x796 = x797.closure(); - Expression x795 = x792.join(x796); - Expression x791 = x792.difference(x795); - Expression x790 = x791.join(x12); - Expression x786 = x787.union(x790); - Decls x784 = x785.oneOf(x786); - Variable x800 = Variable.unary("DW2E1_pa2h"); - Expression x802 = x9.union(x8); - Expression x803 = x9.join(x12); - Expression x801 = x802.union(x803); - Decls x799 = x800.oneOf(x801); - Variable x806 = Variable.unary("DW2E1_pa2l"); - Expression x809 = x9.union(x8); - Expression x810 = x9.join(x12); - Expression x808 = x809.union(x810); - Expression x807 = x808.difference(x800); - Decls x805 = x806.oneOf(x807); - Expression x814 = x727.product(x785); - Variable x818 = Variable.unary("ValidBest_node"); - Decls x817 = x818.oneOf(x6); - Variable x820 = Variable.unary("ValidBest_pref"); - Decls x819 = x820.oneOf(x6); - Decls x816 = x817.and(x819); - Variable x827 = Variable.unary("ValidChoices2_n"); - Decls x826 = x827.oneOf(x6); - Variable x829 = Variable.unary("ValidChoices2_p"); - Decls x828 = x829.oneOf(x6); - Decls x825 = x826.and(x828); - Expression x835 = x827.join(x10); - Expression x834 = x835.join(x6); - Expression x833 = x834.join(x6); - Expression x840 = x827.join(x10); - Expression x839 = x840.join(x6); - Expression x838 = x839.join(x6); - Expression x843 = x12.transpose(); - Expression x842 = x843.closure(); - Expression x841 = x838.join(x842); - Expression x837 = x838.difference(x841); - Expression x836 = x837.join(x12); - Expression x832 = x833.union(x836); - Formula x831 = x829.in(x832); - Expression x849 = x827.join(x10); - Expression x848 = x849.join(x6); - Expression x847 = x848.join(x6); - Formula x846 = x829.in(x847); - Formula x845 = x846.not(); - Expression x855 = x827.join(x10); - Expression x854 = x829.join(x855); - Expression x853 = x9.join(x854); - Formula x852 = x853.some(); - Formula x851 = x852.not(); - Variable x858 = Variable.unary("ValidPathChoice2_p"); - Expression x863 = x714.product(x735); - Expression x864 = x720.product(x760); - Expression x862 = x863.union(x864); - Expression x866 = x714.product(x750); - Expression x867 = x720.product(x775); - Expression x865 = x866.union(x867); - Expression x861 = x862.union(x865); - Expression x860 = x814.union(x861); - Expression x859 = x853.join(x860); - Decls x857 = x858.oneOf(x859); - Expression x874 = x827.join(x10); - Expression x873 = x874.join(x6); - Expression x872 = x873.join(x6); - Formula x871 = x829.in(x872); - Formula x870 = x871.not(); - Formula x869 = x870.not(); - Expression x878 = x827.join(x10); - Expression x877 = x829.join(x878); - Expression x876 = x12.join(x877); - Expression x880 = x853.join(x10); - Expression x879 = x858.join(x880); - Formula x875 = x876.eq(x879); - Formula x868 = x869.and(x875); - Formula x856 = x868.forSome(x857); - Formula x850 = x851.or(x856); - Formula x844 = x845.or(x850); - Formula x830 = x831.and(x844); - Expression x824 = x830.comprehension(x825); - Expression x823 = x818.join(x824); - Formula x822 = x820.in(x823); - Variable x883 = Variable.unary("ValidBest_j"); - Expression x884 = x818.join(x824); - Decls x882 = x883.oneOf(x884); - Expression x889 = x12.transpose(); - Expression x888 = x889.closure(); - Expression x887 = x820.join(x888); - Formula x886 = x883.in(x887); - Formula x885 = x886.not(); - Formula x881 = x885.forAll(x882); - Formula x821 = x822.and(x881); - Expression x815 = x821.comprehension(x816); - Formula x813 = x814.in(x815); - Variable x893 = Variable.unary("DW2E_n"); - Decls x892 = x893.oneOf(x727); - Expression x898 = x893.join(x814); - Expression x899 = x893.join(x10); - Expression x897 = x898.join(x899); - Expression x896 = x6.join(x897); - Expression x900 = x44.difference(x727); - Expression x895 = x896.intersection(x900); - Formula x894 = x895.no(); - Formula x891 = x894.forAll(x892); - Variable x905 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x911 = x720.join(x10); - Expression x910 = x775.join(x911); - Expression x909 = x9.join(x910); - Expression x908 = x909.join(x10); - Expression x907 = x908.join(x6); - Expression x906 = x907.join(x6); - Decls x904 = x905.oneOf(x906); - Expression x916 = x720.join(x10); - Expression x915 = x775.join(x916); - Expression x914 = x12.join(x915); - Expression x918 = x909.join(x10); - Expression x917 = x905.join(x918); - Formula x913 = x914.eq(x917); - Expression x925 = x735.product(x9); - Expression x924 = x714.product(x925); - Expression x927 = x760.product(x806); - Expression x926 = x720.product(x927); - Expression x923 = x924.union(x926); - Expression x930 = x750.product(x8); - Expression x929 = x714.product(x930); - Expression x932 = x775.product(x800); - Expression x931 = x720.product(x932); - Expression x928 = x929.union(x931); - Expression x922 = x923.union(x928); - Expression x921 = x720.join(x922); - Expression x920 = x775.join(x921); - Expression x934 = x909.join(x922); - Expression x933 = x905.join(x934); - Formula x919 = x920.eq(x933); - Formula x912 = x913.and(x919); - Formula x903 = x912.forSome(x904); - Expression x941 = x720.join(x10); - Expression x940 = x941.join(x6); - Expression x939 = x940.join(x6); - Formula x938 = x760.in(x939); - Formula x937 = x938.not(); - Expression x946 = x720.join(x10); - Expression x945 = x760.join(x946); - Expression x944 = x9.join(x945); - Formula x943 = x944.no(); - Variable x949 = Variable.unary("isLeg_pref2"); - Expression x950 = x944.join(x814); - Decls x948 = x949.oneOf(x950); - Expression x957 = x720.join(x10); - Expression x956 = x957.join(x6); - Expression x955 = x956.join(x6); - Formula x954 = x760.in(x955); - Formula x953 = x954.not(); - Formula x952 = x953.not(); - Expression x961 = x720.join(x10); - Expression x960 = x760.join(x961); - Expression x959 = x12.join(x960); - Expression x963 = x944.join(x10); - Expression x962 = x949.join(x963); - Formula x958 = x959.eq(x962); - Formula x951 = x952.and(x958); - Formula x947 = x951.forSome(x948); - Formula x942 = x943.or(x947); - Formula x936 = x937.or(x942); - Variable x966 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x972 = x720.join(x10); - Expression x971 = x760.join(x972); - Expression x970 = x9.join(x971); - Expression x969 = x970.join(x10); - Expression x968 = x969.join(x6); - Expression x967 = x968.join(x6); - Decls x965 = x966.oneOf(x967); - Expression x977 = x720.join(x10); - Expression x976 = x760.join(x977); - Expression x975 = x12.join(x976); - Expression x979 = x970.join(x10); - Expression x978 = x966.join(x979); - Formula x974 = x975.eq(x978); - Expression x982 = x720.join(x922); - Expression x981 = x760.join(x982); - Expression x984 = x970.join(x922); - Expression x983 = x966.join(x984); - Formula x980 = x981.eq(x983); - Formula x973 = x974.and(x980); - Formula x964 = x973.forSome(x965); - Formula x935 = x936.or(x964); - Formula x902 = x903.and(x935); - Variable x987 = Variable.unary("DWNodeCheck_k"); - Variable x990 = Variable.unary("DWNodeCheck_i"); - Decls x989 = x990.oneOf(x6); - Expression x995 = x12.transpose(); - Expression x994 = x995.closure(); - Expression x993 = x760.join(x994); - Formula x992 = x990.in(x993); - Formula x997 = x990.eq(x775); - Formula x996 = x997.not(); - Formula x991 = x992.and(x996); - Expression x988 = x991.comprehension(x989); - Decls x986 = x987.oneOf(x988); - Expression x1004 = x720.join(x10); - Expression x1003 = x987.join(x1004); - Expression x1002 = x9.join(x1003); - Formula x1001 = x1002.no(); - Variable x1007 = Variable.unary("isLeg_pref2"); - Expression x1008 = x1002.join(x814); - Decls x1006 = x1007.oneOf(x1008); - Expression x1015 = x720.join(x10); - Expression x1014 = x1015.join(x6); - Expression x1013 = x1014.join(x6); - Formula x1012 = x987.in(x1013); - Formula x1011 = x1012.not(); - Formula x1010 = x1011.not(); - Expression x1019 = x720.join(x10); - Expression x1018 = x987.join(x1019); - Expression x1017 = x12.join(x1018); - Expression x1021 = x1002.join(x10); - Expression x1020 = x1007.join(x1021); - Formula x1016 = x1017.eq(x1020); - Formula x1009 = x1010.and(x1016); - Formula x1005 = x1009.forSome(x1006); - Formula x1000 = x1001.or(x1005); - Formula x999 = x1000.not(); - Variable x1024 = Variable.unary("DWNodeCheck_first_hop_k_pref"); - Expression x1028 = x720.join(x10); - Expression x1027 = x987.join(x1028); - Expression x1026 = x9.join(x1027); - Expression x1025 = x1026.join(x861); - Decls x1023 = x1024.oneOf(x1025); - Expression x1037 = x720.join(x10); - Expression x1036 = x1037.join(x6); - Expression x1035 = x1036.join(x6); - Formula x1034 = x987.in(x1035); - Formula x1033 = x1034.not(); - Formula x1032 = x1033.not(); - Expression x1041 = x720.join(x10); - Expression x1040 = x987.join(x1041); - Expression x1039 = x12.join(x1040); - Expression x1043 = x1026.join(x10); - Expression x1042 = x1024.join(x1043); - Formula x1038 = x1039.eq(x1042); - Formula x1031 = x1032.and(x1038); - Formula x1030 = x1031.not(); - Expression x1047 = x1026.join(x922); - Expression x1046 = x1024.join(x1047); - Expression x1049 = x720.join(x922); - Expression x1048 = x775.join(x1049); - Formula x1045 = x1046.eq(x1048); - Expression x1052 = x12.closure(); - Expression x1051 = x775.join(x1052); - Formula x1050 = x987.in(x1051); - Formula x1044 = x1045.and(x1050); - Formula x1029 = x1030.or(x1044); - Formula x1022 = x1029.forAll(x1023); - Formula x998 = x999.and(x1022); - Formula x985 = x998.forAll(x986); - Formula x901 = x902.and(x985); - Formula x890 = x891.and(x901); - Formula x812 = x813.and(x890); - Variable x1057 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x1063 = x714.join(x10); - Expression x1062 = x750.join(x1063); - Expression x1061 = x9.join(x1062); - Expression x1060 = x1061.join(x10); - Expression x1059 = x1060.join(x6); - Expression x1058 = x1059.join(x6); - Decls x1056 = x1057.oneOf(x1058); - Expression x1068 = x714.join(x10); - Expression x1067 = x750.join(x1068); - Expression x1066 = x12.join(x1067); - Expression x1070 = x1061.join(x10); - Expression x1069 = x1057.join(x1070); - Formula x1065 = x1066.eq(x1069); - Expression x1073 = x714.join(x922); - Expression x1072 = x750.join(x1073); - Expression x1075 = x1061.join(x922); - Expression x1074 = x1057.join(x1075); - Formula x1071 = x1072.eq(x1074); - Formula x1064 = x1065.and(x1071); - Formula x1055 = x1064.forSome(x1056); - Expression x1082 = x714.join(x10); - Expression x1081 = x1082.join(x6); - Expression x1080 = x1081.join(x6); - Formula x1079 = x735.in(x1080); - Formula x1078 = x1079.not(); - Expression x1087 = x714.join(x10); - Expression x1086 = x735.join(x1087); - Expression x1085 = x9.join(x1086); - Formula x1084 = x1085.no(); - Variable x1090 = Variable.unary("isLeg_pref2"); - Expression x1091 = x1085.join(x814); - Decls x1089 = x1090.oneOf(x1091); - Expression x1098 = x714.join(x10); - Expression x1097 = x1098.join(x6); - Expression x1096 = x1097.join(x6); - Formula x1095 = x735.in(x1096); - Formula x1094 = x1095.not(); - Formula x1093 = x1094.not(); - Expression x1102 = x714.join(x10); - Expression x1101 = x735.join(x1102); - Expression x1100 = x12.join(x1101); - Expression x1104 = x1085.join(x10); - Expression x1103 = x1090.join(x1104); - Formula x1099 = x1100.eq(x1103); - Formula x1092 = x1093.and(x1099); - Formula x1088 = x1092.forSome(x1089); - Formula x1083 = x1084.or(x1088); - Formula x1077 = x1078.or(x1083); - Variable x1107 = Variable.unary("goesThruItsOwnParity_pref2"); - Expression x1113 = x714.join(x10); - Expression x1112 = x735.join(x1113); - Expression x1111 = x9.join(x1112); - Expression x1110 = x1111.join(x10); - Expression x1109 = x1110.join(x6); - Expression x1108 = x1109.join(x6); - Decls x1106 = x1107.oneOf(x1108); - Expression x1118 = x714.join(x10); - Expression x1117 = x735.join(x1118); - Expression x1116 = x12.join(x1117); - Expression x1120 = x1111.join(x10); - Expression x1119 = x1107.join(x1120); - Formula x1115 = x1116.eq(x1119); - Expression x1123 = x714.join(x922); - Expression x1122 = x735.join(x1123); - Expression x1125 = x1111.join(x922); - Expression x1124 = x1107.join(x1125); - Formula x1121 = x1122.eq(x1124); - Formula x1114 = x1115.and(x1121); - Formula x1105 = x1114.forSome(x1106); - Formula x1076 = x1077.or(x1105); - Formula x1054 = x1055.and(x1076); - Variable x1128 = Variable.unary("DWNodeCheck_k"); - Variable x1131 = Variable.unary("DWNodeCheck_i"); - Decls x1130 = x1131.oneOf(x6); - Expression x1136 = x12.transpose(); - Expression x1135 = x1136.closure(); - Expression x1134 = x735.join(x1135); - Formula x1133 = x1131.in(x1134); - Formula x1138 = x1131.eq(x750); - Formula x1137 = x1138.not(); - Formula x1132 = x1133.and(x1137); - Expression x1129 = x1132.comprehension(x1130); - Decls x1127 = x1128.oneOf(x1129); - Expression x1145 = x714.join(x10); - Expression x1144 = x1128.join(x1145); - Expression x1143 = x9.join(x1144); - Formula x1142 = x1143.no(); - Variable x1148 = Variable.unary("isLeg_pref2"); - Expression x1149 = x1143.join(x814); - Decls x1147 = x1148.oneOf(x1149); - Expression x1156 = x714.join(x10); - Expression x1155 = x1156.join(x6); - Expression x1154 = x1155.join(x6); - Formula x1153 = x1128.in(x1154); - Formula x1152 = x1153.not(); - Formula x1151 = x1152.not(); - Expression x1160 = x714.join(x10); - Expression x1159 = x1128.join(x1160); - Expression x1158 = x12.join(x1159); - Expression x1162 = x1143.join(x10); - Expression x1161 = x1148.join(x1162); - Formula x1157 = x1158.eq(x1161); - Formula x1150 = x1151.and(x1157); - Formula x1146 = x1150.forSome(x1147); - Formula x1141 = x1142.or(x1146); - Formula x1140 = x1141.not(); - Variable x1165 = Variable.unary("DWNodeCheck_first_hop_k_pref"); - Expression x1169 = x714.join(x10); - Expression x1168 = x1128.join(x1169); - Expression x1167 = x9.join(x1168); - Expression x1166 = x1167.join(x861); - Decls x1164 = x1165.oneOf(x1166); - Expression x1178 = x714.join(x10); - Expression x1177 = x1178.join(x6); - Expression x1176 = x1177.join(x6); - Formula x1175 = x1128.in(x1176); - Formula x1174 = x1175.not(); - Formula x1173 = x1174.not(); - Expression x1182 = x714.join(x10); - Expression x1181 = x1128.join(x1182); - Expression x1180 = x12.join(x1181); - Expression x1184 = x1167.join(x10); - Expression x1183 = x1165.join(x1184); - Formula x1179 = x1180.eq(x1183); - Formula x1172 = x1173.and(x1179); - Formula x1171 = x1172.not(); - Expression x1188 = x1167.join(x922); - Expression x1187 = x1165.join(x1188); - Expression x1190 = x714.join(x922); - Expression x1189 = x750.join(x1190); - Formula x1186 = x1187.eq(x1189); - Expression x1193 = x12.closure(); - Expression x1192 = x750.join(x1193); - Formula x1191 = x1128.in(x1192); - Formula x1185 = x1186.and(x1191); - Formula x1170 = x1171.or(x1185); - Formula x1163 = x1170.forAll(x1164); - Formula x1139 = x1140.and(x1163); - Formula x1126 = x1139.forAll(x1127); - Formula x1053 = x1054.and(x1126); - Formula x811 = x812.and(x1053); - Formula x804 = x811.forSome(x805); - Formula x798 = x804.forSome(x799); - Formula x783 = x798.forSome(x784); - Formula x773 = x783.forSome(x774); - Formula x758 = x773.forSome(x759); - Formula x748 = x758.forSome(x749); - Formula x733 = x748.forSome(x734); - Formula x725 = x733.forSome(x726); - Formula x718 = x725.forSome(x719); - Formula x712 = x718.forSome(x713); - Formula x268 = x269.or(x712); - Formula x267 = x268.not(); - Formula x144 = x145.iff(x267); - Formula x137 = x138.or(x144); - Formula x136 = x137.not(); - Formula x1194 = x0.eq(x0); - Formula x1195 = x1.eq(x1); - Formula x1196 = x2.eq(x2); - Formula x1197 = x3.eq(x3); - Formula x1198 = x4.eq(x4); - Formula x1199 = x5.eq(x5); - Formula x1200 = x6.eq(x6); - Formula x1201 = x7.eq(x7); - Formula x1202 = x8.eq(x8); - Formula x1203 = x9.eq(x9); - Formula x1204 = x10.eq(x10); - Formula x1205 = x11.eq(x11); - Formula x1206 = x12.eq(x12); - Formula x1207 = x13.eq(x13); - - Formula[] fs = new Formula[] { - x15, x16, x17, x18, x19, x26, x31, x34, x38, x39, x40, x42, x48, x57, x69, x82, x87, x109, x130, x136, x1194, x1195, x1196, x1197, x1198, x1199, x1200, x1201, x1202, x1203, x1204, x1205, x1206, x1207 - }; - String[] fsn = new String[] { - "x15", "x16", "x17", "x18", "x19", "x26", "x31", "x34", "x38", "x39", "x40", "x42", "x48", "x57", "x69", "x82", "x87", "x109", "x130", "x136", "x1194", "x1195", "x1196", "x1197", "x1198", "x1199", "x1200", "x1201", "x1202", "x1203", "x1204", "x1205", "x1206", "x1207" - }; - - Formula x14 = Formula.compose(FormulaOperator.AND, fs); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - solver.options().setReporter(new ConsoleReporter()); - System.out.println("Solving..."); - System.out.flush(); - Solution sol = solver.solve(x14, bounds); - System.out.println(sol.toString()); - - if (sol.instance() != null) { - System.out.println("Evaluating..."); - Evaluator ev = new Evaluator(sol.instance(), solver.options()); - for (int i = 0; i < fs.length; i++) { - System.out.println(fsn[i] + " =\n" + PrettyPrinter.print(fs[i], 2)); - } - System.out.println("\n===========================\n"); - for (int i = 0; i < fs.length; i++) { - System.out.println(fsn[i] + " = " + ev.evaluate(fs[i])); - } - final boolean val = ev.evaluate(x14); - System.out.println("x14 = " + val); - throw new AssertionError("bad instance"); - } - - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/BooleanCircuitTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/BooleanCircuitTest.java deleted file mode 100644 index 18656b4af..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/BooleanCircuitTest.java +++ /dev/null @@ -1,395 +0,0 @@ -package tests.basic; - -import static kodkod.engine.bool.BooleanConstant.FALSE; -import static kodkod.engine.bool.BooleanConstant.TRUE; -import static kodkod.engine.bool.Operator.AND; -import static kodkod.engine.bool.Operator.OR; - -import java.util.LinkedList; -import java.util.List; - -import junit.framework.TestCase; -import kodkod.engine.bool.BooleanConstant; -import kodkod.engine.bool.BooleanFactory; -import kodkod.engine.bool.BooleanValue; -import kodkod.engine.bool.BooleanVariable; -import kodkod.engine.bool.Operator; -import kodkod.engine.config.Options; - -public class BooleanCircuitTest extends TestCase { - - private BooleanFactory f; - private BooleanVariable[] v; - private final int size = 20; - - private static final Composer[] COMPOSERS = { - new Composer() { - - @Override - public BooleanValue compose(BooleanFactory f, BooleanValue v0, BooleanValue v1) { - return f.and(v0, v1); - } - }, new Composer() { - - @Override - public BooleanValue compose(BooleanFactory f, BooleanValue v0, BooleanValue v1) { - return f.or(v0, v1); - } - } - }; - - @Override - protected void setUp() throws Exception { - super.setUp(); - init(); - } - - private void init() { - f = BooleanFactory.factory(size, new Options()); - v = new BooleanVariable[size]; - for (int i = 0; i < size; i++) { - v[i] = f.variable(i + 1); - assertNotNull(v[i]); - } - } - - private static interface Composer { - - BooleanValue compose(BooleanFactory f, BooleanValue v0, BooleanValue v1); - } - - private final BooleanValue compose(Operator op, BooleanValue v0, BooleanValue v1) { - return COMPOSERS[op.ordinal()].compose(f, v0, v1); - } - - public final void testConstant() { - assertSame(TRUE, BooleanConstant.constant(true)); - assertTrue(TRUE.booleanValue()); - - assertSame(FALSE, BooleanConstant.constant(false)); - assertFalse(FALSE.booleanValue()); - } - - public void testVariable() { - for (int i = 0; i < size; i++) { - assertSame(v[i], f.variable(i + 1)); - } - } - - public final void testNot() { - // bivalency: !T = F, !F = T - assertSame(FALSE, f.not(TRUE)); - assertSame(TRUE, f.not(FALSE)); - - // involution !!a = a - assertSame(FALSE, f.not(f.not(FALSE))); - assertSame(TRUE, f.not(f.not(TRUE))); - - for (int i = 0; i < size; i++) { - assertSame(v[i], f.not(f.not(v[i]))); - } - - for (int i = 0; i < size / 2; i++) { - assertSame(f.or(v[i * 2], v[i * 2 + 1]), f.not(f.not(f.or(v[i * 2], v[i * 2 + 1])))); - assertSame(f.and(v[i * 2], v[i * 2 + 1]), f.not(f.not(f.and(v[i * 2], v[i * 2 + 1])))); - } - } - - private final void testParenthesis(BooleanValue result, Operator.Nary op, BooleanValue p, BooleanValue q, BooleanValue r, BooleanValue s) { - - // System.out.println("-------------------------------"); - // System.out.println("p: " + p + " " + p.literal()); - // System.out.println("q: " + q + " " + q.literal()); - // System.out.println("r: " + r + " " + r.literal()); - // System.out.println("s: " + s + " " + s.literal()); - // - // System.out.println("pq: " + f.compose(op, p, q)); - // System.out.println("rs: " + f.compose(op, r, s)); - // System.out.println("(pq)(rs): " + f.compose(op, f.compose(op, p, q), - // f.compose(op, r , s))); - // - // System.out.println("rs: " + r.compose(op, s)); - // System.out.println("q(rs): " + q.compose(op, r.compose(op, s))); - // System.out.println("p(q(rs)): " + p.compose(op, (q.compose(op, - // (r.compose(op, s)))))); - // - // System.out.println("qr: " + q.compose(op, r)); - // System.out.println("(qr)s: " + (q.compose(op, r)).compose(op, s)); - // System.out.println("p(qr)s): " + p.compose(op, ((q.compose(op, - // r)).compose(op, s)))); - // - // System.out.println("pq: " + p.compose(op, q)); - // System.out.println("(pq)r: " + (p.compose(op, q)).compose(op, r)); - // System.out.println("(p(qr))s: " + ((p.compose(op, q)).compose(op, - // r)).compose(op, s)); - - // p(q(rs)) - assertSame(result, compose(op, p, compose(op, q, compose(op, r, s)))); - // p((qr)s) - assertSame(result, compose(op, p, compose(op, compose(op, q, r), s))); - // (pq)(rs) - assertSame(result, compose(op, compose(op, p, q), compose(op, r, s))); - // (p(qr))s - assertSame(result, compose(op, p, compose(op, compose(op, q, r), s))); - // ((pq)r)s - assertSame(result, compose(op, compose(op, compose(op, p, q), r), s)); - } - - private final void testIdentityContradictionExcludedMiddle(Operator.Nary op, BooleanValue p) { - // identity: p & T = p | F = p - assertSame(p, compose(op, p, op.identity())); - - // short circuit: p & F = F, p | T = T - assertSame(op.shortCircuit(), compose(op, p, op.shortCircuit())); - - // contradiction / excluded middle: p & !p = F, p | !p = T - assertSame(op.shortCircuit(), compose(op, p, f.not(p))); - - } - - private final void testIdempotencyAbsorptionContraction(Operator.Nary op, BooleanValue p, BooleanValue q) { - // idempotency: p op p = p - assertSame(p, compose(op, p, p)); - assertSame(q, compose(op, q, q)); - - // absorption: p op (p op q) = p op q - assertSame(compose(op, p, q), compose(op, p, compose(op, p, q))); - - // contraction: p op.complement (p op q) = p - // System.out.println(p + ", " + q + ", " + p.compose(op.complement(), - // p.compose(op, q))); - assertSame(p, compose(op.complement(), p, compose(op, p, q))); - } - - private final void testCommutativityAndAssociativity(Operator.Nary op, BooleanValue p, BooleanValue q, BooleanValue r, BooleanValue s) { - - // System.out.println("p: " + p + " " + p.digest()); - // System.out.println("q: " + q + " " + q.digest()); - // System.out.println("r: " + r + " " + r.digest()); - // System.out.println("s: " + s + " " + s.digest()); - // System.out.println("pq: " + p.compose(op, q)); - // System.out.println("pqr: " + p.compose(op, q).compose(op, r)); - // System.out.println("pqrs: " + p.compose(op, q).compose(op, - // r).compose(op, s)); - - // commutativity: p op q = p op q - // and associativity: p op (r op q) = (p op r) op q - - // generate all permutations, and their parenthesizations, of p q r s - // and check that they are the same - final List formulas = new LinkedList(); - formulas.add(p); - formulas.add(q); - formulas.add(r); - formulas.add(s); - - final BooleanValue composition = compose(op, compose(op, compose(op, p, q), r), s); - - for (int i0 = 0; i0 < 4; i0++) { - BooleanValue f0 = formulas.get(i0); - formulas.remove(i0); - for (int i1 = 0; i1 < 3; i1++) { - BooleanValue f1 = formulas.get(i1); - formulas.remove(i1); - - for (int i2 = 0; i2 < 2; i2++) { - BooleanValue f2 = formulas.get(i2); - formulas.remove(i2); - testParenthesis(composition, op, f0, f1, f2, formulas.get(0)); - formulas.add(i2, f2); - } - - formulas.add(i1, f1); - - } - formulas.add(i0, f0); - } - - } - - private final void testMultiGateWithConstantAndFormula(Operator.Nary op, BooleanValue p, BooleanValue q) { - testCommutativityAndAssociativity(op, TRUE, p, q, FALSE); - testCommutativityAndAssociativity(op, FALSE, TRUE, p, q); - testCommutativityAndAssociativity(op, p, TRUE, q, FALSE); - testIdempotencyAbsorptionContraction(op, p, FALSE); - testIdempotencyAbsorptionContraction(op, TRUE, q); - } - - private final void testMultiGateWithConstantArgument(Operator.Nary op) { - // constant / constant - testIdentityContradictionExcludedMiddle(op, TRUE); - testIdentityContradictionExcludedMiddle(op, FALSE); - testIdempotencyAbsorptionContraction(op, TRUE, FALSE); - - // constant / variable - testMultiGateWithConstantAndFormula(op, v[8], v[9]); - - // constant / negation - final BooleanValue v246 = compose(op, v[2], compose(op.complement(), v[4], v[6])); - final BooleanValue v135 = compose(op.complement(), v[1], compose(op, v[3], v[5])); - testMultiGateWithConstantAndFormula(op, f.not(v246), f.not(v135)); - testMultiGateWithConstantAndFormula(op, v246, f.not(v135)); - - // constant / multigate - testMultiGateWithConstantAndFormula(op, v246, v135); - testMultiGateWithConstantAndFormula(op, compose(op, v[2], v[3]), compose(op, v[1], v[4])); - } - - private final void testMultiGateWithVariableArgument(Operator.Nary op) { - // variable / variable - testIdentityContradictionExcludedMiddle(op, v[0]); - testIdentityContradictionExcludedMiddle(op, v[3]); - testCommutativityAndAssociativity(op, v[4], v[6], v[8], v[2]); - testIdempotencyAbsorptionContraction(op, v[1], v[5]); - - // variable / negation - final BooleanValue v101214 = compose(op, v[10], compose(op.complement(), v[12], v[14])); - final BooleanValue v151311 = compose(op.complement(), v[15], compose(op, v[13], v[11])); - - testCommutativityAndAssociativity(op, v[10], f.not(v151311), v[14], f.not(v101214)); - testIdempotencyAbsorptionContraction(op, v[11], f.not(v151311)); - - // variable / multigate - final BooleanValue v191618 = compose(op.complement(), v[19], compose(op.complement(), v[16], v[18])), - v101712 = compose(op, v[10], compose(op, v[17], v[12])), - v141815 = compose(op.complement(), v[14], compose(op, v[18], v[15])), - v121716 = compose(op, v[12], compose(op.complement(), v[17], v[16])); - testCommutativityAndAssociativity(op, v[10], v[12], v191618, v141815); - // fails due to not extensively checking for sharing, which is ok for - // now - // testCommutativityAndAssociativity(op, v[10], v[12], v121716, - // v101712); - testCommutativityAndAssociativity(op, v[9], v[18], v[16], v121716); - testIdempotencyAbsorptionContraction(op, v[10], v101712); - testIdempotencyAbsorptionContraction(op, v[14], v141815); - } - - private final void testMultiGateWithNegatedArgument(Operator.Nary op) { - // negation / negation - final BooleanValue v842 = compose(op.complement(), v[8], compose(op.complement(), v[4], v[2])), - v191015 = compose(op, v[19], compose(op, v[10], v[15])), - v027 = compose(op.complement(), v[0], compose(op, v[2], v[7])), - v15104 = compose(op, v[15], compose(op.complement(), v[10], v[4])); - testIdentityContradictionExcludedMiddle(op, f.not(v027)); - testIdentityContradictionExcludedMiddle(op, f.not(v191015)); - testCommutativityAndAssociativity(op, f.not(v842), f.not(v191015), f.not(v027), f.not(v15104)); - - // negation / multigate - testCommutativityAndAssociativity(op, v842, f.not(v191015), v027, f.not(v15104)); - testCommutativityAndAssociativity(op, f.not(v842), v191015, v027, f.not(v15104)); - testCommutativityAndAssociativity(op, v842, f.not(v191015), f.not(v027), v15104); - testCommutativityAndAssociativity(op, f.not(v842), v191015, f.not(v027), v15104); - - } - - private final void testMultiGateWithMultiGateArgument(Operator.Nary op) { - final BooleanValue v842 = compose(op.complement(), v[8], compose(op.complement(), v[4], v[2])), - v191015 = compose(op, v[19], compose(op, v[10], v[15])), - v027 = compose(op.complement(), v[0], compose(op, v[2], v[7])), - v15104 = compose(op, v[15], compose(op.complement(), v[10], v[4])); - - testIdentityContradictionExcludedMiddle(op, v027); - testIdentityContradictionExcludedMiddle(op, v191015); - testCommutativityAndAssociativity(op, v842, v191015, v027, v15104); - testCommutativityAndAssociativity(op, v842, v191015, v027, compose(op, v[18], v[1])); - testIdempotencyAbsorptionContraction(op, v842, v15104); - } - - private void testMultiGate(Operator.Nary op) { - testMultiGateWithConstantArgument(op); - init(); - testMultiGateWithVariableArgument(op); - init(); - testMultiGateWithNegatedArgument(op); - init(); - testMultiGateWithMultiGateArgument(op); - } - - public final void testAnd() { - testMultiGate(AND); - } - - public final void testOr() { - testMultiGate(OR); - } - - public final void testITE() { - final BooleanValue a12 = f.and(v[1], v[2]), na12 = f.not(a12), a45 = f.and(v[4], v[5]), o67 = f.or(v[6], v[7]), - no67 = f.not(o67), o89 = f.or(v[8], v[9]), no89 = f.not(o89); - assertSame(a12, f.ite(TRUE, a12, a45)); - assertSame(a45, f.ite(FALSE, a12, a45)); - assertSame(f.or(o89, a12), f.ite(a12, TRUE, o89)); - assertSame(f.and(o89, na12), f.ite(a12, FALSE, o89)); - assertSame(f.or(no67, a45), f.ite(o67, a45, TRUE)); - assertSame(f.and(no89, no67), f.ite(no89, no67, FALSE)); - assertSame(o67, f.ite(o89, o67, o67)); - assertSame(f.or(a12, o67), f.ite(a12, a12, o67)); - assertSame(f.and(o89, na12), f.ite(a12, na12, o89)); - assertSame(f.or(no67, a45), f.ite(o67, a45, no67)); - assertSame(f.and(no89, no67), f.ite(no89, no67, no89)); - assertSame(f.ite(f.and(v[1], v[2]), o67, a45), f.ite(a12, f.or(v[6], v[7]), a45)); - - } - - // public final void testReductions() { - // final BooleanValue val1 = f.or(v[10], v[6]); - // final BooleanValue val2 = f.or(v[8], val1); - // System.out.println(val1); - // System.out.println(val2); - // System.out.println(f.or(f.not(val2), val1)); - // - // final BooleanAccumulator val3 = BooleanAccumulator.treeGate(OR); - // final BooleanAccumulator val4 = BooleanAccumulator.treeGate(AND); - // for(int i = 0; i < 5; i++) { - // val3.add(v[i]); - // val4.add(f.not(v[i])); - // } - // final BooleanValue val5 = f.accumulate(val3); - // final BooleanValue val6 = f.accumulate(val4); - // System.out.println(val3); - // System.out.println(val4); - // System.out.println(val5); - // System.out.println(val6); - // System.out.println(f.and(val5, val6)); - // } - - // private final void testSimpleReductions(Operator.Nary op) { - // final BooleanValue y = compose(op.complement(), v[18], v[19]); - // final BooleanValue noty = f.not(y); - // final BooleanAccumulator acc = BooleanAccumulator.treeGate(op); - // for(int i = 0, max = (1<FALSE && cells'[index] = FALSE - */ - private static final void blank(BooleanMatrix m, BooleanValue[] cells, int index) { - m.set(index, FALSE); - cells[index] = FALSE; - } - - private static final IntRange range(int min, int max) { - return Ints.range(min, max); - } - - private void assertEquals(IntRange range, Iterator> indexIter) { - for (int i = range.min(); i <= range.max(); i++) { - assertEquals(i, indexIter.next().index()); - } - } - - public final void testSetAndGet() { - // set regions [4..8], [11..14], [16..23], [9..10] to variables - fill(mF324, mCells, mR[1]); - fill(mF324, mCells, mR[3]); - fill(mF324, mCells, mR[5]); - fill(mF324, mCells, mR[2]); - assertTrue(equivalent(mF324, mCells)); - - // check that the dense regions in the matrix are [4..14] and [16..23] - Iterator> indeces = mF324.iterator(); - assertEquals(Ints.merge(Ints.merge(mR[1], mR[2]), mR[3]), indeces); - assertEquals(mR[5], indeces); - - // wipe out 4, 14, 23, and 10 - blank(mF324, mCells, mR[1].min()); - blank(mF324, mCells, mR[3].max()); - blank(mF324, mCells, mR[5].max()); - blank(mF324, mCells, mR[2].max()); - assertTrue(equivalent(mF324, mCells)); - // add 4 again - fill(mF324, mCells, range(mR[1].min(), mR[1].min())); - indeces = mF324.iterator(); - assertEquals(Ints.merge(range(mR[1].min(), mR[1].max()), range(mR[2].min(), mR[2].max() - 1)), indeces); - assertEquals(range(mR[2].max() + 1, mR[3].max() - 1), indeces); - assertEquals(range(mR[5].min(), mR[5].max() - 1), indeces); - - // System.out.println(mF324); - } - - public final void testNot() { - - fill(mT324, mCells, mR[1]); - fill(mT324, mCells, mR[3]); - for (int i = mR[1].min(); i <= mR[1].max(); i++) { - mCells[i] = f.not(mCells[i]); - } - for (int i = mR[3].min(); i <= mR[3].max(); i++) { - mCells[i] = f.not(mCells[i]); - } - mT324.set(mR[1].max() + 1, FALSE); - mCells[mR[1].max() + 1] = TRUE; - - BooleanMatrix mNot = mT324.not(); - - assertTrue(equivalent(mT324.dimensions(), mNot.dimensions())); - assertTrue(equivalent(mNot, mCells)); - - // System.out.println(mT324); - // System.out.println(mNot); - } - - public final void testAnd() { - assertTrue(equivalent(mT324, mT324.and(mT324))); - assertTrue(equivalent(mF324, mF324.and(mF324))); - assertTrue(equivalent(mF324, mF324.and(mT324))); - assertTrue(equivalent(mT324.and(mF324), mF324.and(mT324))); - - for (int i = mR[2].min(); i <= mR[2].max(); i++) { - mT324.set(i, vars[i]); - mF324.set(i, vars[2 * i % vars.length]); - mCells[i] = f.and(vars[i], vars[2 * i % vars.length]); - } - assertTrue(equivalent(mT324.and(mF324), mCells)); - - mT324.set(mR[4].min(), vars[mR[4].min()]); - mF324.set(mR[3].min(), vars[mR[3].min()]); - mCells[mR[3].min()] = vars[mR[3].min()]; - assertTrue(equivalent(mT324.and(mF324), mCells)); - - // System.out.println(mT324); - // System.out.println(mF324); - - } - - public final void testOr() { - assertTrue(equivalent(mT324, mT324.or(mT324))); - assertTrue(equivalent(mF324, mF324.or(mF324))); - assertTrue(equivalent(mT324, mT324.or(mF324))); - assertTrue(equivalent(mT324.or(mF324), mF324.or(mT324))); - - Arrays.fill(mCells, TRUE); - - for (int i = mR[1].min(); i <= mR[1].max(); i++) { - mT324.set(i, vars[i]); - mF324.set(i, vars[2 * i % vars.length]); - mCells[i] = f.or(vars[i], vars[2 * i % vars.length]); - } - assertTrue(equivalent(mT324.or(mF324), mCells)); - - mT324.set(mR[0].max(), vars[mR[0].max()]); - mF324.set(mR[2].min(), vars[mR[2].min()]); - mCells[mR[0].max()] = vars[mR[0].max()]; - assertTrue(equivalent(mT324.or(mF324), mCells)); - - // System.out.println(mT324); - // System.out.println(mF324); - // System.out.println(Arrays.asList(mCells)); - - } - - private final void assertDotProductFalse(BooleanMatrix mF, BooleanMatrix m) { - BooleanMatrix product = mF.dot(m); - assertEquals(0, product.density()); - assertTrue(equivalent(mF.dimensions().dot(m.dimensions()), product.dimensions())); - } - - public final void testDotProduct() { - fill(mF43, range(0, dim43.capacity() - 1)); - fill(mF4, range(0, dim4.capacity() - 1)); - - assertDotProductFalse(mF324, mF43); - assertDotProductFalse(mF324, mF4); - - fill(mF324, range(0, dim324.capacity() - 1)); - - BooleanValue[] result = new BooleanValue[dim324.dot(dim43).capacity()]; - for (int i = 0; i < result.length; i++) { - result[i] = BooleanAccumulator.treeGate(Operator.OR); - } - int rows43 = dim324.dimension(dim324.numDimensions() - 1); - int rows324 = dim324.capacity() / rows43; - int cols43 = dim43.capacity() / rows43; - for (int i = 0; i < rows324; i++) { - for (int j = 0; j < cols43; j++) { - for (int k = 0; k < rows43; k++) { - int index324 = i * rows43 + k; - int index43 = j + k * cols43; - int indexR = cols43 * i + j; - ((BooleanAccumulator) result[indexR]).add(f.and(mF324.get(index324), mF43.get(index43))); - } - } - } - for (int i = 0; i < result.length; i++) { - result[i] = f.accumulate((BooleanAccumulator) result[i]); - } - - assertTrue(equivalent(mF324.dot(mF43), result)); - - for (int i = 0; i < dim324.capacity(); i += 2) { - mF324.set(i, FALSE); - } - for (int i = 1; i < dim4.capacity(); i += 2) { - mF4.set(i, FALSE); - } - - assertDotProductFalse(mF324, mF4); - - } - - private final void assertCrossProductFalse(BooleanMatrix mF, BooleanMatrix m) { - BooleanMatrix product = mF.cross(m); - assertEquals(0, product.density()); - assertTrue(equivalent(mF.dimensions().cross(m.dimensions()), product.dimensions())); - } - - public final void testCrossProduct() { - final BooleanMatrix mT43 = mF43.not(); - - fill(mT43, range(0, dim43.capacity() - 1)); - fill(mF4, range(0, dim4.capacity() - 1)); - - assertCrossProductFalse(mF324, mT43); - assertCrossProductFalse(mF324, mF4); - - fill(mT324, range(0, dim324.capacity() - 1)); - - BooleanValue[] result = new BooleanValue[dim324.cross(dim43).capacity()]; - Arrays.fill(result, TRUE); - - final int c324 = dim324.capacity(), c43 = dim43.capacity(); - final int c32443 = c324 * c43; - - for (int i = 0; i < c32443; i++) { - result[i] = f.and(mT324.get(i / c43), mT43.get(i % c43)); - } - assertTrue(equivalent(mT324.cross(mT43), result)); - - mT324.set(1, TRUE); - for (int i = c43; i < c43 * 2; i++) { - result[i] = mT43.get(i % c43); - } - - assertTrue(equivalent(mT324.cross(mT43), result)); - - mT43.set(5, TRUE); - for (int i = 0; i < c324; i++) { - result[i * c43 + 5] = mT324.get(i); - } - - assertTrue(equivalent(mT324.cross(mT43), result)); - - mT324.set(10, FALSE); - for (int i = c43 * 10; i < c43 * 11; i++) { - result[i] = FALSE; - } - - assertTrue(equivalent(mT324.cross(mT43), result)); - // System.out.println(Arrays.asList(result)); - // System.out.println(mT324.crossProduct(mT43)); - - } - - public final void testTranspose() { - BooleanMatrix mF43t = mF43.transpose(); - assertEquals(mF43.density(), mF43t.density()); - assertTrue(equivalent(dim43.transpose(), mF43t.dimensions())); - - fill(mF43, range(0, dim43.capacity() - 1)); - BooleanValue[] result = new BooleanValue[dim43.capacity()]; - final int a = dim43.dimension(0), b = dim43.dimension(1); - for (int i = 0; i < a; i++) { - for (int j = 0; j < b; j++) { - result[j * a + i] = vars[i * b + j]; - } - } - - mF43t = mF43.transpose(); - assertEquals(mF43.density(), mF43t.density()); - assertTrue(equivalent(dim43.transpose(), mF43t.dimensions())); - assertTrue(equivalent(mF43t, result)); - - } - - public final void testClosure() { - BooleanMatrix mF44 = f.matrix(Dimensions.square(4, 2)); - assertTrue(equivalent(mF44, mF44.closure())); - - mF44.set(0, vars[0]); - mF44.set(9, vars[9]); - assertTrue(equivalent(mF44, mF44.closure())); - - mF44.set(2, vars[2]); - - BooleanValue[] result = new BooleanValue[mF44.dimensions().capacity()]; - for (int i = 0; i < result.length; i++) { - result[i] = FALSE; - } - result[0] = vars[0]; - result[1] = f.and(vars[2], vars[9]); - result[1] = f.or(result[1], f.and(vars[0], result[1])); - result[2] = vars[2]; - result[9] = vars[9]; - - assertTrue(equivalent(mF44.closure(), result)); - - mF44.set(7, vars[7]); - result[7] = vars[7]; - result[3] = f.and(vars[2], f.and(vars[9], vars[7])); - result[11] = f.and(vars[7], vars[9]); - - assertTrue(equivalent(mF44.closure(), result)); - - // System.out.println(mF44.closure()); - } - - public final void testOverride() { - assertTrue(equivalent(mT324.override(mT324), mT324)); - assertTrue(equivalent(mT324.override(mF324), mT324)); - assertTrue(equivalent(mF324.override(mT324), mT324)); - assertTrue(equivalent(mF324.override(mF324), mF324)); - - final BooleanMatrix mF324c = mF324.clone(), mT324c = mT324.clone(); - - mF324.set(3, vars[3]); - mF324.set(17, vars[17]); - mF324.set(22, vars[22]); - assertTrue(equivalent(mF324.override(mF324c), mF324)); - assertTrue(equivalent(mF324.override(mT324), mT324)); - - mF324c.set(9, vars[9]); - assertTrue(equivalent(mF324.override(mF324c), mF324.or(mF324c))); - - mT324.set(0, BooleanConstant.FALSE); - assertTrue(equivalent(mF324.override(mT324), mT324)); - assertTrue(equivalent(mT324.override(mT324c), mT324c)); - assertTrue(equivalent(mT324c.override(mT324), mT324)); - - final BooleanMatrix mFoF = f.matrix(dim324); - mF324.set(10, vars[10]); - mF324c.set(3, vars[4]); - mF324c.set(20, vars[20]); - mF324c.set(19, vars[19]); - - mFoF.set(3, f.or(vars[4], f.and(vars[3], f.not(vars[4])))); - mFoF.set(9, vars[9]); - mFoF.set(10, f.and(vars[10], f.not(vars[9]))); - mFoF.set(17, f.and(vars[17], f.and(f.not(vars[19]), f.not(vars[20])))); - mFoF.set(22, f.and(vars[22], f.and(f.not(vars[19]), f.not(vars[20])))); - mFoF.set(20, vars[20]); - mFoF.set(19, vars[19]); - - assertTrue(equivalent(mF324.override(mF324c), mFoF)); - - mT324.set(3, vars[4]); - mT324.set(11, vars[11]); - for (int i = 16; i < 24; i++) - mT324.set(i, vars[i - 16]); - - final BooleanMatrix mFoT = f.matrix(dim324); - for (int i = 0; i < 16; i++) - mFoT.set(i, mT324.get(i)); - - final BooleanAccumulator g = BooleanAccumulator.treeGate(Operator.AND); - for (int i = 0; i < 8; i++) - g.add(f.not(vars[i])); - final BooleanValue v3 = f.accumulate(g); - - for (int i = 16; i < 24; i++) - mFoT.set(i, f.or(f.and(v3, mF324.get(i)), mT324.get(i))); - - assertTrue(equivalent(mF324.override(mT324), mFoT)); - - final BooleanMatrix mToF = f.matrix(dim324); - for (int i = 0; i < 8; i++) - mToF.set(i, f.or(mF324.get(i), f.and(mT324.get(i), f.not(vars[3])))); - for (int i = 8; i < 16; i++) - mToF.set(i, f.or(mF324.get(i), f.and(mT324.get(i), f.not(vars[10])))); - for (int i = 16; i < 24; i++) - mToF.set(i, f.or(mF324.get(i), f.and(mT324.get(i), f.and(f.not(vars[17]), f.not(vars[22]))))); - - assertTrue(equivalent(mT324.override(mF324), mToF)); - - final BooleanMatrix mToT = f.matrix(dim324).not(); - mT324c.set(11, vars[12]); - mT324c.set(12, vars[13]); - mT324c.set(18, vars[18]); - for (int i = 0; i < 16; i++) - mToT.set(i, mT324.get(i)); - for (int i = 16; i < 24; i++) - mToT.set(i, f.or(mT324.get(i), f.and(mT324c.get(i), v3))); - - assertTrue(equivalent(mT324c.override(mT324), mToT)); - - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/BugTests.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/BugTests.java deleted file mode 100644 index 89570a6f2..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/BugTests.java +++ /dev/null @@ -1,3329 +0,0 @@ -package tests.basic; - -import static kodkod.ast.Expression.UNIV; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import junit.framework.TestCase; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Evaluator; -import kodkod.engine.Proof; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.AbstractReporter; -import kodkod.engine.config.Options; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.engine.fol2sat.Translator; -import kodkod.engine.fol2sat.UnboundLeafException; -import kodkod.engine.satlab.SATFactory; -import kodkod.engine.ucore.RCEStrategy; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; -import kodkod.util.ints.IntBitSet; -import kodkod.util.ints.IntIterator; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; -import kodkod.util.nodes.Nodes; - -/** - * Test cases that record reported bugs. - * - * @author Emina Torlak - */ -public class BugTests extends TestCase { - - private final Solver solver = new Solver(); - - public final void testBGP_03172011() { - - Relation x5 = Relation.unary("s012"); - Relation x8 = Relation.unary("zero"); - Relation x9 = Relation.unary("one"); - Relation x12 = Relation.nary("next", 2); - - Universe universe = new Universe(Arrays.asList("0", "1", "2", "3")); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - bounds.boundExactly(x5, factory.setOf("0", "1", "2")); - bounds.boundExactly(x8, factory.setOf("0")); - bounds.bound(x9, factory.setOf("1"), factory.setOf("1", "2")); - - TupleSet x12_upper = factory.noneOf(2); - x12_upper.add(factory.tuple("1", "2")); - x12_upper.add(factory.tuple("2", "3")); - bounds.boundExactly(x12, x12_upper); - - Variable x714 = Variable.unary("x714"); - Decls x713 = x714.oneOf(x8.union(x9)); - - Variable x720 = Variable.unary("x720"); - Expression x723 = x8.union(x9); - Expression x724 = x9.join(x12); - Expression x722 = x723.union(x724); - Expression x721 = x722.difference(x714); - Decls x719 = x720.oneOf(x721); - - Variable x727 = Variable.unary("x727"); - Expression x732 = x714.union(x720); - Expression x728 = x5.difference(x732); - Decls x726 = x727.oneOf(x728); - - Variable x735 = Variable.unary("x735"); - Decls x734 = x735.oneOf(x8); - - Variable x893 = Variable.unary("x893"); - Decls x892 = x893.oneOf(x727); - Formula x894 = x720.no(); - Formula x891 = x894.forAll(x892); - - Formula x712 = x891.forSome(x713.and(x719).and(x726).and(x734)); - Formula x267 = Formula.FALSE.or(x712); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - - final Solution sol = solver.solve(x267, bounds); - assertEquals(sol.outcome(), Solution.Outcome.TRIVIALLY_UNSATISFIABLE); - } - - public final void testFelix_03162009() { - Relation x = Relation.unary("X"); - Relation y = Relation.unary("Y"); - Relation q = Relation.unary("Q"); - Relation f = Relation.nary("f", 2); - - List atomlist = Arrays.asList("X", "Y"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x_upper = factory.noneOf(1); - x_upper.add(factory.tuple("X")); - bounds.boundExactly(x, x_upper); - - TupleSet y_upper = factory.noneOf(1); - y_upper.add(factory.tuple("Y")); - bounds.boundExactly(y, y_upper); - - TupleSet q_upper = factory.noneOf(1); - q_upper.add(factory.tuple("X")); - q_upper.add(factory.tuple("Y")); - bounds.bound(q, q_upper); - - TupleSet f_upper = factory.noneOf(2); - f_upper.add(factory.tuple("X").product(factory.tuple("X"))); - f_upper.add(factory.tuple("X").product(factory.tuple("Y"))); - f_upper.add(factory.tuple("Y").product(factory.tuple("X"))); - f_upper.add(factory.tuple("Y").product(factory.tuple("Y"))); - bounds.bound(f, f_upper); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - - Expression test = f.override(q.product(y)); - TupleSet approx = factory.setOf(test.arity(), Translator.approximate(test, bounds, solver.options()).denseIndices()); - assertEquals(f_upper, approx); - } - - public final void testFelix_10272008() { - Relation x0 = Relation.unary("Int/min"); - Relation x1 = Relation.unary("Int/zero"); - Relation x2 = Relation.unary("Int/max"); - Relation x3 = Relation.nary("Int/next", 2); - Relation x4 = Relation.unary("seq/Int"); - Relation x5 = Relation.unary("this/X"); - - List atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7", "unused0", "unused1", "unused2"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("-8")); - bounds.boundExactly(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("0")); - bounds.boundExactly(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("7")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(2); - x3_upper.add(factory.tuple("-8").product(factory.tuple("-7"))); - x3_upper.add(factory.tuple("-7").product(factory.tuple("-6"))); - x3_upper.add(factory.tuple("-6").product(factory.tuple("-5"))); - x3_upper.add(factory.tuple("-5").product(factory.tuple("-4"))); - x3_upper.add(factory.tuple("-4").product(factory.tuple("-3"))); - x3_upper.add(factory.tuple("-3").product(factory.tuple("-2"))); - x3_upper.add(factory.tuple("-2").product(factory.tuple("-1"))); - x3_upper.add(factory.tuple("-1").product(factory.tuple("0"))); - x3_upper.add(factory.tuple("0").product(factory.tuple("1"))); - x3_upper.add(factory.tuple("1").product(factory.tuple("2"))); - x3_upper.add(factory.tuple("2").product(factory.tuple("3"))); - x3_upper.add(factory.tuple("3").product(factory.tuple("4"))); - x3_upper.add(factory.tuple("4").product(factory.tuple("5"))); - x3_upper.add(factory.tuple("5").product(factory.tuple("6"))); - x3_upper.add(factory.tuple("6").product(factory.tuple("7"))); - bounds.boundExactly(x3, x3_upper); - - TupleSet x4_upper = factory.noneOf(1); - x4_upper.add(factory.tuple("0")); - x4_upper.add(factory.tuple("1")); - x4_upper.add(factory.tuple("2")); - x4_upper.add(factory.tuple("3")); - bounds.boundExactly(x4, x4_upper); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("unused0")); - x5_upper.add(factory.tuple("unused1")); - x5_upper.add(factory.tuple("unused2")); - bounds.bound(x5, x5_upper); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Variable x11 = Variable.unary("c"); - Expression x12 = x5.difference(x5); - Decls x10 = x11.oneOf(x12); - IntExpression x13 = IntConstant.constant(0); - IntExpression x9 = x13.sum(x10); - IntExpression x14 = IntConstant.constant(0); - Formula x8 = x9.eq(x14); - Formula x17 = x0.eq(x0); - Formula x18 = x2.eq(x2); - Formula x16 = x17.and(x18); - Formula x19 = x3.eq(x3); - Formula x15 = x16.and(x19); - Formula x7 = x8.and(x15); - Formula x22 = x1.eq(x1); - Formula x23 = x4.eq(x4); - Formula x21 = x22.and(x23); - Formula x24 = x5.eq(x5); - Formula x20 = x21.and(x24); - Formula x6 = x7.and(x20); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - - Solution sol = solver.solve(x6, bounds); - assertEquals(sol.outcome(), Solution.Outcome.TRIVIALLY_SATISFIABLE); - } - - public final void testFelix_06192008() { - Relation x5 = Relation.unary("R"); - - List atomlist = Arrays.asList("X"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("X")); - bounds.bound(x5, x5_upper); - - Variable x10 = Variable.unary("a"); - Expression x11 = x5.difference(x5); - Decls x9 = x10.oneOf(x11); - Variable x14 = Variable.nary("b", 2); - Expression x15 = x5.product(x5); - Decls x13 = x14.setOf(x15); - Expression x19 = x5.product(x5); - Formula x17 = x14.in(x19); - Expression x22 = x10.product(x10); - Formula x21 = x22.eq(x14); - Formula x16 = x17.and(x21); - Formula x12 = x16.forSome(x13); - Formula x7 = x12.forAll(x9); - - // System.out.println(x7); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - - // System.out.println("Depth=0..."); System.out.flush(); - solver.options().setSkolemDepth(0); - assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(x7, bounds).outcome()); - - // System.out.println("Depth=1..."); System.out.flush(); - solver.options().setSkolemDepth(1); - final Solution sol = solver.solve(x7, bounds); - assertEquals(Solution.Outcome.SATISFIABLE, sol.outcome()); - assertEquals(2, sol.instance().relations().size()); - for (Relation r : sol.instance().relations()) { - assertTrue(sol.instance().tuples(r).isEmpty()); - } - } - - public final void testFelix_05072008() { - Relation A = Relation.unary("A"), first = Relation.unary("OrdFirst"), last = Relation.unary("OrdLast"), - next = Relation.nary("OrdNext", 2); - - List atomlist = Arrays.asList("A1", "A2", "A3"); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet all = factory.setOf("A1", "A2", "A3"); - bounds.boundExactly(A, all); - bounds.bound(first, all); - bounds.bound(last, all); - bounds.bound(next, all.product(all)); - - Formula form = next.totalOrder(A, first, last); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(0); - solver.options().setSkolemDepth(0); - - Iterator sol = solver.solveAll(form, bounds); - assertTrue(sol.hasNext()); - assertEquals(sol.next().outcome(), Solution.Outcome.TRIVIALLY_SATISFIABLE); - assertTrue(sol.hasNext()); - assertEquals(sol.next().outcome(), Solution.Outcome.TRIVIALLY_UNSATISFIABLE); - assertFalse(sol.hasNext()); - - // int i=1; - // - // while (sol.hasNext()) { - // System.out.println("================================== "+i+" - // ==================================="); - // System.out.println(sol.next()); - // System.out.flush(); - // i++; - // } - } - - public final void testEmina_05072008() { - Relation A = Relation.unary("A"), first = Relation.unary("OrdFirst"), last = Relation.unary("OrdLast"), - next = Relation.nary("OrdNext", 2); - Relation B = Relation.unary("B"), acyclic = Relation.binary("acyclic"); - - List atomlist = Arrays.asList("A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2"); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet allA = factory.setOf("A1", "A2", "A3"); - TupleSet allB = factory.setOf("B1", "B2", "B3"); - TupleSet allC = factory.setOf("C1", "C2"); - bounds.boundExactly(A, allA); - bounds.bound(first, allA); - bounds.bound(last, allA); - bounds.bound(next, allA.product(allA)); - bounds.boundExactly(B, allB); - bounds.bound(acyclic, allC.product(allC)); - - Variable v = Variable.unary("v"); - Formula f0 = Formula.TRUE.forSome(v.setOf(B)); - Formula f1 = next.totalOrder(A, first, last); - Formula f2 = acyclic.acyclic(); - Formula form = f0.and(f1).and(f2); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(0); - solver.options().setSkolemDepth(0); - - Iterator sol = solver.solveAll(form, bounds); - int i = 1; - - while (sol.hasNext()) { - assertTrue(i <= 17); - sol.next(); - i++; - } - } - - public final void testFelix_03062008_2() { - Relation x5 = Relation.unary("Role"); - Relation x6 = Relation.unary("Session"); - - List atomlist = Arrays.asList("Role$0", "Session$0", "Session$1"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("Role$0")); - bounds.bound(x5, x5_upper); - - TupleSet x6_upper = factory.noneOf(1); - x6_upper.add(factory.tuple("Session$0")); - x6_upper.add(factory.tuple("Session$1")); - bounds.bound(x6, x6_upper); - - Variable x11 = Variable.unary("x_a"); - Decls x10 = x11.oneOf(x6); - Variable x15 = Variable.unary("x_b"); - Decls x14 = x15.oneOf(x5); - Variable x17 = Variable.unary("x_c"); - Decls x16 = x17.oneOf(x5); - Decls x13 = x14.and(x16); - Expression x20 = x15.product(x17); - Expression x19 = x11.product(x20); - Formula x18 = x19.some(); - Formula x12 = x18.forSome(x13); - Formula x9 = x12.forAll(x10); - Formula x24 = x5.some(); - Formula x23 = x24.not(); - Formula x28 = x5.eq(x5); - Formula x29 = x6.eq(x6); - Formula x25 = x28.and(x29); - Formula x22 = x23.and(x25); - Formula x8 = x9.and(x22).and(x5.no()).and(x6.no()); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(2); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(2); - - System.out.flush(); - - Solution sol = solver.solve(x8, bounds); - Instance inst = sol.instance(); - assertNotNull(inst); - - for (Relation rel : inst.relations()) { - if (rel != x5 && rel != x6) { - final TupleSet range = inst.tuples(x6).product(inst.tuples(x5)); - assertTrue(range.containsAll(inst.tuples(rel))); - } - } - } - - public final void testFelix_03062008() { - Relation x0 = Relation.unary("Int/min"); - Relation x1 = Relation.unary("Int/zero"); - Relation x2 = Relation.unary("Int/max"); - Relation x3 = Relation.nary("Int/next", 2); - Relation x4 = Relation.unary("seq/Int"); - - List atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("-8")); - bounds.boundExactly(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("0")); - bounds.boundExactly(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("7")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(2); - x3_upper.add(factory.tuple("-8").product(factory.tuple("-7"))); - x3_upper.add(factory.tuple("-7").product(factory.tuple("-6"))); - x3_upper.add(factory.tuple("-6").product(factory.tuple("-5"))); - x3_upper.add(factory.tuple("-5").product(factory.tuple("-4"))); - x3_upper.add(factory.tuple("-4").product(factory.tuple("-3"))); - x3_upper.add(factory.tuple("-3").product(factory.tuple("-2"))); - x3_upper.add(factory.tuple("-2").product(factory.tuple("-1"))); - x3_upper.add(factory.tuple("-1").product(factory.tuple("0"))); - x3_upper.add(factory.tuple("0").product(factory.tuple("1"))); - x3_upper.add(factory.tuple("1").product(factory.tuple("2"))); - x3_upper.add(factory.tuple("2").product(factory.tuple("3"))); - x3_upper.add(factory.tuple("3").product(factory.tuple("4"))); - x3_upper.add(factory.tuple("4").product(factory.tuple("5"))); - x3_upper.add(factory.tuple("5").product(factory.tuple("6"))); - x3_upper.add(factory.tuple("6").product(factory.tuple("7"))); - bounds.boundExactly(x3, x3_upper); - - TupleSet x4_upper = factory.noneOf(1); - x4_upper.add(factory.tuple("0")); - bounds.boundExactly(x4, x4_upper); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Variable x9 = Variable.unary("x"); - Decls x8 = x9.oneOf(Expression.INTS); - Variable x14 = Variable.unary("p_t'"); - Expression x15 = Expression.INTS.difference(x9); - Decls x13 = x14.oneOf(x15); - Variable x20 = Variable.unary("p_v"); - Decls x19 = x20.oneOf(Expression.INTS); - Formula x21 = x14.in(x9); - Expression x18 = x21.comprehension(x19); - IntExpression x17 = x18.count(); - IntExpression x22 = IntConstant.constant(0); - Formula x16 = x17.gt(x22); - Formula x12 = x16.forAll(x13); - Formula x11 = x12.not(); - Formula x7 = x11.forAll(x8); - Formula x25 = x0.eq(x0); - Formula x26 = x2.eq(x2); - Formula x24 = x25.and(x26); - Formula x27 = x3.eq(x3); - Formula x23 = x24.and(x27); - Formula x6 = x7.and(x23); - Formula x29 = x1.eq(x1); - Formula x30 = x4.eq(x4); - Formula x28 = x29.and(x30); - Formula x5 = x6.and(x28); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - // solver.options().setFlatten(false); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - - // System.out.println(PrettyPrinter.print(x5, 2)); - solver.options().setSkolemDepth(0); - Solution sol1 = solver.solve(x5, bounds); - assertNotNull(sol1.instance()); - - solver.options().setSkolemDepth(1); - Solution sol2 = solver.solve(x5, bounds); - assertNotNull(sol2.instance()); - } - - public final void testFelix_02222008() { - List atomlist = Arrays.asList("X1", "X2", "X3"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - Relation x = Relation.unary("X"); - TupleSet x_upper = factory.noneOf(1); - x_upper.add(factory.tuple("X1")); - x_upper.add(factory.tuple("X2")); - x_upper.add(factory.tuple("X3")); - bounds.bound(x, x_upper); - - Variable a = Variable.unary("a"); - Variable b = Variable.unary("b"); - Variable c = Variable.unary("c"); - Formula goal = x.lone().not().and(b.union(c).eq(a).forSome(c.oneOf(x)).forAll(b.oneOf(x)).forSome(a.setOf(x))); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(0); - solver.options().setSkolemDepth(2); - - Iterator itr = solver.solveAll(goal, bounds); - int sols = 0; - while (itr.hasNext()) { - Solution sol = itr.next(); - Instance inst = sol.instance(); - if (inst == null) - break; - sols++; - - for (Relation rel : inst.relations()) { - if (rel != x) { - if (rel.arity() == 1) { // rel = a - assertEquals(inst.tuples(x), inst.tuples(rel)); - } else { // rel = c - final TupleSet dom = factory.noneOf(1); - for (Tuple t : inst.tuples(rel)) { - dom.add(factory.tuple(t.atom(0))); - } - assertEquals(inst.tuples(x), dom); - } - } - } - } - assertEquals(3, sols); - } - - public final void testFelix_02212008() { - Relation x0 = Relation.unary("Int/min"); - Relation x1 = Relation.unary("Int/zero"); - Relation x2 = Relation.unary("Int/max"); - Relation x3 = Relation.nary("Int/next", 2); - Relation x4 = Relation.unary("seq/Int"); - - List atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("-8")); - bounds.boundExactly(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("0")); - bounds.boundExactly(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("7")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(2); - x3_upper.add(factory.tuple("-8").product(factory.tuple("-7"))); - x3_upper.add(factory.tuple("-7").product(factory.tuple("-6"))); - x3_upper.add(factory.tuple("-6").product(factory.tuple("-5"))); - x3_upper.add(factory.tuple("-5").product(factory.tuple("-4"))); - x3_upper.add(factory.tuple("-4").product(factory.tuple("-3"))); - x3_upper.add(factory.tuple("-3").product(factory.tuple("-2"))); - x3_upper.add(factory.tuple("-2").product(factory.tuple("-1"))); - x3_upper.add(factory.tuple("-1").product(factory.tuple("0"))); - x3_upper.add(factory.tuple("0").product(factory.tuple("1"))); - x3_upper.add(factory.tuple("1").product(factory.tuple("2"))); - x3_upper.add(factory.tuple("2").product(factory.tuple("3"))); - x3_upper.add(factory.tuple("3").product(factory.tuple("4"))); - x3_upper.add(factory.tuple("4").product(factory.tuple("5"))); - x3_upper.add(factory.tuple("5").product(factory.tuple("6"))); - x3_upper.add(factory.tuple("6").product(factory.tuple("7"))); - bounds.boundExactly(x3, x3_upper); - - TupleSet x4_upper = factory.noneOf(1); - x4_upper.add(factory.tuple("0")); - x4_upper.add(factory.tuple("1")); - x4_upper.add(factory.tuple("2")); - x4_upper.add(factory.tuple("3")); - bounds.boundExactly(x4, x4_upper); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Variable x9 = Variable.nary("isTree_r", 2); - Expression x10 = Expression.INTS.product(Expression.INTS); - Decls x8 = x9.setOf(x10); - Expression x15 = Expression.INTS.product(Expression.INTS); - Formula x14 = x9.in(x15); - Formula x13 = x14.and(Formula.TRUE); - Formula x12 = x13.and(Formula.TRUE); - Formula x7 = x12.forSome(x8); - Formula x19 = x0.eq(x0); - Formula x20 = x2.eq(x2); - Formula x18 = x19.and(x20); - Formula x21 = x3.eq(x3); - Formula x17 = x18.and(x21); - Formula x6 = x7.and(x17); - Formula x23 = x1.eq(x1); - Formula x24 = x4.eq(x4); - Formula x22 = x23.and(x24); - Formula x5 = x6.and(x22); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - - Iterator sols = solver.solveAll(x5, bounds); - assertTrue(sols.hasNext()); - Solution a = sols.next(); - assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, a.outcome()); - assertTrue(sols.hasNext()); - a = sols.next(); - assertEquals(Solution.Outcome.SATISFIABLE, a.outcome()); - - } - - public final void testFelix_11262007() { - Relation x6 = Relation.unary("R2"); - - List atomlist = Arrays.asList("X", "Y", "Z"); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - bounds.bound(x6, factory.allOf(1)); - - final Variable x32 = Variable.unary("a"); - final Decls x31 = x32.oneOf(x6); - - final Variable x36 = Variable.unary("b"); - final Decls x35 = x36.oneOf(x32.join(x6.product(x6))); - - final Formula x29 = x36.some().forSome(x35).forSome(x31); - - Solver solver = new Solver(); - - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - final Set decls = new LinkedHashSet(); - solver.options().setReporter(new AbstractReporter() { - - @Override - public void skolemizing(Decl decl, Relation skolem, List predecl) { - decls.add(decl); - } - }); - - Solution sol = solver.solve(x29, bounds); - assertEquals(2, decls.size()); - assertTrue(decls.contains(x31)); - assertTrue(decls.contains(x35)); - assertNotNull(sol.instance()); - - } - - public final void testFelix_11192007() { - List atomlist = Arrays.asList("A", "B", "C"); - - Universe universe = new Universe(atomlist); - - Bounds bounds = new Bounds(universe); - - Solver solver = new Solver(); - - solver.options().setLogTranslation(2); - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - solver.options().setSymmetryBreaking(20); - solver.options().setSkolemDepth(0); - - Solution sol = solver.solve(Formula.TRUE, bounds); - assertNotNull(sol.instance()); - } - - private static boolean isMinimal(Solver solver, Bounds bounds, Set core) { - final Set minCore = new LinkedHashSet(core); - for (Iterator itr = minCore.iterator(); itr.hasNext();) { - Formula f = itr.next(); - Formula noF = Formula.TRUE; - for (Formula f1 : minCore) { - if (f != f1) - noF = noF.and(f1); - } - if (solver.solve(noF, bounds).instance() == null) { - itr.remove(); - } - } - if (minCore.size() == core.size()) { - return true; - } else { - System.out.println("minimal core is: "); - for (Formula f : minCore) { - System.out.println(f); - } - System.out.println("found core is: "); - for (Formula f : core) { - System.out.println(f); - } - return false; - } - } - - public final void testFelix_05192007() { - Relation x5 = Relation.nary("this/de", 1); - Relation x6 = Relation.nary("this/dir", 1); - Relation x7 = Relation.nary("this/de.contents", 2); - Relation x8 = Relation.nary("this/dir.entries", 2); - Relation x9 = Relation.nary("this/dir.parent", 2); - - List atomlist = Arrays.asList("de[0]", "de[1]", "de[2]", "de[3]", "dir[0]", "dir[1]", "dir[2]", "dir[3]"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("de[0]")); - x5_upper.add(factory.tuple("de[1]")); - x5_upper.add(factory.tuple("de[2]")); - x5_upper.add(factory.tuple("de[3]")); - bounds.bound(x5, x5_upper); - - TupleSet x6_upper = factory.noneOf(1); - x6_upper.add(factory.tuple("dir[0]")); - x6_upper.add(factory.tuple("dir[1]")); - x6_upper.add(factory.tuple("dir[2]")); - x6_upper.add(factory.tuple("dir[3]")); - bounds.bound(x6, x6_upper); - - TupleSet x7_upper = factory.noneOf(2); - x7_upper.add(factory.tuple("de[0]").product(factory.tuple("dir[0]"))); - x7_upper.add(factory.tuple("de[0]").product(factory.tuple("dir[1]"))); - x7_upper.add(factory.tuple("de[0]").product(factory.tuple("dir[2]"))); - x7_upper.add(factory.tuple("de[0]").product(factory.tuple("dir[3]"))); - x7_upper.add(factory.tuple("de[1]").product(factory.tuple("dir[0]"))); - x7_upper.add(factory.tuple("de[1]").product(factory.tuple("dir[1]"))); - x7_upper.add(factory.tuple("de[1]").product(factory.tuple("dir[2]"))); - x7_upper.add(factory.tuple("de[1]").product(factory.tuple("dir[3]"))); - x7_upper.add(factory.tuple("de[2]").product(factory.tuple("dir[0]"))); - x7_upper.add(factory.tuple("de[2]").product(factory.tuple("dir[1]"))); - x7_upper.add(factory.tuple("de[2]").product(factory.tuple("dir[2]"))); - x7_upper.add(factory.tuple("de[2]").product(factory.tuple("dir[3]"))); - x7_upper.add(factory.tuple("de[3]").product(factory.tuple("dir[0]"))); - x7_upper.add(factory.tuple("de[3]").product(factory.tuple("dir[1]"))); - x7_upper.add(factory.tuple("de[3]").product(factory.tuple("dir[2]"))); - x7_upper.add(factory.tuple("de[3]").product(factory.tuple("dir[3]"))); - bounds.bound(x7, x7_upper); - - TupleSet x8_upper = factory.noneOf(2); - x8_upper.add(factory.tuple("dir[0]").product(factory.tuple("de[0]"))); - x8_upper.add(factory.tuple("dir[0]").product(factory.tuple("de[1]"))); - x8_upper.add(factory.tuple("dir[0]").product(factory.tuple("de[2]"))); - x8_upper.add(factory.tuple("dir[0]").product(factory.tuple("de[3]"))); - x8_upper.add(factory.tuple("dir[1]").product(factory.tuple("de[0]"))); - x8_upper.add(factory.tuple("dir[1]").product(factory.tuple("de[1]"))); - x8_upper.add(factory.tuple("dir[1]").product(factory.tuple("de[2]"))); - x8_upper.add(factory.tuple("dir[1]").product(factory.tuple("de[3]"))); - x8_upper.add(factory.tuple("dir[2]").product(factory.tuple("de[0]"))); - x8_upper.add(factory.tuple("dir[2]").product(factory.tuple("de[1]"))); - x8_upper.add(factory.tuple("dir[2]").product(factory.tuple("de[2]"))); - x8_upper.add(factory.tuple("dir[2]").product(factory.tuple("de[3]"))); - x8_upper.add(factory.tuple("dir[3]").product(factory.tuple("de[0]"))); - x8_upper.add(factory.tuple("dir[3]").product(factory.tuple("de[1]"))); - x8_upper.add(factory.tuple("dir[3]").product(factory.tuple("de[2]"))); - x8_upper.add(factory.tuple("dir[3]").product(factory.tuple("de[3]"))); - bounds.bound(x8, x8_upper); - - TupleSet x9_upper = factory.noneOf(2); - x9_upper.add(factory.tuple("dir[0]").product(factory.tuple("dir[0]"))); - x9_upper.add(factory.tuple("dir[0]").product(factory.tuple("dir[1]"))); - x9_upper.add(factory.tuple("dir[0]").product(factory.tuple("dir[2]"))); - x9_upper.add(factory.tuple("dir[0]").product(factory.tuple("dir[3]"))); - x9_upper.add(factory.tuple("dir[1]").product(factory.tuple("dir[0]"))); - x9_upper.add(factory.tuple("dir[1]").product(factory.tuple("dir[1]"))); - x9_upper.add(factory.tuple("dir[1]").product(factory.tuple("dir[2]"))); - x9_upper.add(factory.tuple("dir[1]").product(factory.tuple("dir[3]"))); - x9_upper.add(factory.tuple("dir[2]").product(factory.tuple("dir[0]"))); - x9_upper.add(factory.tuple("dir[2]").product(factory.tuple("dir[1]"))); - x9_upper.add(factory.tuple("dir[2]").product(factory.tuple("dir[2]"))); - x9_upper.add(factory.tuple("dir[2]").product(factory.tuple("dir[3]"))); - x9_upper.add(factory.tuple("dir[3]").product(factory.tuple("dir[0]"))); - x9_upper.add(factory.tuple("dir[3]").product(factory.tuple("dir[1]"))); - x9_upper.add(factory.tuple("dir[3]").product(factory.tuple("dir[2]"))); - x9_upper.add(factory.tuple("dir[3]").product(factory.tuple("dir[3]"))); - bounds.bound(x9, x9_upper); - - Expression x39 = x5.union(Expression.INTS); - Expression x38 = x6.union(x39); - Expression x37 = x38.product(Expression.UNIV); - Expression x35 = Expression.IDEN.intersection(x37); - Expression x34 = x35.intersection(x7); - Formula x33 = x34.no(); - Variable x44 = Variable.nary("functional_x", 1); - Decls x43 = x44.oneOf(x5); - Expression x48 = x44.join(x7); - Formula x47 = x48.lone(); - Formula x45 = Formula.TRUE.implies(x47); - Formula x42 = x45.forAll(x43); - Formula x32 = x33.and(x42); - Variable x51 = Variable.nary("total_x", 1); - Decls x50 = x51.oneOf(x5); - Expression x54 = x51.join(x7); - Formula x53 = x54.some(); - Formula x52 = Formula.TRUE.implies(x53); - Formula x49 = x52.forAll(x50); - Formula x31 = x32.and(x49); - Variable x57 = Variable.nary("injective_x", 1); - Decls x56 = x57.oneOf(x6); - Expression x60 = x7.join(x57); - Formula x59 = x60.lone(); - Formula x58 = Formula.TRUE.implies(x59); - Formula x55 = x58.forAll(x56); - Formula x30 = x31.and(x55); - Expression x63 = x7.join(x8); - Expression x62 = x63.transpose(); - Formula x61 = x62.in(x63); - Formula x29 = x30.and(x61); - Variable x66 = Variable.nary("acyclic_x", 1); - Decls x65 = x66.oneOf(x5); - Expression x72 = x7.join(x8); - Expression x71 = x72.closure(); - Expression x70 = x66.join(x71); - Formula x69 = x66.in(x70); - Formula x68 = x69.not(); - Formula x67 = Formula.TRUE.implies(x68); - Formula x64 = x67.forAll(x65); - Formula x28 = x29.and(x64); - Variable x75 = Variable.nary("surjective_x", 1); - Decls x74 = x75.oneOf(x5); - Expression x78 = x8.join(x75); - Formula x77 = x78.some(); - Formula x76 = Formula.TRUE.implies(x77); - Formula x73 = x76.forAll(x74); - Formula x27 = x28.and(x73); - Variable x81 = Variable.nary("functional_x", 1); - Decls x80 = x81.oneOf(x6); - Expression x84 = x81.join(x8); - Formula x83 = x84.lone(); - Formula x82 = Formula.TRUE.implies(x83); - Formula x79 = x82.forAll(x80); - Formula x26 = x27.and(x79); - Variable x87 = Variable.nary("acyclic_x", 1); - Decls x86 = x87.oneOf(x6); - Expression x93 = x8.join(x7); - Expression x92 = x93.closure(); - Expression x91 = x87.join(x92); - Formula x90 = x87.in(x91); - Formula x89 = x90.not(); - Formula x88 = Formula.TRUE.implies(x89); - Formula x85 = x88.forAll(x86); - Formula x25 = x26.and(x85); - Expression x96 = x9.transpose(); - Expression x95 = x96.intersection(x9); - Expression x98 = x38.product(Expression.UNIV); - Expression x97 = Expression.IDEN.intersection(x98); - Formula x94 = x95.in(x97); - Formula x24 = x25.and(x94); - Expression x102 = x38.product(Expression.UNIV); - Expression x101 = Expression.IDEN.intersection(x102); - Expression x100 = x101.intersection(x9); - Formula x99 = x100.no(); - Formula x23 = x24.and(x99); - Expression x106 = x38.product(Expression.UNIV); - Expression x105 = Expression.IDEN.intersection(x106); - Expression x104 = x105.intersection(x8); - Formula x103 = x104.no(); - Formula x22 = x23.and(x103); - Variable x109 = Variable.nary("injective_x", 1); - Decls x108 = x109.oneOf(x5); - Expression x112 = x8.join(x109); - Formula x111 = x112.lone(); - Formula x110 = Formula.TRUE.implies(x111); - Formula x107 = x110.forAll(x108); - Formula x21 = x22.and(x107); - Variable x115 = Variable.nary("acyclic_x", 1); - Decls x114 = x115.oneOf(x6); - Expression x120 = x9.closure(); - Expression x119 = x115.join(x120); - Formula x118 = x115.in(x119); - Formula x117 = x118.not(); - Formula x116 = Formula.TRUE.implies(x117); - Formula x113 = x116.forAll(x114); - Formula x20 = x21.and(x113); - Variable x123 = Variable.nary("functional_x", 1); - Decls x122 = x123.oneOf(x6); - Expression x126 = x123.join(x9); - Formula x125 = x126.lone(); - Formula x124 = Formula.TRUE.implies(x125); - Formula x121 = x124.forAll(x122); - Formula x19 = x20.and(x121); - Variable x129 = Variable.nary("injective_x", 1); - Decls x128 = x129.oneOf(x6); - Expression x132 = x9.join(x129); - Formula x131 = x132.lone(); - Formula x130 = Formula.TRUE.implies(x131); - Formula x127 = x130.forAll(x128); - Formula x18 = x19.and(x127); - Variable x137 = Variable.nary("rootedOne_root", 1); - Decls x136 = x137.oneOf(x6); - Variable x139 = Variable.nary("rootedOne_root", 1); - Decls x138 = x139.oneOf(x6); - Decls x135 = x136.and(x138); - Expression x146 = x9.closure(); - Expression x148 = x38.product(Expression.UNIV); - Expression x147 = Expression.IDEN.intersection(x148); - Expression x145 = x146.union(x147); - Expression x144 = x137.join(x145); - Formula x143 = x6.in(x144); - Expression x152 = x9.closure(); - Expression x154 = x38.product(Expression.UNIV); - Expression x153 = Expression.IDEN.intersection(x154); - Expression x151 = x152.union(x153); - Expression x150 = x139.join(x151); - Formula x149 = x6.in(x150); - Formula x142 = x143.and(x149); - Formula x156 = x137.eq(x139); - Formula x155 = x156.and(Formula.TRUE); - Formula x141 = x142.implies(x155); - Formula x140 = Formula.TRUE.implies(x141); - Formula x134 = x140.forAll(x135); - Variable x159 = Variable.nary("rootedOne_root", 1); - Decls x158 = x159.oneOf(x6); - Expression x164 = x9.closure(); - Expression x166 = x38.product(Expression.UNIV); - Expression x165 = Expression.IDEN.intersection(x166); - Expression x163 = x164.union(x165); - Expression x162 = x159.join(x163); - Formula x161 = x6.in(x162); - Formula x160 = Formula.TRUE.and(x161); - Formula x157 = x160.forSome(x158); - Formula x133 = x134.and(x157); - Formula x17 = x18.and(x133); - Variable x170 = Variable.nary("weaklyConnected_d", 1); - Decls x169 = x170.oneOf(x6); - Variable x172 = Variable.nary("weaklyConnected_g", 1); - Decls x171 = x172.oneOf(x6); - Decls x168 = x169.and(x171); - Formula x177 = x170.eq(x172); - Formula x176 = x177.not(); - Formula x175 = x176.not(); - Expression x182 = x9.transpose(); - Expression x181 = x9.union(x182); - Expression x180 = x181.closure(); - Expression x179 = x172.join(x180); - Formula x178 = x170.in(x179); - Formula x174 = x175.or(x178); - Formula x173 = Formula.TRUE.implies(x174); - Formula x167 = x173.forAll(x168); - Formula x16 = x17.and(x167); - Expression x187 = x8.join(x7); - Expression x188 = Expression.UNIV.product(x6); - Expression x186 = x187.intersection(x188); - Expression x185 = x9.union(x186); - Expression x184 = x185.transpose(); - Formula x183 = x184.in(x185); - Formula x15 = x16.and(x183); - Variable x191 = Variable.nary("inner_injective_x", 1); - Variable x197 = Variable.nary("ternary_a", 1); - Expression x198 = x7.join(x38); - Decls x196 = x197.oneOf(x198); - Variable x200 = Variable.nary("ternary_b", 1); - Expression x202 = x38.join(x7); - Expression x203 = x8.join(x38); - Expression x201 = x202.intersection(x203); - Decls x199 = x200.oneOf(x201); - Variable x205 = Variable.nary("ternary_c", 1); - Expression x206 = x38.join(x8); - Decls x204 = x205.oneOf(x206); - Decls x195 = x196.and(x199).and(x204); - Expression x209 = x197.product(x200); - Formula x208 = x209.in(x7); - Expression x211 = x200.product(x205); - Formula x210 = x211.in(x8); - Formula x207 = x208.and(x210); - Expression x194 = x207.comprehension(x195); - Expression x193 = x194.join(x38); - Expression x192 = x193.join(x38); - Decls x190 = x191.oneOf(x192); - Variable x215 = Variable.nary("injective_x", 1); - Expression x217 = x191.join(x194); - Expression x216 = x38.join(x217); - Decls x214 = x215.oneOf(x216); - Expression x221 = x191.join(x194); - Expression x220 = x221.join(x215); - Formula x219 = x220.lone(); - Formula x218 = Formula.TRUE.implies(x219); - Formula x213 = x218.forAll(x214); - Formula x212 = Formula.TRUE.implies(x213); - Formula x189 = x212.forAll(x190); - Formula x14 = x15.and(x189); - Variable x224 = Variable.nary("inner_injective_x", 1); - Variable x230 = Variable.nary("ternary_a", 1); - Expression x231 = x8.join(x38); - Decls x229 = x230.oneOf(x231); - Variable x233 = Variable.nary("ternary_b", 1); - Expression x235 = x38.join(x8); - Expression x236 = x7.join(x38); - Expression x234 = x235.intersection(x236); - Decls x232 = x233.oneOf(x234); - Variable x238 = Variable.nary("ternary_c", 1); - Expression x239 = x38.join(x7); - Decls x237 = x238.oneOf(x239); - Decls x228 = x229.and(x232).and(x237); - Expression x242 = x230.product(x233); - Formula x241 = x242.in(x8); - Expression x244 = x233.product(x238); - Formula x243 = x244.in(x7); - Formula x240 = x241.and(x243); - Expression x227 = x240.comprehension(x228); - Expression x226 = x227.join(x38); - Expression x225 = x226.join(x38); - Decls x223 = x224.oneOf(x225); - Variable x248 = Variable.nary("injective_x", 1); - Expression x250 = x224.join(x227); - Expression x249 = x38.join(x250); - Decls x247 = x248.oneOf(x249); - Expression x254 = x224.join(x227); - Expression x253 = x254.join(x248); - Formula x252 = x253.lone(); - Formula x251 = Formula.TRUE.implies(x252); - Formula x246 = x251.forAll(x247); - Formula x245 = Formula.TRUE.implies(x246); - Formula x222 = x245.forAll(x223); - Formula x13 = x14.and(x222); - Variable x259 = Variable.nary("rootedOne_root", 1); - Decls x258 = x259.oneOf(x6); - Variable x261 = Variable.nary("rootedOne_root", 1); - Decls x260 = x261.oneOf(x6); - Decls x257 = x258.and(x260); - Variable x272 = Variable.nary("rootedOne_a", 1); - Decls x271 = x272.oneOf(x6); - Variable x274 = Variable.nary("rootedOne_b", 1); - Decls x273 = x274.oneOf(x6); - Decls x270 = x271.and(x273); - Variable x277 = Variable.nary("rootedOne_c", 1); - Decls x276 = x277.oneOf(x38); - Expression x281 = x277.product(x274); - Expression x280 = x272.product(x281); - Variable x285 = Variable.nary("ternary_a", 1); - Expression x286 = x8.join(x38); - Decls x284 = x285.oneOf(x286); - Variable x288 = Variable.nary("ternary_b", 1); - Expression x290 = x38.join(x8); - Expression x291 = x7.join(x38); - Expression x289 = x290.intersection(x291); - Decls x287 = x288.oneOf(x289); - Variable x293 = Variable.nary("ternary_c", 1); - Expression x294 = x38.join(x7); - Decls x292 = x293.oneOf(x294); - Decls x283 = x284.and(x287).and(x292); - Expression x297 = x285.product(x288); - Formula x296 = x297.in(x8); - Expression x299 = x288.product(x293); - Formula x298 = x299.in(x7); - Formula x295 = x296.and(x298); - Expression x282 = x295.comprehension(x283); - Formula x279 = x280.in(x282); - Formula x278 = Formula.TRUE.and(x279); - Formula x275 = x278.forSome(x276); - Expression x269 = x275.comprehension(x270); - Expression x268 = x269.closure(); - Expression x301 = x38.product(Expression.UNIV); - Expression x300 = Expression.IDEN.intersection(x301); - Expression x267 = x268.union(x300); - Expression x266 = x259.join(x267); - Formula x265 = x6.in(x266); - Variable x309 = Variable.nary("rootedOne_a", 1); - Decls x308 = x309.oneOf(x6); - Variable x311 = Variable.nary("rootedOne_b", 1); - Decls x310 = x311.oneOf(x6); - Decls x307 = x308.and(x310); - Variable x314 = Variable.nary("rootedOne_c", 1); - Decls x313 = x314.oneOf(x38); - Expression x318 = x314.product(x311); - Expression x317 = x309.product(x318); - Formula x316 = x317.in(x282); - Formula x315 = Formula.TRUE.and(x316); - Formula x312 = x315.forSome(x313); - Expression x306 = x312.comprehension(x307); - Expression x305 = x306.closure(); - Expression x320 = x38.product(Expression.UNIV); - Expression x319 = Expression.IDEN.intersection(x320); - Expression x304 = x305.union(x319); - Expression x303 = x261.join(x304); - Formula x302 = x6.in(x303); - Formula x264 = x265.and(x302); - Formula x322 = x259.eq(x261); - Formula x321 = x322.and(Formula.TRUE); - Formula x263 = x264.implies(x321); - Formula x262 = Formula.TRUE.implies(x263); - Formula x256 = x262.forAll(x257); - Variable x325 = Variable.nary("rootedOne_root", 1); - Decls x324 = x325.oneOf(x6); - Variable x334 = Variable.nary("rootedOne_a", 1); - Decls x333 = x334.oneOf(x6); - Variable x336 = Variable.nary("rootedOne_b", 1); - Decls x335 = x336.oneOf(x6); - Decls x332 = x333.and(x335); - Variable x339 = Variable.nary("rootedOne_c", 1); - Decls x338 = x339.oneOf(x38); - Expression x343 = x339.product(x336); - Expression x342 = x334.product(x343); - Formula x341 = x342.in(x282); - Formula x340 = Formula.TRUE.and(x341); - Formula x337 = x340.forSome(x338); - Expression x331 = x337.comprehension(x332); - Expression x330 = x331.closure(); - Expression x345 = x38.product(Expression.UNIV); - Expression x344 = Expression.IDEN.intersection(x345); - Expression x329 = x330.union(x344); - Expression x328 = x325.join(x329); - Formula x327 = x6.in(x328); - Formula x326 = Formula.TRUE.and(x327); - Formula x323 = x326.forSome(x324); - Formula x255 = x256.and(x323); - Formula x12 = x13.and(x255); - Expression x348 = x9.join(x9); - Formula x347 = x348.in(x9); - Formula x346 = x347.not(); - Formula x11 = x12.and(x346); - Expression x352 = x6.product(x6); - Formula x351 = x9.in(x352); - Expression x355 = x6.product(x5); - Formula x354 = x8.in(x355); - Expression x359 = x5.product(x6); - Formula x358 = x7.in(x359); - Formula x363 = Formula.TRUE.and(Formula.TRUE); - Formula x362 = Formula.TRUE.and(x363); - Formula x361 = Formula.TRUE.and(x362); - Formula x360 = Formula.TRUE.and(x361); - Formula x357 = x358.and(x360); - Formula x356 = Formula.TRUE.and(x357); - Formula x353 = x354.and(x356); - Formula x350 = x351.and(x353); - Formula x349 = Formula.TRUE.and(x350); - Formula x10 = x11.and(x349); - - Solver solver = new Solver(); - solver.options().setLogTranslation(1); - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - Solution sol = solver.solve(x10, bounds); - // System.out.println(sol.toString()); - Proof proof = sol.proof(); - proof.minimize(new RCEStrategy(proof.log())); - Set core = Nodes.minRoots(x10, sol.proof().highLevelCore().values()); - - // final Set minCore = new LinkedHashSet(core); - // for(Iterator itr = minCore.iterator(); itr.hasNext();) { - // Formula f = itr.next(); - // Formula noF = Formula.TRUE; - // for( Formula f1 : minCore ) { - // if (f!=f1) - // noF = noF.and(f1); - // } - // if (solver.solve(noF, bounds).instance()==null) { - // itr.remove(); - // } - // } - // assertTrue(minCore.size()==core.size()); - assertTrue(isMinimal(solver, bounds, core)); - } - - public final void testFelix_05152007_3() { - Relation x5 = Relation.nary("A", 1); - - List atomlist = Arrays.asList("A[0]", "A[1]", "A[2]"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("A[0]")); - x5_upper.add(factory.tuple("A[1]")); - x5_upper.add(factory.tuple("A[2]")); - - bounds.bound(x5, x5_upper); - - Formula a = x5.some(); - Formula a1 = x5.no(); - Formula b = a1.and(Formula.TRUE.and(Formula.TRUE)); - Formula c = a.and(b); - - Solver solver = new Solver(); - - solver.options().setLogTranslation(1); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - - Solution sol = solver.solve(c, bounds); - Set core = Nodes.minRoots(c, sol.proof().highLevelCore().values()); - - assertEquals(2, core.size()); - assertTrue(core.contains(a)); - assertTrue(core.contains(a1)); - - } - - public final void testFelix_05152007_2() { - Relation x5 = Relation.nary("A", 1); - - List atomlist = Arrays.asList("A0", "A1", "A2"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - - Bounds bounds = new Bounds(universe); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("A2")); - x5_upper.add(factory.tuple("A1")); - x5_upper.add(factory.tuple("A0")); - - bounds.bound(x5, x5_upper); - - Formula x7 = x5.eq(x5).not(); - - Solver solver = new Solver(); - - solver.options().setLogTranslation(1); - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - - Solution sol = solver.solve(x7, bounds); - Set core = Nodes.minRoots(x7, sol.proof().highLevelCore().values()); - assertEquals(1, core.size()); - assertTrue(core.contains(x7)); - } - - public final void testFelix_05152007_1() { - Relation x5 = Relation.nary("A", 1); - - List atomlist = Arrays.asList("A0", "A1", "A2"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("A2")); - x5_upper.add(factory.tuple("A1")); - x5_upper.add(factory.tuple("A0")); - - bounds.bound(x5, x5_upper); - - Formula x7 = x5.some(); - Formula x8 = x5.no(); - - Formula x6 = x7.and(x8); - - Solver solver = new Solver(); - solver.options().setLogTranslation(1); - - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - - Solution sol = solver.solve(x6, bounds); - - // System.out.println("Sol="+sol); - - Set core = Nodes.minRoots(x6, sol.proof().highLevelCore().values()); - assertEquals(2, core.size()); - assertTrue(core.contains(x7)); - assertTrue(core.contains(x8)); - - } - - public final void testMana_01312007() { - final Relation A = Relation.unary("A"); - final Relation first1 = Relation.unary("first1"); - final Relation first2 = Relation.unary("first2"); - final Relation last1 = Relation.unary("last1"); - final Relation last2 = Relation.unary("last2"); - final Relation next1 = Relation.binary("next1"); - final Relation next2 = Relation.binary("next2"); - - final Formula f0 = next1.totalOrder(A, first1, last1); - final Formula f1 = next2.totalOrder(A, first2, last2); - final Formula f2 = first1.eq(last2); - - final Formula f3 = f0.and(f1).and(f2); - - final Universe u = new Universe(Arrays.asList("a0", "a1", "a2")); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - - b.bound(A, f.allOf(1)); - b.bound(first1, f.allOf(1)); - b.bound(first2, f.allOf(1)); - b.bound(last1, f.allOf(1)); - b.bound(last2, f.allOf(1)); - b.bound(next1, f.allOf(2)); - b.bound(next2, f.allOf(2)); - - final Solver solver = new Solver(); - final Solution sol = solver.solve(f3, b); - - assertEquals(Solution.Outcome.SATISFIABLE, sol.outcome()); - } - - public final void testFelix_01132007() { - // Relation x1 = Relation.nary("A",1); - // List atomlist = Arrays.asList("A0", "A1", "A2"); - // - // Universe universe = new Universe(atomlist); - // TupleFactory factory = universe.factory(); - // Bounds bounds = new Bounds(universe); - // - // TupleSet x1_upper = factory.noneOf(1); - // - // x1_upper.add(factory.tuple("A0")); - // x1_upper.add(factory.tuple("A1")); - // x1_upper.add(factory.tuple("A2")); - // - // bounds.bound(x1, x1_upper); - // Solver solver = new Solver(); - // - // solver.options().setSolver(SATFactory.MiniSat); - // solver.options().setSymmetryBreaking(0); - // Iterator sols = solver.solveAll(Formula.TRUE, bounds); - // int i = 0; - // while (sols.hasNext() && i < 9) { - // System.out.println("Solution"+i+": " + sols.next().instance()); - // i++; - // } - - } - - public final void testFelix_01062007() { - Relation x1 = Relation.nary("A", 1); - List atomlist = Arrays.asList("A"); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("A")); - bounds.bound(x1, x1_upper); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - - Iterator sols = solver.solveAll(Formula.TRUE, bounds); - assertNotNull(sols.next().instance()); - - assertNotNull(sols.next().instance()); - - assertNull(sols.next().instance()); - - // Solution sol1=sols.next(); - // System.out.println("Solution1:"+sol1.instance()); - // - // Solution sol2=sols.next(); - // System.out.println("Solution2:"+sol2.instance()); - // - // Solution sol3=sols.next(); - // System.out.println("Solution3:"+sol3.instance()); - - } - - public final void testFelix_01032007() { - List atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Expression set = IntConstant.constant(8).toExpression(); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - Solution sol = solver.solve(set.some(), bounds); - - assertNotNull("expected SATISFIABLE but was " + sol.outcome(), sol.instance()); - - Evaluator eval = new Evaluator(sol.instance(), solver.options()); - TupleSet ts = eval.evaluate(set); - assertFalse(ts.size() == 0); - - } - - public final void testFelix_11122006() { - Relation x0 = Relation.nary("Q", 1); - Relation x1 = Relation.nary("B", 1); - Relation x2 = Relation.nary("A", 1); - Relation x3 = Relation.nary("QQ", 3); - - List atomlist = Arrays.asList("A", "B", "Q"); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("Q")); - bounds.boundExactly(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("B")); - bounds.boundExactly(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("A")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(3); - x3_upper.add(factory.tuple("Q").product(factory.tuple("A")).product(factory.tuple("A"))); - x3_upper.add(factory.tuple("Q").product(factory.tuple("B")).product(factory.tuple("B"))); - bounds.bound(x3, x3_upper); - - Expression x7 = x2.product(x2); - Expression x8 = x0.join(x3); - Formula x6 = x7.in(x8); - Formula x5 = x6.not(); - - Expression x18 = x1.product(x1); - Expression x17 = x7.union(x18); - Expression x16 = x0.product(x17); - - Formula x15 = x3.in(x16); - Formula x4 = x5.and(x15); - - Solver solver = new Solver(); - - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - - // System.out.println(bounds); - // System.out.println(x4); - Solution sol = solver.solve(x4, bounds); - assertEquals(sol.outcome(), Solution.Outcome.SATISFIABLE); - // System.out.println(sol.toString()); - } - - public final void testFelix_10182006() { - // (some x: one { y: one SIG | true } | true) - Relation sig = Relation.unary("SIG"); - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - final Expression e0 = Formula.TRUE.comprehension(y.oneOf(sig)); - final Formula f0 = Formula.TRUE.forSome(x.oneOf(e0)); - final Universe u = new Universe(Arrays.asList("a0")); - final Bounds bounds = new Bounds(u); - bounds.bound(sig, u.factory().allOf(1)); - final Solution s = solver.solve(f0, bounds); - assertEquals(Solution.Outcome.SATISFIABLE, s.outcome()); - } - - public final void testEmina_10092006() { - Relation r = Relation.ternary("r"); - final Variable a = Variable.unary("A"); - final Variable b = Variable.unary("B"); - final Variable c = Variable.unary("C"); - final Variable d = Variable.unary("D"); - final Formula f0 = (b.join(a.join(r))).eq(d.join(c.join(r))); - final Formula f1 = a.in(c).and(b.in(d)); - final Formula f = f0.implies(f1).forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV)).and(d.oneOf(UNIV))); - final Universe u = new Universe(Arrays.asList("a0", "a1")); - final Bounds bounds = new Bounds(u); - bounds.bound(r, u.factory().allOf(3)); - // System.out.println(f); System.out.println(bounds); - solver.options().setSymmetryBreaking(0); - // solver.options().setFlatten(false); - final Solution s = solver.solve(f, bounds); - // System.out.println(s); - assertEquals(Solution.Outcome.SATISFIABLE, s.outcome()); - } - - public final void testFelix_08142006() { - Relation x0 = Relation.nary("/nodeOrd/Ord", 1); - Relation x1 = Relation.nary("/msg/ord/Ord", 1); - Relation x2 = Relation.nary("/msg/Tick", 1); - Relation x3 = Relation.nary("/bool/False", 1); - Relation x4 = Relation.nary("/bool/True", 1); - Relation x5 = Relation.nary("/bool/Bool", 1); - Relation x6 = Relation.nary("/RingLeadNodeState", 1); - Relation x7 = Relation.nary("/msg/NodeState", 1); - Relation x8 = Relation.nary("/MsgViz", 1); - Relation x9 = Relation.nary("/msg/Msg", 1); - Relation x10 = Relation.nary("/RingLeadMsgState", 1); - Relation x11 = Relation.nary("/msg/MsgState", 1); - Relation x12 = Relation.nary("/RingLeadNode", 1); - Relation x13 = Relation.nary("/msg/Node", 1); - Relation x14 = Relation.nary("/RingLeadNode.rightNeighbor", 2); - Relation x15 = Relation.nary("/msg/MsgState.from", 2); - Relation x16 = Relation.nary("/msg/MsgState.to", 2); - Relation x17 = Relation.nary("/RingLeadMsgState.id", 2); - Relation x18 = Relation.nary("/msg/Msg.state", 2); - Relation x19 = Relation.nary("/msg/Msg.sentOn", 2); - Relation x20 = Relation.nary("/msg/Msg.readOn", 3); - Relation x21 = Relation.nary("/MsgViz.vFrom", 2); - Relation x22 = Relation.nary("/MsgViz.vTo", 2); - Relation x23 = Relation.nary("/MsgViz.vId", 2); - Relation x24 = Relation.nary("/RingLeadNodeState.leader", 2); - Relation x25 = Relation.nary("/msg/Tick.state", 3); - Relation x26 = Relation.nary("/msg/Tick.visible", 3); - Relation x27 = Relation.nary("/msg/Tick.read", 3); - Relation x28 = Relation.nary("/msg/Tick.sent", 3); - Relation x29 = Relation.nary("/msg/Tick.available", 2); - Relation x30 = Relation.nary("/msg/Tick.needsToSend", 3); - - Relation x31 = Relation.nary("first_", 1); - Relation x32 = Relation.nary("last_", 1); - Relation x33 = Relation.nary("next_", 2); - Relation x34 = Relation.nary("first_", 1); - Relation x35 = Relation.nary("last_", 1); - Relation x36 = Relation.nary("next_", 2); - - String[] atoms = { - "-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7", "Bool.0", "Bool.1", "Msg.0", "MsgState.0", "Node.0", "NodeState.0", "NodeState.1", "Ord.0", "Ord.1", "Tick.0", "Tick.1", "Tick.2" - }; - - java.util.ArrayList atomlist = new java.util.ArrayList(); - for (String a : atoms) - atomlist.add(a); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - TupleSet x0_upper = factory.noneOf(1); - x0_upper.add(factory.tuple("Ord.1")); - bounds.bound(x0, x0_upper); - - TupleSet x1_upper = factory.noneOf(1); - x1_upper.add(factory.tuple("Ord.0")); - bounds.bound(x1, x1_upper); - - TupleSet x2_upper = factory.noneOf(1); - x2_upper.add(factory.tuple("Tick.0")); - x2_upper.add(factory.tuple("Tick.1")); - x2_upper.add(factory.tuple("Tick.2")); - bounds.boundExactly(x2, x2_upper); - - TupleSet x3_upper = factory.noneOf(1); - x3_upper.add(factory.tuple("Bool.1")); - bounds.bound(x3, x3_upper); - - TupleSet x4_upper = factory.noneOf(1); - x4_upper.add(factory.tuple("Bool.0")); - bounds.bound(x4, x4_upper); - - TupleSet x5_upper = factory.noneOf(1); - x5_upper.add(factory.tuple("Bool.0")); - x5_upper.add(factory.tuple("Bool.1")); - bounds.bound(x5, x5_upper); - - TupleSet x6_upper = factory.noneOf(1); - x6_upper.add(factory.tuple("NodeState.0")); - x6_upper.add(factory.tuple("NodeState.1")); - bounds.bound(x6, x6_upper); - - TupleSet x7_upper = factory.noneOf(1); - x7_upper.add(factory.tuple("NodeState.0")); - x7_upper.add(factory.tuple("NodeState.1")); - bounds.bound(x7, x7_upper); - - TupleSet x8_upper = factory.noneOf(1); - x8_upper.add(factory.tuple("Msg.0")); - bounds.bound(x8, x8_upper); - - TupleSet x9_upper = factory.noneOf(1); - x9_upper.add(factory.tuple("Msg.0")); - bounds.bound(x9, x9_upper); - - TupleSet x10_upper = factory.noneOf(1); - x10_upper.add(factory.tuple("MsgState.0")); - bounds.bound(x10, x10_upper); - - TupleSet x11_upper = factory.noneOf(1); - x11_upper.add(factory.tuple("MsgState.0")); - bounds.bound(x11, x11_upper); - - TupleSet x12_upper = factory.noneOf(1); - x12_upper.add(factory.tuple("Node.0")); - bounds.bound(x12, x12_upper); - - TupleSet x13_upper = factory.noneOf(1); - x13_upper.add(factory.tuple("Node.0")); - bounds.boundExactly(x13, x13_upper); - - TupleSet x14_upper = factory.noneOf(2); - x14_upper.add(factory.tuple("Node.0").product(factory.tuple("Node.0"))); - bounds.bound(x14, x14_upper); - - TupleSet x15_upper = factory.noneOf(2); - x15_upper.add(factory.tuple("MsgState.0").product(factory.tuple("Node.0"))); - bounds.bound(x15, x15_upper); - - TupleSet x16_upper = factory.noneOf(2); - x16_upper.add(factory.tuple("MsgState.0").product(factory.tuple("Node.0"))); - bounds.bound(x16, x16_upper); - - TupleSet x17_upper = factory.noneOf(2); - x17_upper.add(factory.tuple("MsgState.0").product(factory.tuple("Node.0"))); - bounds.bound(x17, x17_upper); - - TupleSet x18_upper = factory.noneOf(2); - x18_upper.add(factory.tuple("Msg.0").product(factory.tuple("MsgState.0"))); - bounds.bound(x18, x18_upper); - - TupleSet x19_upper = factory.noneOf(2); - x19_upper.add(factory.tuple("Msg.0").product(factory.tuple("Tick.0"))); - x19_upper.add(factory.tuple("Msg.0").product(factory.tuple("Tick.1"))); - x19_upper.add(factory.tuple("Msg.0").product(factory.tuple("Tick.2"))); - bounds.bound(x19, x19_upper); - - TupleSet x20_upper = factory.noneOf(3); - x20_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")).product(factory.tuple("Tick.0"))); - x20_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")).product(factory.tuple("Tick.1"))); - x20_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")).product(factory.tuple("Tick.2"))); - bounds.bound(x20, x20_upper); - - TupleSet x21_upper = factory.noneOf(2); - x21_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0"))); - bounds.bound(x21, x21_upper); - - TupleSet x22_upper = factory.noneOf(2); - x22_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0"))); - bounds.bound(x22, x22_upper); - - TupleSet x23_upper = factory.noneOf(2); - x23_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0"))); - bounds.bound(x23, x23_upper); - - TupleSet x24_upper = factory.noneOf(2); - x24_upper.add(factory.tuple("NodeState.0").product(factory.tuple("Bool.0"))); - x24_upper.add(factory.tuple("NodeState.0").product(factory.tuple("Bool.1"))); - x24_upper.add(factory.tuple("NodeState.1").product(factory.tuple("Bool.0"))); - x24_upper.add(factory.tuple("NodeState.1").product(factory.tuple("Bool.1"))); - bounds.bound(x24, x24_upper); - - TupleSet x25_upper = factory.noneOf(3); - x25_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.0"))); - x25_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.1"))); - x25_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.0"))); - x25_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.1"))); - x25_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.0"))); - x25_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.1"))); - bounds.bound(x25, x25_upper); - - TupleSet x26_upper = factory.noneOf(3); - x26_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x26_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x26_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - bounds.bound(x26, x26_upper); - - TupleSet x27_upper = factory.noneOf(3); - x27_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x27_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x27_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - bounds.bound(x27, x27_upper); - - TupleSet x28_upper = factory.noneOf(3); - x28_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x28_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x28_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - bounds.bound(x28, x28_upper); - - TupleSet x29_upper = factory.noneOf(2); - x29_upper.add(factory.tuple("Tick.0").product(factory.tuple("Msg.0"))); - x29_upper.add(factory.tuple("Tick.1").product(factory.tuple("Msg.0"))); - x29_upper.add(factory.tuple("Tick.2").product(factory.tuple("Msg.0"))); - bounds.bound(x29, x29_upper); - - TupleSet x30_upper = factory.noneOf(3); - x30_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x30_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - x30_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0"))); - bounds.bound(x30, x30_upper); - - TupleSet x31_upper = factory.noneOf(1); - x31_upper.add(factory.tuple("Tick.0")); - x31_upper.add(factory.tuple("Tick.1")); - x31_upper.add(factory.tuple("Tick.2")); - bounds.bound(x31, x31_upper); - - TupleSet x32_upper = factory.noneOf(1); - x32_upper.add(factory.tuple("Tick.0")); - x32_upper.add(factory.tuple("Tick.1")); - x32_upper.add(factory.tuple("Tick.2")); - bounds.bound(x32, x32_upper); - - TupleSet x33_upper = factory.noneOf(2); - x33_upper.add(factory.tuple("Tick.0").product(factory.tuple("Tick.0"))); - x33_upper.add(factory.tuple("Tick.0").product(factory.tuple("Tick.1"))); - x33_upper.add(factory.tuple("Tick.0").product(factory.tuple("Tick.2"))); - x33_upper.add(factory.tuple("Tick.1").product(factory.tuple("Tick.0"))); - x33_upper.add(factory.tuple("Tick.1").product(factory.tuple("Tick.1"))); - x33_upper.add(factory.tuple("Tick.1").product(factory.tuple("Tick.2"))); - x33_upper.add(factory.tuple("Tick.2").product(factory.tuple("Tick.0"))); - x33_upper.add(factory.tuple("Tick.2").product(factory.tuple("Tick.1"))); - x33_upper.add(factory.tuple("Tick.2").product(factory.tuple("Tick.2"))); - bounds.bound(x33, x33_upper); - - TupleSet x34_upper = factory.noneOf(1); - x34_upper.add(factory.tuple("Node.0")); - bounds.bound(x34, x34_upper); - - TupleSet x35_upper = factory.noneOf(1); - x35_upper.add(factory.tuple("Node.0")); - bounds.bound(x35, x35_upper); - - TupleSet x36_upper = factory.noneOf(2); - x36_upper.add(factory.tuple("Node.0").product(factory.tuple("Node.0"))); - bounds.bound(x36, x36_upper); - - bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); - - bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); - - bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); - - bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); - - bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); - - bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); - - bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - - bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - - bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - - bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - - bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); - - bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); - - bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); - - bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); - - bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); - - bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); - - Variable x41 = Variable.nary("@t", 1); - Expression x44 = x1.product(x32); - Expression x43 = x1.join(x44); - Expression x42 = x2.difference(x43); - Decls x40 = x41.oneOf(x42); - Expression x48 = x41.join(x25); - Expression x49 = x43.join(x25); - Formula x47 = x48.eq(x49); - Variable x52 = Variable.nary("@r", 2); - Variable x59 = Variable.nary("VAR", 1); - Decls x58 = x59.oneOf(x9); - Expression x61 = x59.join(x19); - Expression x65 = x1.product(x33); - Expression x64 = x1.join(x65); - Expression x63 = x64.closure(); - Expression x62 = x41.join(x63); - Formula x60 = x61.in(x62); - Expression x57 = x60.comprehension(x58); - Expression x56 = x9.difference(x57); - Variable x68 = Variable.nary("VAR", 1); - Decls x67 = x68.oneOf(x9); - Variable x71 = Variable.nary("@n", 1); - Expression x73 = x68.join(x18); - Expression x72 = x73.join(x16); - Decls x70 = x71.oneOf(x72); - Expression x76 = x68.join(x20); - Expression x75 = x71.join(x76); - Expression x81 = x33.transpose(); - Expression x80 = x1.product(x81); - Expression x79 = x1.join(x80); - Expression x78 = x79.closure(); - Expression x77 = x41.join(x78); - Formula x74 = x75.in(x77); - Formula x69 = x74.forAll(x70); - Expression x66 = x69.comprehension(x67); - Expression x55 = x56.difference(x66); - Expression x83 = x41.join(x26); - Expression x82 = x13.join(x83); - Expression x54 = x55.difference(x82); - Variable x89 = Variable.nary("VAR", 1); - Decls x88 = x89.oneOf(x9); - Expression x91 = x89.join(x19); - Expression x92 = x43.join(x63); - Formula x90 = x91.in(x92); - Expression x87 = x90.comprehension(x88); - Expression x86 = x9.difference(x87); - Variable x95 = Variable.nary("VAR", 1); - Decls x94 = x95.oneOf(x9); - Variable x98 = Variable.nary("@n", 1); - Expression x100 = x95.join(x18); - Expression x99 = x100.join(x16); - Decls x97 = x98.oneOf(x99); - Expression x103 = x95.join(x20); - Expression x102 = x98.join(x103); - Expression x104 = x43.join(x78); - Formula x101 = x102.in(x104); - Formula x96 = x101.forAll(x97); - Expression x93 = x96.comprehension(x94); - Expression x85 = x86.difference(x93); - Expression x106 = x43.join(x26); - Expression x105 = x13.join(x106); - Expression x84 = x85.difference(x105); - Expression x53 = x54.product(x84); - Decls x51 = x52.setOf(x53); - Variable x117 = Variable.nary("VAR", 1); - Decls x116 = x117.oneOf(x9); - Expression x119 = x117.join(x19); - Formula x118 = x119.in(x62); - Expression x115 = x118.comprehension(x116); - Expression x114 = x9.difference(x115); - Variable x122 = Variable.nary("VAR", 1); - Decls x121 = x122.oneOf(x9); - Variable x125 = Variable.nary("@n", 1); - Expression x127 = x122.join(x18); - Expression x126 = x127.join(x16); - Decls x124 = x125.oneOf(x126); - Expression x130 = x122.join(x20); - Expression x129 = x125.join(x130); - Formula x128 = x129.in(x77); - Formula x123 = x128.forAll(x124); - Expression x120 = x123.comprehension(x121); - Expression x113 = x114.difference(x120); - Expression x112 = x113.difference(x82); - Variable x136 = Variable.nary("VAR", 1); - Decls x135 = x136.oneOf(x9); - Expression x138 = x136.join(x19); - Formula x137 = x138.in(x92); - Expression x134 = x137.comprehension(x135); - Expression x133 = x9.difference(x134); - Variable x141 = Variable.nary("VAR", 1); - Decls x140 = x141.oneOf(x9); - Variable x144 = Variable.nary("@n", 1); - Expression x146 = x141.join(x18); - Expression x145 = x146.join(x16); - Decls x143 = x144.oneOf(x145); - Expression x149 = x141.join(x20); - Expression x148 = x144.join(x149); - Formula x147 = x148.in(x104); - Formula x142 = x147.forAll(x143); - Expression x139 = x142.comprehension(x140); - Expression x132 = x133.difference(x139); - Expression x131 = x132.difference(x105); - Expression x111 = x112.product(x131); - Formula x110 = x52.in(x111); - Variable x152 = Variable.nary("@", 1); - Variable x158 = Variable.nary("VAR", 1); - Decls x157 = x158.oneOf(x9); - Expression x160 = x158.join(x19); - Formula x159 = x160.in(x62); - Expression x156 = x159.comprehension(x157); - Expression x155 = x9.difference(x156); - Variable x163 = Variable.nary("VAR", 1); - Decls x162 = x163.oneOf(x9); - Variable x166 = Variable.nary("@n", 1); - Expression x168 = x163.join(x18); - Expression x167 = x168.join(x16); - Decls x165 = x166.oneOf(x167); - Expression x171 = x163.join(x20); - Expression x170 = x166.join(x171); - Formula x169 = x170.in(x77); - Formula x164 = x169.forAll(x165); - Expression x161 = x164.comprehension(x162); - Expression x154 = x155.difference(x161); - Expression x153 = x154.difference(x82); - Decls x151 = x152.oneOf(x153); - Expression x174 = x152.join(x52); - Formula x173 = x174.one(); - Variable x181 = Variable.nary("VAR", 1); - Decls x180 = x181.oneOf(x9); - Expression x183 = x181.join(x19); - Formula x182 = x183.in(x92); - Expression x179 = x182.comprehension(x180); - Expression x178 = x9.difference(x179); - Variable x186 = Variable.nary("VAR", 1); - Decls x185 = x186.oneOf(x9); - Variable x189 = Variable.nary("@n", 1); - Expression x191 = x186.join(x18); - Expression x190 = x191.join(x16); - Decls x188 = x189.oneOf(x190); - Expression x194 = x186.join(x20); - Expression x193 = x189.join(x194); - Formula x192 = x193.in(x104); - Formula x187 = x192.forAll(x188); - Expression x184 = x187.comprehension(x185); - Expression x177 = x178.difference(x184); - Expression x176 = x177.difference(x105); - Formula x175 = x174.in(x176); - Formula x172 = x173.and(x175); - Formula x150 = x172.forAll(x151); - Formula x109 = x110.and(x150); - Variable x197 = Variable.nary("@", 1); - Decls x196 = x197.oneOf(x176); - Expression x200 = x52.join(x197); - Formula x199 = x200.one(); - Formula x201 = x200.in(x153); - Formula x198 = x199.and(x201); - Formula x195 = x198.forAll(x196); - Formula x108 = x109.and(x195); - Variable x204 = Variable.nary("@m1", 1); - Expression x205 = x52.join(Expression.UNIV); - Decls x203 = x204.oneOf(x205); - Expression x209 = x9.product(Expression.UNIV); - Expression x208 = x209.intersection(x18); - Expression x207 = x204.join(x208); - Expression x211 = x204.join(x52); - Expression x210 = x211.join(x18); - Formula x206 = x207.eq(x210); - Formula x202 = x206.forAll(x203); - Formula x107 = x108.and(x202); - Formula x50 = x107.forSome(x51); - Formula x46 = x47.and(x50); - Variable x214 = Variable.nary("@r", 2); - Expression x215 = x82.product(x105); - Decls x213 = x214.setOf(x215); - Formula x219 = x214.in(x215); - Variable x222 = Variable.nary("@", 1); - Decls x221 = x222.oneOf(x82); - Expression x225 = x222.join(x214); - Formula x224 = x225.one(); - Formula x226 = x225.in(x105); - Formula x223 = x224.and(x226); - Formula x220 = x223.forAll(x221); - Formula x218 = x219.and(x220); - Variable x229 = Variable.nary("@", 1); - Decls x228 = x229.oneOf(x105); - Expression x232 = x214.join(x229); - Formula x231 = x232.one(); - Formula x233 = x232.in(x82); - Formula x230 = x231.and(x233); - Formula x227 = x230.forAll(x228); - Formula x217 = x218.and(x227); - Variable x236 = Variable.nary("@m1", 1); - Expression x237 = x214.join(Expression.UNIV); - Decls x235 = x236.oneOf(x237); - Expression x239 = x236.join(x208); - Expression x241 = x236.join(x214); - Expression x240 = x241.join(x18); - Formula x238 = x239.eq(x240); - Formula x234 = x238.forAll(x235); - Formula x216 = x217.and(x234); - Formula x212 = x216.forSome(x213); - Formula x45 = x46.and(x212); - Formula x39 = x45.forSome(x40); - Variable x244 = Variable.nary("@t", 1); - Decls x243 = x244.oneOf(x2); - Variable x248 = Variable.nary("@n", 1); - Decls x247 = x248.oneOf(x13); - Expression x252 = x244.join(x25); - Expression x251 = x248.join(x252); - Expression x250 = x251.join(x24); - Formula x249 = x250.eq(x4); - Formula x246 = x249.forSome(x247); - Formula x245 = x246.not(); - Formula x242 = x245.forAll(x243); - Formula x38 = x39.and(x242); - Variable x256 = Variable.nary("@this", 1); - Decls x255 = x256.oneOf(x2); - Expression x260 = x256.join(x25); - Expression x261 = x13.product(x7); - Formula x259 = x260.in(x261); - Variable x264 = Variable.nary("@", 1); - Decls x263 = x264.oneOf(x13); - Expression x267 = x264.join(x260); - Formula x266 = x267.one(); - Formula x268 = x267.in(x7); - Formula x265 = x266.and(x268); - Formula x262 = x265.forAll(x263); - Formula x258 = x259.and(x262); - Variable x271 = Variable.nary("@", 1); - Decls x270 = x271.oneOf(x7); - Expression x273 = x260.join(x271); - Formula x272 = x273.in(x13); - Formula x269 = x272.forAll(x270); - Formula x257 = x258.and(x269); - Formula x254 = x257.forAll(x255); - Expression x277 = x13.product(x9); - Expression x276 = x2.product(x277); - Formula x275 = x30.in(x276); - Expression x280 = x2.product(x9); - Formula x279 = x29.in(x280); - Formula x282 = x28.in(x276); - Formula x284 = x27.in(x276); - Formula x286 = x26.in(x276); - Expression x290 = x2.product(Expression.UNIV); - Expression x289 = x290.product(Expression.UNIV); - Formula x288 = x25.in(x289); - Variable x294 = Variable.nary("@this", 1); - Decls x293 = x294.oneOf(x9); - Expression x300 = x294.join(x20); - Expression x299 = x300.join(x2); - Expression x302 = x294.join(x18); - Expression x301 = x302.join(x16); - Formula x298 = x299.in(x301); - Formula x304 = x302.one(); - Formula x305 = x302.in(x11); - Formula x303 = x304.and(x305); - Formula x297 = x298.and(x303); - Expression x308 = x294.join(x19); - Formula x307 = x308.one(); - Formula x309 = x308.in(x2); - Formula x306 = x307.and(x309); - Formula x296 = x297.and(x306); - Expression x313 = x13.product(x2); - Formula x312 = x300.in(x313); - Variable x316 = Variable.nary("@", 1); - Decls x315 = x316.oneOf(x13); - Expression x319 = x316.join(x300); - Formula x318 = x319.lone(); - Formula x320 = x319.in(x2); - Formula x317 = x318.and(x320); - Formula x314 = x317.forAll(x315); - Formula x311 = x312.and(x314); - Variable x323 = Variable.nary("@", 1); - Decls x322 = x323.oneOf(x2); - Expression x325 = x300.join(x323); - Formula x324 = x325.in(x13); - Formula x321 = x324.forAll(x322); - Formula x310 = x311.and(x321); - Formula x295 = x296.and(x310); - Formula x292 = x295.forAll(x293); - Expression x328 = x209.product(Expression.UNIV); - Formula x327 = x20.in(x328); - Formula x330 = x19.in(x209); - Formula x332 = x18.in(x209); - Variable x336 = Variable.nary("@this", 1); - Decls x335 = x336.oneOf(x11); - Expression x339 = x336.join(x15); - Formula x338 = x339.one(); - Formula x340 = x339.in(x13); - Formula x337 = x338.and(x340); - Formula x334 = x337.forAll(x335); - Expression x343 = x11.product(x13); - Formula x342 = x16.in(x343); - Expression x346 = x11.product(Expression.UNIV); - Formula x345 = x15.in(x346); - Formula x348 = x27.in(x26); - Expression x352 = x2.join(x28); - Expression x351 = x13.join(x352); - Formula x350 = x9.in(x351); - Expression x360 = x1.product(x31); - Expression x359 = x1.join(x360); - Expression x358 = x359.join(x26); - Expression x357 = x13.join(x358); - Formula x356 = x357.no(); - Variable x363 = Variable.nary("@pre", 1); - Decls x362 = x363.oneOf(x42); - Expression x366 = x363.join(x64); - Expression x365 = x366.join(x29); - Expression x368 = x363.join(x29); - Expression x370 = x363.join(x28); - Expression x369 = x13.join(x370); - Expression x367 = x368.difference(x369); - Formula x364 = x365.eq(x367); - Formula x361 = x364.forAll(x362); - Formula x355 = x356.and(x361); - Variable x373 = Variable.nary("@t", 1); - Decls x372 = x373.oneOf(x2); - Expression x382 = x373.join(x28); - Expression x381 = x13.join(x382); - Expression x383 = x373.join(x29); - Formula x380 = x381.in(x383); - Expression x385 = x381.join(x19); - Formula x384 = x385.in(x373); - Formula x379 = x380.and(x384); - Expression x390 = x373.join(x27); - Expression x389 = x13.join(x390); - Expression x388 = x389.join(x20); - Expression x387 = x13.join(x388); - Formula x386 = x387.in(x373); - Formula x378 = x379.and(x386); - Formula x391 = x381.eq(x381); - Formula x377 = x378.and(x391); - Variable x394 = Variable.nary("@n", 1); - Decls x393 = x394.oneOf(x13); - Variable x397 = Variable.nary("@m", 1); - Decls x396 = x397.oneOf(x9); - Expression x401 = x397.join(x20); - Expression x400 = x394.join(x401); - Formula x399 = x400.eq(x373); - Expression x403 = x394.join(x390); - Formula x402 = x397.in(x403); - Formula x398 = x399.implies(x402); - Formula x395 = x398.forAll(x396); - Formula x392 = x395.forAll(x393); - Formula x376 = x377.and(x392); - Variable x406 = Variable.nary("@n", 1); - Decls x405 = x406.oneOf(x13); - Expression x410 = x406.join(x382); - Expression x409 = x410.join(x18); - Expression x408 = x409.join(x15); - Formula x407 = x408.in(x406); - Formula x404 = x407.forAll(x405); - Formula x375 = x376.and(x404); - Variable x413 = Variable.nary("@n", 1); - Decls x412 = x413.oneOf(x13); - Variable x416 = Variable.nary("@m", 1); - Decls x415 = x416.oneOf(x9); - Expression x421 = x373.join(x26); - Expression x420 = x413.join(x421); - Formula x419 = x416.in(x420); - Expression x425 = x416.join(x18); - Expression x424 = x425.join(x16); - Formula x423 = x413.in(x424); - Expression x427 = x416.join(x19); - Expression x428 = x373.join(x78); - Formula x426 = x427.in(x428); - Formula x422 = x423.and(x426); - Formula x418 = x419.implies(x422); - Expression x431 = x413.join(x390); - Formula x430 = x416.in(x431); - Expression x436 = x373.join(x63); - Expression x435 = x436.join(x26); - Expression x434 = x413.join(x435); - Formula x433 = x416.in(x434); - Formula x432 = x433.not(); - Formula x429 = x430.implies(x432); - Formula x417 = x418.and(x429); - Formula x414 = x417.forAll(x415); - Formula x411 = x414.forAll(x412); - Formula x374 = x375.and(x411); - Formula x371 = x374.forAll(x372); - Formula x354 = x355.and(x371); - Variable x440 = Variable.nary("@this", 1); - Decls x439 = x440.oneOf(x6); - Expression x443 = x440.join(x24); - Formula x442 = x443.one(); - Formula x444 = x443.in(x5); - Formula x441 = x442.and(x444); - Formula x438 = x441.forAll(x439); - Expression x447 = x6.product(Expression.UNIV); - Formula x446 = x24.in(x447); - Variable x451 = Variable.nary("@this", 1); - Decls x450 = x451.oneOf(x8); - Expression x455 = x451.join(x21); - Formula x454 = x455.one(); - Formula x456 = x455.in(x13); - Formula x453 = x454.and(x456); - Expression x459 = x451.join(x23); - Formula x458 = x459.one(); - Formula x460 = x459.in(x13); - Formula x457 = x458.and(x460); - Formula x452 = x453.and(x457); - Formula x449 = x452.forAll(x450); - Expression x463 = x8.product(Expression.UNIV); - Formula x462 = x23.in(x463); - Expression x466 = x8.product(x13); - Formula x465 = x22.in(x466); - Formula x468 = x21.in(x463); - Variable x472 = Variable.nary("@this", 1); - Decls x471 = x472.oneOf(x10); - Expression x475 = x472.join(x17); - Formula x474 = x475.one(); - Formula x476 = x475.in(x13); - Formula x473 = x474.and(x476); - Formula x470 = x473.forAll(x471); - Expression x479 = x10.product(Expression.UNIV); - Formula x478 = x17.in(x479); - Variable x483 = Variable.nary("@this", 1); - Decls x482 = x483.oneOf(x12); - Expression x486 = x483.join(x14); - Formula x485 = x486.one(); - Formula x487 = x486.in(x13); - Formula x484 = x485.and(x487); - Formula x481 = x484.forAll(x482); - Expression x490 = x12.product(Expression.UNIV); - Formula x489 = x14.in(x490); - Formula x494 = x12.eq(x13); - Formula x495 = x10.eq(x11); - Formula x493 = x494.and(x495); - Formula x496 = x6.eq(x7); - Formula x492 = x493.and(x496); - Variable x500 = Variable.nary("@n", 1); - Decls x499 = x500.oneOf(x13); - Variable x504 = Variable.nary("@t", 1); - Decls x503 = x504.oneOf(x42); - Formula x507 = x504.eq(x359); - Expression x514 = x504.join(x28); - Expression x513 = x500.join(x514); - Formula x512 = x513.one(); - Expression x518 = x504.join(x30); - Expression x517 = x500.join(x518); - IntExpression x516 = x517.count(); - IntExpression x519 = IntConstant.constant(1); - Formula x515 = x516.eq(x519); - Formula x511 = x512.and(x515); - Expression x522 = x513.join(x18); - Expression x521 = x522.join(x16); - Expression x523 = x500.join(x14); - Formula x520 = x521.eq(x523); - Formula x510 = x511.and(x520); - Expression x525 = x522.join(x17); - Formula x524 = x525.eq(x500); - Formula x509 = x510.and(x524); - Expression x530 = x504.join(x64); - Expression x529 = x530.join(x25); - Expression x528 = x500.join(x529); - Expression x527 = x528.join(x24); - Formula x526 = x527.eq(x3); - Formula x508 = x509.and(x526); - Formula x506 = x507.implies(x508); - Formula x532 = x507.not(); - Expression x539 = x504.join(x27); - Expression x538 = x500.join(x539); - Expression x541 = x504.join(x26); - Expression x540 = x500.join(x541); - Formula x537 = x538.eq(x540); - Variable x544 = Variable.nary("@received", 1); - Decls x543 = x544.oneOf(x538); - Expression x548 = x544.join(x18); - Expression x547 = x548.join(x17); - Expression x552 = x0.product(x36); - Expression x551 = x0.join(x552); - Expression x550 = x551.closure(); - Expression x549 = x500.join(x550); - Formula x546 = x547.in(x549); - Variable x557 = Variable.nary("@weSend", 1); - Decls x556 = x557.oneOf(x513); - Variable x559 = Variable.nary("@weSend", 1); - Decls x558 = x559.oneOf(x513); - Decls x555 = x556.and(x558); - Expression x565 = x557.join(x18); - Expression x564 = x565.join(x17); - Formula x563 = x564.eq(x547); - Expression x567 = x565.join(x16); - Formula x566 = x567.eq(x523); - Formula x562 = x563.and(x566); - Expression x571 = x559.join(x18); - Expression x570 = x571.join(x17); - Formula x569 = x570.eq(x547); - Expression x573 = x571.join(x16); - Formula x572 = x573.eq(x523); - Formula x568 = x569.and(x572); - Formula x561 = x562.and(x568); - Formula x574 = x557.eq(x559); - Formula x560 = x561.implies(x574); - Formula x554 = x560.forAll(x555); - Variable x577 = Variable.nary("@weSend", 1); - Decls x576 = x577.oneOf(x513); - Expression x581 = x577.join(x18); - Expression x580 = x581.join(x17); - Formula x579 = x580.eq(x547); - Expression x583 = x581.join(x16); - Formula x582 = x583.eq(x523); - Formula x578 = x579.and(x582); - Formula x575 = x578.forSome(x576); - Formula x553 = x554.and(x575); - Formula x545 = x546.implies(x553); - Formula x542 = x545.forAll(x543); - Formula x536 = x537.and(x542); - Variable x586 = Variable.nary("@weSend", 1); - Decls x585 = x586.oneOf(x513); - Expression x591 = x586.join(x18); - Expression x590 = x591.join(x17); - Formula x589 = x590.in(x549); - Expression x594 = x538.join(x18); - Expression x593 = x594.join(x17); - Formula x592 = x590.in(x593); - Formula x588 = x589.and(x592); - Expression x596 = x591.join(x16); - Formula x595 = x596.eq(x523); - Formula x587 = x588.and(x595); - Formula x584 = x587.forAll(x585); - Formula x535 = x536.and(x584); - Variable x601 = Variable.nary("VAR", 1); - Decls x600 = x601.oneOf(x538); - Expression x604 = x601.join(x18); - Expression x603 = x604.join(x17); - Formula x602 = x603.in(x549); - Expression x599 = x602.comprehension(x600); - IntExpression x598 = x599.count(); - Formula x597 = x516.eq(x598); - Formula x534 = x535.and(x597); - Formula x606 = x527.eq(x4); - Expression x611 = x504.join(x25); - Expression x610 = x500.join(x611); - Expression x609 = x610.join(x24); - Formula x608 = x609.eq(x4); - Formula x612 = x500.in(x593); - Formula x607 = x608.or(x612); - Formula x605 = x606.iff(x607); - Formula x533 = x534.and(x605); - Formula x531 = x532.implies(x533); - Formula x505 = x506.and(x531); - Formula x502 = x505.forAll(x503); - Expression x618 = x43.join(x27); - Expression x617 = x500.join(x618); - Expression x619 = x500.join(x106); - Formula x616 = x617.eq(x619); - Variable x622 = Variable.nary("@received", 1); - Decls x621 = x622.oneOf(x617); - Expression x626 = x622.join(x18); - Expression x625 = x626.join(x17); - Formula x624 = x625.in(x549); - Variable x631 = Variable.nary("@weSend", 1); - Expression x633 = x43.join(x28); - Expression x632 = x500.join(x633); - Decls x630 = x631.oneOf(x632); - Variable x635 = Variable.nary("@weSend", 1); - Decls x634 = x635.oneOf(x632); - Decls x629 = x630.and(x634); - Expression x641 = x631.join(x18); - Expression x640 = x641.join(x17); - Formula x639 = x640.eq(x625); - Expression x643 = x641.join(x16); - Formula x642 = x643.eq(x523); - Formula x638 = x639.and(x642); - Expression x647 = x635.join(x18); - Expression x646 = x647.join(x17); - Formula x645 = x646.eq(x625); - Expression x649 = x647.join(x16); - Formula x648 = x649.eq(x523); - Formula x644 = x645.and(x648); - Formula x637 = x638.and(x644); - Formula x650 = x631.eq(x635); - Formula x636 = x637.implies(x650); - Formula x628 = x636.forAll(x629); - Variable x653 = Variable.nary("@weSend", 1); - Decls x652 = x653.oneOf(x632); - Expression x657 = x653.join(x18); - Expression x656 = x657.join(x17); - Formula x655 = x656.eq(x625); - Expression x659 = x657.join(x16); - Formula x658 = x659.eq(x523); - Formula x654 = x655.and(x658); - Formula x651 = x654.forSome(x652); - Formula x627 = x628.and(x651); - Formula x623 = x624.implies(x627); - Formula x620 = x623.forAll(x621); - Formula x615 = x616.and(x620); - Variable x662 = Variable.nary("@weSend", 1); - Decls x661 = x662.oneOf(x632); - Expression x667 = x662.join(x18); - Expression x666 = x667.join(x17); - Formula x665 = x666.in(x549); - Expression x670 = x617.join(x18); - Expression x669 = x670.join(x17); - Formula x668 = x666.in(x669); - Formula x664 = x665.and(x668); - Expression x672 = x667.join(x16); - Formula x671 = x672.eq(x523); - Formula x663 = x664.and(x671); - Formula x660 = x663.forAll(x661); - Formula x614 = x615.and(x660); - Expression x676 = x43.join(x30); - Expression x675 = x500.join(x676); - IntExpression x674 = x675.count(); - Variable x680 = Variable.nary("VAR", 1); - Decls x679 = x680.oneOf(x617); - Expression x683 = x680.join(x18); - Expression x682 = x683.join(x17); - Formula x681 = x682.in(x549); - Expression x678 = x681.comprehension(x679); - IntExpression x677 = x678.count(); - Formula x673 = x674.eq(x677); - Formula x613 = x614.and(x673); - Formula x501 = x502.and(x613); - Formula x498 = x501.forAll(x499); - Variable x687 = Variable.nary("@n", 1); - Decls x686 = x687.oneOf(x13); - Expression x691 = x359.join(x25); - Expression x690 = x687.join(x691); - Expression x689 = x690.join(x24); - Formula x688 = x689.eq(x3); - Formula x685 = x688.forAll(x686); - Formula x696 = x8.eq(x9); - Expression x698 = x18.join(x15); - Formula x697 = x21.eq(x698); - Formula x695 = x696.and(x697); - Expression x700 = x18.join(x16); - Formula x699 = x22.eq(x700); - Formula x694 = x695.and(x699); - Expression x702 = x18.join(x17); - Formula x701 = x23.eq(x702); - Formula x693 = x694.and(x701); - Formula x706 = x13.one(); - Variable x709 = Variable.nary("@n", 1); - Decls x708 = x709.oneOf(x13); - Expression x712 = x709.join(x14); - Formula x711 = x709.eq(x712); - Formula x710 = x711.not(); - Formula x707 = x710.forAll(x708); - Formula x705 = x706.or(x707); - Variable x715 = Variable.nary("@n", 1); - Decls x714 = x715.oneOf(x13); - Expression x718 = x14.closure(); - Expression x717 = x715.join(x718); - Formula x716 = x13.in(x717); - Formula x713 = x716.forAll(x714); - Formula x704 = x705.and(x713); - Formula x720 = x0.one(); - Formula x722 = x1.one(); - Formula x724 = x3.one(); - Formula x726 = x4.one(); - Expression x729 = x4.union(x3); - Formula x728 = x729.eq(x5); - Formula x731 = x6.in(x7); - Formula x733 = x8.in(x9); - Formula x735 = x10.in(x11); - Formula x737 = x12.in(x13); - Formula x739 = x36.totalOrder(x13, x34, x35); - Formula x740 = x33.totalOrder(x2, x31, x32); - Formula x738 = x739.and(x740); - Formula x736 = x737.and(x738); - Formula x734 = x735.and(x736); - Formula x732 = x733.and(x734); - Formula x730 = x731.and(x732); - Formula x727 = x728.and(x730); - Formula x725 = x726.and(x727); - Formula x723 = x724.and(x725); - Formula x721 = x722.and(x723); - Formula x719 = x720.and(x721); - Formula x703 = x704.and(x719); - Formula x692 = x693.and(x703); - Formula x684 = x685.and(x692); - Formula x497 = x498.and(x684); - Formula x491 = x492.and(x497); - Formula x488 = x489.and(x491); - Formula x480 = x481.and(x488); - Formula x477 = x478.and(x480); - Formula x469 = x470.and(x477); - Formula x467 = x468.and(x469); - Formula x464 = x465.and(x467); - Formula x461 = x462.and(x464); - Formula x448 = x449.and(x461); - Formula x445 = x446.and(x448); - Formula x437 = x438.and(x445); - Formula x353 = x354.and(x437); - Formula x349 = x350.and(x353); - Formula x347 = x348.and(x349); - Formula x344 = x345.and(x347); - Formula x341 = x342.and(x344); - Formula x333 = x334.and(x341); - Formula x331 = x332.and(x333); - Formula x329 = x330.and(x331); - Formula x326 = x327.and(x329); - Formula x291 = x292.and(x326); - Formula x287 = x288.and(x291); - Formula x285 = x286.and(x287); - Formula x283 = x284.and(x285); - Formula x281 = x282.and(x283); - Formula x278 = x279.and(x281); - Formula x274 = x275.and(x278); - Formula x253 = x254.and(x274); - Formula x37 = x38.and(x253); - - Solver solver = new Solver(); - // solver.options().setSolver(SATFactory.ZChaff); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - // System.out.println(x37); - try { - Solution sol = solver.solve(x37, bounds); - assertNotNull(sol.instance()); - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public final void testFelix_08022006() { - Relation x = Relation.nary("P", 1); - - String[] atoms = { - "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7" - }; - - java.util.ArrayList atomlist = new java.util.ArrayList(); - for (String a : atoms) - atomlist.add(a); - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - for (int i = -8; i <= 7; i++) - bounds.boundExactly(i, factory.setOf(String.valueOf(i))); - - bounds.bound(x, factory.allOf(1)); - - Formula f = x.in(Expression.INTS).and(x.some()); - - // System.out.println(bounds); - - Solver solver = new Solver(); - // solver.options().setSolver(SATFactory.ZChaff); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); - Solution sol; - try { - sol = solver.solve(f, bounds); - assertNotNull(sol.instance()); - } catch (HigherOrderDeclException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnboundLeafException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - public final void testVincent_03182006_reduced() { - final Relation pCourses = Relation.binary("pCourses"), prereqs = Relation.binary("prereqs"); - final List atoms = new ArrayList(14); - atoms.add("6.002"); - atoms.add("8.02"); - atoms.add("6.003"); - atoms.add("6.001"); - atoms.add("[8.02]"); - atoms.add("[6.001]"); - atoms.add("[]"); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - - b.bound(pCourses, f.setOf(f.tuple("[8.02]", "8.02"), f.tuple("[6.001]", "6.001"))); - - b.bound(prereqs, f.setOf(f.tuple("6.002", "[8.02]"), f.tuple("8.02", "[]"), f.tuple("6.003", "[6.001]"), f.tuple("6.001", "[]"))); - - // System.out.println(u); - solver.options().setSolver(SATFactory.DefaultSAT4J); - Solution solution = solver.solve((pCourses.some()).and(prereqs.some()), b); - // System.out.println(solution); // SATISFIABLE - assertEquals(solution.outcome(), Solution.Outcome.SATISFIABLE); - - } - - public final void testVincent_03182006() { - final Relation cAttributes = Relation.binary("cAttributes"), Int = Relation.unary("Integer"), - c6001 = Relation.unary("6.001"), one = Relation.unary("ONE"), - prereqsetUsed = Relation.binary("prereqsetUsed"), Course = Relation.unary("Course"), - CardinalityGrouping = Relation.unary("CardinalityGrouping"), pCourses = Relation.binary("pCourses"), - dec = Relation.binary("dec"), c6002 = Relation.unary("6.002"), greater = Relation.binary("greater"), - size = Relation.binary("size"), less = Relation.binary("less"), - sAttributes = Relation.binary("sAttributes"), PrereqSet = Relation.unary("PrereqSet"), - inc = Relation.binary("inc"), next = Relation.binary("next"), equal = Relation.binary("equal"), - Semester = Relation.unary("Semester"), index = Relation.ternary("index"), - sCourses = Relation.binary("sCourses"), prev = Relation.binary("prev"), - prereqs = Relation.binary("prereqs"); - // [6.002, 8.02, 6.003, 6.001, Spring 2006, Fall 2006, [8.02], [6.001], - // [], Spring, Even, Fall, 1, 2] - final List atoms = new ArrayList(14); - atoms.add("6.002"); - atoms.add("8.02"); - atoms.add("6.003"); - atoms.add("6.001"); - atoms.add("Spring 2006"); - atoms.add("Fall 2006"); - atoms.add("[8.02]"); - atoms.add("[6.001]"); - atoms.add("[]"); - atoms.add("Spring"); - atoms.add("Even"); - atoms.add("Fall"); - atoms.add("1"); - atoms.add("2"); - final Universe u = new Universe(atoms); - final Bounds b = new Bounds(u); - final TupleFactory f = u.factory(); - - b.bound(cAttributes, f.noneOf(2)); - b.boundExactly(Int, f.range(f.tuple("1"), f.tuple("2"))); - b.boundExactly(c6001, f.setOf(f.tuple("6.001"))); - b.boundExactly(one, f.setOf(f.tuple("1"))); - b.bound(prereqsetUsed, f.setOf(f.tuple("6.002", "[8.02]"), f.tuple("8.02", "[]"), f.tuple("6.003", "[6.001]"), f.tuple("6.001", "[]"))); - b.bound(Course, f.range(f.tuple("6.002"), f.tuple("6.001"))); - b.bound(CardinalityGrouping, f.noneOf(1)); - b.boundExactly(pCourses, f.setOf(f.tuple("[8.02]", "8.02"), f.tuple("[6.001]", "6.001"))); - b.boundExactly(dec, f.setOf(f.tuple("2", "1"))); - b.boundExactly(greater, b.upperBound(dec)); - b.bound(size, f.noneOf(2)); - b.boundExactly(c6002, f.setOf(f.tuple("6.002"))); - b.boundExactly(less, f.setOf(f.tuple("1", "2"))); - b.boundExactly(sAttributes, f.setOf(f.tuple("Spring 2006", "Spring"), f.tuple("Spring 2006", "Even"), f.tuple("Fall 2006", "Even"), f.tuple("Fall 2006", "Fall"))); - b.boundExactly(PrereqSet, f.setOf("[8.02]", "[6.001]", "[]")); - b.boundExactly(inc, b.upperBound(less)); - b.boundExactly(next, f.setOf(f.tuple("Spring 2006", "Fall 2006"))); - b.boundExactly(equal, f.setOf(f.tuple("1", "1"), f.tuple("2", "2"))); - b.boundExactly(Semester, f.setOf("Spring 2006", "Fall 2006")); - b.bound(index, f.noneOf(3)); - b.bound(sCourses, f.range(f.tuple("Spring 2006"), f.tuple("Fall 2006")).product(f.range(f.tuple("6.002"), f.tuple("6.001")))); - b.boundExactly(prev, f.setOf(f.tuple("Fall 2006", "Spring 2006"))); - b.boundExactly(prereqs, f.setOf(f.tuple("6.002", "[8.02]"), f.tuple("8.02", "[]"), f.tuple("6.003", "[6.001]"), f.tuple("6.001", "[]"))); - // for(Relation r : b.relations()) { - // System.out.println(r + " " + r.arity() + " " + b.lowerBound(r) + " ; - // " + b.upperBound(r)); - // } - // System.out.println(u); - - final Formula f0 = sCourses.in(Semester.product(Course)); - final Formula f1 = size.function(CardinalityGrouping, Int); - final Formula f2 = prereqsetUsed.function(Semester.join(sCourses), PrereqSet); - final Formula f3 = prereqsetUsed.in(prereqs); - final Variable s = Variable.unary("s"); - final Expression e0 = s.join(sCourses).join(prereqsetUsed).join(pCourses); - final Expression e1 = s.join(prev.closure()).join(sCourses); - final Formula f4 = e0.in(e1).forAll(s.oneOf(Semester)); - final Formula f5 = c6002.in(Semester.join(sCourses)); - final Variable e = Variable.unary("e"); - final Expression e3 = Semester.join(sCourses).difference(e); - final Formula f60 = c6002.in(e3); - final Formula f61 = e3.join(prereqsetUsed).join(pCourses).in(e3); - final Formula f6 = (f60.and(f61)).not().forAll(e.oneOf(Semester.join(sCourses))); - final Variable c = Variable.unary("c"); - final Formula f7 = c.join(cAttributes).in(s.join(sAttributes)).forAll(c.oneOf(s.join(sCourses))).forAll(s.oneOf(Semester)); - final Variable s1 = Variable.unary("s1"), s2 = Variable.unary("s2"); - final Formula f8 = s1.join(sCourses).intersection(s2.join(sCourses)).no().forAll(s2.oneOf(Semester.difference(s1))).forAll(s1.oneOf(Semester)); - final Formula f9 = c6001.intersection(Semester.join(sCourses)).no(); - - final Formula x = f0.and(f1).and(f2).and(f3).and(f4).and(f5).and(f6).and(f7).and(f8); - final Formula y = x.and(f9); - - // System.out.println(x); - // System.out.println(y); - - solver.options().setSolver(SATFactory.DefaultSAT4J); - Solution solution = solver.solve(x, b); - // System.out.println(solution); // SATISFIABLE - assertEquals(solution.outcome(), Solution.Outcome.SATISFIABLE); - - Solution solution2 = solver.solve(y, b); - // System.out.println(solution2); // SATISFIABLE!!!??? - // System.out.println((new - // Evaluator(solution2.instance())).evaluate(x)); - assertEquals(solution2.outcome(), Solution.Outcome.SATISFIABLE); - - } - - public final void testGreg_03032006() { - Relation r = Relation.binary("r"); - Universe univ = new Universe(Collections.singleton("o")); - Bounds bounds = new Bounds(univ); - bounds.bound(r, univ.factory().allOf(2)); - - assertEquals(Solution.Outcome.SATISFIABLE, solver.solve(r.some(), bounds).outcome()); - - } - - public final void testGreg_02192006() { - Relation r1 = Relation.unary("r1"); - Relation r2 = Relation.unary("r2"); - Relation r3 = Relation.unary("r3"); - Expression e = r1.in(r2).thenElse(r2, r1); - Formula f = e.eq(r2).and(e.in(r3)); - Object o1 = "o1"; - Object o2 = "o2"; - Universe univ = new Universe(Arrays.asList(o1, o2)); - TupleFactory factory = univ.factory(); - TupleSet set1 = factory.setOf(o1); - TupleSet set2 = factory.setOf(o2); - Bounds bounds = new Bounds(univ); - bounds.bound(r1, set1); - bounds.boundExactly(r2, set2); - bounds.bound(r3, set1); - - assertEquals(Solution.Outcome.TRIVIALLY_UNSATISFIABLE, solver.solve(f, bounds).outcome()); - - } - - public final void testVincent_02182006() { - // set ups universe of atoms [1..257] - final List atoms = new ArrayList(); - - // change this to 256, and the program works - for (int i = 0; i < 257; i++) { - atoms.add(i + 1); - } - - final Universe universe = new Universe(atoms); - final Bounds bounds = new Bounds(universe); - final TupleFactory factory = universe.factory(); - - final Relation oneRel = Relation.unary("oneRel"); - final Relation pCourses = Relation.binary("pCourses"); - final Relation prev = Relation.binary("prev"); - final Relation sCourses = Relation.binary("sCourses"); - final Relation prereqs = Relation.binary("prereqs"); - final Relation semester = Relation.unary("Semester"); - final Relation course = Relation.unary("Course"); - final Relation prereqset = Relation.unary("PrereqSet"); - - final int courseIndex = 0; - final int courseScope = 254; - final int semesterIndex = 254; - final int semesterScope = 2; - final int prereqsetIndex = 256; - final int prereqsetScope = 1; - - bounds.bound(course, factory.range(factory.tuple(atoms.get(courseIndex)), factory.tuple(atoms.get(courseIndex + courseScope - 1)))); - bounds.bound(semester, factory.range(factory.tuple(atoms.get(semesterIndex)), factory.tuple(atoms.get(semesterIndex + semesterScope - 1)))); - bounds.bound(prereqset, factory.range(factory.tuple(atoms.get(prereqsetIndex)), factory.tuple(atoms.get(prereqsetIndex + prereqsetScope - 1)))); - - bounds.bound(oneRel, factory.setOf(factory.tuple(atoms.get(0))), factory.setOf(factory.tuple(atoms.get(0)))); - - // list1 = [256, 2] - // list2 = [256, 3] - // pCoursesTS = [ [256, 2], [256, 3] ] - List list1 = new ArrayList(); - list1.add(atoms.get(256)); - list1.add(atoms.get(1)); - List list2 = new ArrayList(); - list2.add(atoms.get(256)); - list2.add(atoms.get(2)); - TupleSet pCoursesTS = factory.setOf(factory.tuple(list1), factory.tuple(list2)); - bounds.bound(pCourses, pCoursesTS, pCoursesTS); - - // prevTS = [ [255, 254] ] - TupleSet prevTS = factory.setOf(factory.tuple((Object) atoms.get(255), (Object) atoms.get(254))); - bounds.bound(prev, prevTS, prevTS); - - // sCourses can be anything from Semester -> Course - bounds.bound(sCourses, factory.area(factory.tuple((Object) atoms.get(semesterIndex), (Object) atoms.get(courseIndex)), - - factory.tuple((Object) atoms.get(semesterIndex + semesterScope - 1), (Object) atoms.get(courseIndex + courseScope - 1)))); - - // pCoursesTS = [ [0, 256] ] - TupleSet prereqsTS = factory.setOf(factory.tuple((Object) atoms.get(0), (Object) atoms.get(256))); - bounds.bound(prereqs, prereqsTS, prereqsTS); - - // all s: futureSemesters | all c: s.courses | no c.prereqs or some p: - // c.prereqs | p.courses in s.prev^.courses - final Variable s = Variable.unary("s"), c = Variable.unary("c"), p = Variable.unary("p"); - Formula formula = (p.join(pCourses).in(s.join(prev.closure()).join(sCourses)).forAll(p.oneOf(c.join(prereqs)))).forAll(c.oneOf(s.join(sCourses))).forAll(s.oneOf(semester)); - - // System.out.println(formula); - - final Instance instance = solver.solve(formula, bounds).instance(); - assertNotNull(instance); - } - - public final void testVincent_02172006() { - // set ups universe of atoms [1..257] - final List atoms = new ArrayList(); - - // change this to 256, and the program works - for (int i = 0; i < 257; i++) { - atoms.add(i + 1); - } - - final Universe universe = new Universe(atoms); - final Bounds bounds = new Bounds(universe); - final TupleFactory factory = universe.factory(); - - final Relation oneRel = Relation.unary("oneRel"); - final Relation pCourses = Relation.binary("pCourses"); - final Relation prev = Relation.binary("prev"); - final Relation sCourses = Relation.binary("sCourses"); - final Relation prereqs = Relation.binary("prereqs"); - final Relation rel = Relation.unary("rel"); - - bounds.bound(oneRel, factory.setOf(factory.tuple(atoms.get(0))), factory.setOf(factory.tuple(atoms.get(0)))); - bounds.bound(rel, factory.allOf(1)); - - // list1 and list2 are temp lists for creating bounds for binary - // relations below - // list1 = [1, 2] - // list2 = [3, 2] - // ts = [ [1, 2], [2, 2], [3, 2] ] - List list1 = new ArrayList(); - list1.add(atoms.get(0)); - list1.add(atoms.get(1)); - List list2 = new ArrayList(); - list2.add(atoms.get(2)); - list2.add(atoms.get(1)); - TupleSet ts = factory.area(factory.tuple(list1), factory.tuple(list2)); - - bounds.bound(pCourses, ts); - bounds.bound(prev, ts); - bounds.bound(sCourses, ts); - bounds.bound(prereqs, ts); - - // all s: futureSemesters | all c: s.courses | no c.prereqs or some p: - // c.prereqs | p.courses in s.prev^.courses - final Variable s = Variable.unary("s"), c = Variable.unary("c"), p = Variable.unary("p"); - Formula formula = (p.join(pCourses).in(s.join(prev.closure()).join(sCourses)).forAll(p.oneOf(c.join(prereqs)))).forAll(c.oneOf(s.join(sCourses))).forAll(s.oneOf(rel)); - - // System.out.println(formula); - // solve - - final Instance instance = solver.solve(formula, bounds).instance(); - assertNotNull(instance); - - } - - public final void testEmina_02162006() { - final IntTreeSet s = new IntTreeSet(); - for (int i = 0; i < 5; i++) { - s.add(i); - } - final IntTreeSet s1 = new IntTreeSet(); - s1.add(0); - - final IntSet intersection = new IntTreeSet(s); - intersection.retainAll(s1); - s.removeAll(intersection); - - assertSameContents(s, 1, 2, 3, 4); - assertSameContents(s1, 0); - assertSameContents(intersection, 0); - } - - public final void testVincent_02162006() { - // set ups universe of atoms [1..257] - final List atoms = new ArrayList(); - - // change this to 256, and the program works - for (int i = 0; i < 257; i++) { - atoms.add(i + 1); - } - - final Universe universe = new Universe(atoms); - final Bounds bounds = new Bounds(universe); - final TupleFactory factory = universe.factory(); - - // oneRel is bounded to the Integer 1 - final Relation oneRel = Relation.unary("oneRel"); - - // rel can contain anything - final Relation rel = Relation.unary("rel"); - - bounds.bound(oneRel, factory.setOf(factory.tuple(atoms.get(0))), factory.setOf(factory.tuple(atoms.get(0)))); - bounds.bound(rel, factory.allOf(1)); - - // constraint: oneRel in rel - Formula formula = oneRel.in(rel); - - // solve - - final Instance instance = solver.solve(formula, bounds).instance(); - assertNotNull(instance); - // System.out.println(instance); - - } - - private final void assertSameContents(IntSet s, int... elts) { - assertEquals(elts.length, s.size()); - for (int i : elts) - assertTrue(s.contains(i)); - } - - public final void testVincent_02132006() { - IntTreeSet set = new IntTreeSet(); - for (int i = 0; i < 2; i++) { - set.add(i); - } - - IntTreeSet set2 = new IntTreeSet(); - for (int i = 0; i < 2; i++) { - set2.add(i); - } - - set.removeAll(set2); - IntIterator setIterator = set.iterator(); - assertFalse(setIterator.hasNext()); - assertFalse(setIterator.hasNext()); - - set.addAll(set2); - assertSameContents(set, 0, 1); - - set2.clear(); - for (int i = 3; i < 5; i++) { - set2.add(i); - } - - set.addAll(set2); - assertSameContents(set, 0, 1, 3, 4); - - set2.clear(); - for (int i = 1; i < 4; i++) { - set2.add(i); - } - - set.addAll(set2); - assertSameContents(set, 0, 1, 2, 3, 4); - } - - public final void testEmina_01232006() { - final List atoms = new ArrayList(5); - for (int i = 0; i < 5; i++) - atoms.add("a" + i); - final Universe u = new Universe(atoms); - final TupleFactory tf = u.factory(); - - final Relation r1 = Relation.unary("r1"), r2 = Relation.binary("r2"), r3 = Relation.ternary("r3"); - final Bounds b = new Bounds(u); - final TupleSet r2Bound = tf.noneOf(2); - for (int i = 0; i < 4; i++) - r2Bound.add(tf.tuple(atoms.get(i), atoms.get(i))); - r2Bound.add(tf.tuple("a4", "a1")); - r2Bound.add(tf.tuple("a4", "a2")); - b.bound(r2, r2Bound); - b.bound(r1, tf.setOf("a0", "a3"), tf.setOf("a0", "a3", "a4")); - b.bound(r3, tf.setOf(tf.tuple("a0", "a0", "a0"), tf.tuple("a3", "a3", "a3"))); - final Formula f = r1.product(r2).in(r3); - - final Instance instance = solver.solve(f, b).instance(); - assertTrue((new Evaluator(instance)).evaluate(f)); - // System.out.println(instance); - // System.out.println((new Evaluator(instance)).evaluate(f )); - - } - - public final void testEmina_01192006() { - IntBitSet s = new IntBitSet(64); - for (int i = 4; i < 8; i++) { - for (int j = 0; j < 4; j++) { - s.add(i * 8 + j); - } - } - // System.out.println(s); - for (int i = 4; i < 8; i++) { - assertTrue(s.iterator(i * 8, (i + 1) * 8 - 1).hasNext()); - int count = 0; - for (IntIterator iter = s.iterator(i * 8, (i + 1) * 8 - 1); iter.hasNext();) { - count += iter.next() % 8; - } - assertEquals(count, 6); - } - for (int i = 4; i < 8; i++) { - assertTrue(s.iterator((i + 1) * 8 - 1, i * 8).hasNext()); - int count = 0; - for (IntIterator iter = s.iterator((i + 1) * 8 - 1, i * 8); iter.hasNext();) { - count += iter.next() % 8; - } - assertEquals(count, 6); - } - } - - public final void testGreg_01192006() { - // circular linked list - Relation Entry = Relation.unary("Entry"); - Relation head = Relation.unary("head"); - Relation next = Relation.binary("next"); - Formula nextFun = next.function(Entry, Entry); - - // bijection between indices and entries in linked list - Relation Index = Relation.unary("Index"); - Relation index2Entry = Relation.binary("index2Entry"); - Expression entries = head.join(next.closure()); - Variable e = Variable.unary("e"); - Expression preImage = index2Entry.join(e); - Formula index2EntryBij = e.in(entries).implies(preImage.one()).and(e.in(entries).not().implies(preImage.no())).forAll(e.oneOf(Entry)); - - // try to force list to have three distinct entries - Variable e1 = Variable.unary("e1"); - Variable e2 = Variable.unary("e2"); - Variable e3 = Variable.unary("e3"); - Formula threeEntries = e1.eq(e2).not().and(e1.eq(e3).not()).and(e2.eq(e3).not()).forSome(e1.oneOf(entries).and(e2.oneOf(entries).and(e3.oneOf(entries)))); - Formula simulate = head.one().and(nextFun).and(index2EntryBij).and(threeEntries); - - Object Entry0 = "Entry0"; - Object Entry1 = "Entry1"; - Object Entry2 = "Entry2"; - Object Entry3 = "Entry3"; - Object Index0 = "Index0"; - Object Index1 = "Index1"; - Object Index2 = "Index2"; - Object Index3 = "Index3"; - - Universe univ = new Universe(Arrays.asList(Entry0, Entry1, Entry2, Entry3, Index0, Index1, Index2, Index3)); - TupleFactory factory = univ.factory(); - TupleSet entryTuples = factory.setOf(Entry0, Entry1, Entry2, Entry3); - TupleSet indexTuples = factory.setOf(Index0, Index1, Index2, Index3); - - Instance instance = new Instance(univ); - instance.add(Entry, entryTuples); - instance.add(head, factory.setOf(Entry0)); - instance.add(Index, indexTuples); - - Tuple next0 = factory.tuple(Entry0, Entry1); - Tuple next1 = factory.tuple(Entry1, Entry2); - Tuple next2 = factory.tuple(Entry2, Entry3); - Tuple next3 = factory.tuple(Entry3, Entry0); - instance.add(next, factory.setOf(next0, next1, next2, next3)); - - Tuple i2e0 = factory.tuple(Index0, Entry0); - Tuple i2e1 = factory.tuple(Index1, Entry1); - Tuple i2e2 = factory.tuple(Index2, Entry2); - Tuple i2e3 = factory.tuple(Index3, Entry3); - instance.add(index2Entry, factory.setOf(i2e0, i2e1, i2e2, i2e3)); - - Evaluator eval = new Evaluator(instance); - assertTrue(eval.evaluate(simulate)); - - Bounds bounds = new Bounds(univ); - bounds.boundExactly(Entry, entryTuples); - bounds.bound(head, entryTuples); - bounds.bound(next, entryTuples.product(entryTuples)); - bounds.bound(Index, indexTuples); - bounds.bound(index2Entry, indexTuples.product(entryTuples)); - // Solver solver = new Solver(SATSolverName.Default); - - // System.out.println(simulate); - // System.out.println(bounds); - // System.out.println(instance); - instance = solver.solve(simulate, bounds).instance(); - // System.out.println(instance); - assertNotNull(instance); - - } - - public final void testMana_01132006() { - // r0=[[], [[null], [DblLinkedList0]]], - // null=[[[null]], [[null]]], - // head=[[], [[DblLinkedList0, null], [DblLinkedList0, - // DblLinkedListElem0]]], - // next=[[], [[DblLinkedListElem0, null], [DblLinkedListElem0, - // DblLinkedListElem0]]], - // univ=[[[null], [DblLinkedList0], [1], [DblLinkedListElem0], [0]], - // [[null], [DblLinkedList0], [1], [DblLinkedListElem0], [0]]] - // r1=[[], [[null], [DblLinkedListElem0]]], - final List atoms = new ArrayList(5); - atoms.add("null"); - atoms.add("DblLinkedList0"); - atoms.add("1"); - atoms.add("DblLinkedListElem0"); - atoms.add("0"); - final Universe u = new Universe(atoms); - final TupleFactory t = u.factory(); - - // !((head . univ) in ((if (r1 in null) then (head ++ (r0 -> (r1 . - // next))) else head) . univ)) - - final Relation head = Relation.binary("head"), univ = Relation.unary("univ"), r0 = Relation.unary("r0"), - r1 = Relation.unary("r1"), next = Relation.binary("next"), nil = Relation.unary("null"), - none = Relation.unary("none"); - - final Expression override = head.override(r0.product(r1.join(next))); - final Expression ifElse = r1.in(nil).thenElse(override, head); - final Formula f = head.join(univ).in(ifElse.join(univ)).not(); - - final Bounds b = new Bounds(u); - b.bound(r0, t.setOf("null", "DblLinkedList0")); - b.bound(r1, t.setOf("null", "DblLinkedListElem0")); - b.bound(head, t.setOf("DblLinkedList0").product(b.upperBound(r1))); - - b.bound(next, t.setOf(t.tuple("DblLinkedListElem0", "null"), t.tuple("DblLinkedListElem0", "DblLinkedListElem0"))); - b.boundExactly(univ, t.allOf(1)); - b.boundExactly(nil, t.setOf("null")); - b.boundExactly(none, t.noneOf(1)); - - // System.out.println(f); - // System.out.println(b); - - final Instance instance = solver.solve(f, b).instance(); - assertNull(instance); - - } - - public final void testGreg_11232005() { - final List atoms = new ArrayList(3); - atoms.add("-1"); - atoms.add("0"); - atoms.add("1"); - final Universe u = new Universe(atoms); - final TupleFactory t = u.factory(); - - final Relation inc = Relation.binary("inc"), add = Relation.ternary("add"), one = Relation.unary("1"), - param0 = Relation.unary("param0"), ints = Relation.unary("int"); - - // (one param0 && ((1 . (param0 . add)) in (param0 . ^inc))) - final Formula f = param0.one().and((one.join(param0.join(add))).in(param0.join(inc.closure()))); - - final Bounds b = new Bounds(u); - - b.bound(param0, t.allOf(1)); - b.boundExactly(one, t.setOf(t.tuple("1"))); - b.boundExactly(ints, t.allOf(1)); - b.boundExactly(inc, t.setOf(t.tuple("-1", "0"), t.tuple("0", "1"))); - // [1, 1, -1], [1, -1, 0], [1, 0, 1], [-1, 1, 0], [-1, -1, 1], - // [-1, 0, -1], [0, 1, 1], [0, -1, -1], [0, 0, 0]] - b.boundExactly(add, t.setOf(t.tuple("1", "1", "-1"), t.tuple("1", "-1", "0"), t.tuple("1", "0", "1"), t.tuple("-1", "1", "0"), t.tuple("-1", "-1", "1"), t.tuple("-1", "0", "-1"), t.tuple("0", "1", "1"), t.tuple("0", "-1", "-1"), t.tuple("0", "0", "0"))); - - // System.out.println(f); - // System.out.println(b); - - final Instance instance = solver.solve(f, b).instance(); - assertTrue((new Evaluator(instance)).evaluate(f)); - // System.out.println(instance); - // System.out.println((new Evaluator(instance)).evaluate(f )); - - } - - public final void testGreg_01052006() { - - // final TreeSequence t = new TreeSequence(); - // final int[] elts = {107, 31, 86, 72, 6, 119, 23, 131}; - // for(int i = 0; i < elts.length; i++) { - // t.put(elts[i], 0); - // } - // final int[] sorted = new int[elts.length]; - // System.arraycopy(elts, 0, sorted, 0, elts.length); - // Arrays.sort(sorted); - // int count = 0; - // for(IndexedEntry e : t) { - // assertEquals(sorted[count++], e.index()); - // } - // t.remove(72); - // t.put(72,0); - // count = 0; - // for(IndexedEntry e : t) { - // assertEquals(sorted[count++], e.index()); - // } - - final List atoms = new ArrayList(12); - atoms.add(2); - atoms.add(4); - atoms.add(-2); - atoms.add("null"); - atoms.add("array0"); - atoms.add(6); - atoms.add(1); - atoms.add(-1); - atoms.add(-3); - atoms.add(3); - atoms.add(5); - atoms.add(0); - - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - - final TupleSet tdiv = f.noneOf(3); - - for (int i = -3; i <= 6; i++) { - for (int j = -3; j <= 6; j++) { - if (j != 0) { - int divij = i / j; - if (-3 <= divij && divij <= 6) - tdiv.add(f.tuple(i, j, divij)); - else - tdiv.add(f.tuple(i, j, (10 + divij) % 10)); - } - } - } - - final TupleSet tdivcopy = tdiv.clone(); - for (int i = -3; i <= 6; i++) { - for (int j = -3; j <= 6; j++) { - if (j != 0) { - int divij = i / j; - if (-3 <= divij && divij <= 6) - assertTrue(tdivcopy.contains(f.tuple(i, j, divij))); - else - assertTrue(tdivcopy.contains(f.tuple(i, j, (10 + divij) % 10))); - } - } - } - } - - public final void testAleks_03102013() { - final int NUM = 100; - // run it multiple times, because whether the bug is going to be - // exhibited depends on the ordering of items in a set (concretely, - // shared nodes in the AnnotatedNode class - for (int i = 0; i < NUM; i++) { - doTestAleks_03102013(); - } - } - - private final void doTestAleks_03102013() { - Relation r = Relation.unary("R"); - Relation s = Relation.binary("f"); - Variable v = Variable.unary("e"); - Decl decl = v.oneOf(r); - Expression shared = v.join(s); - Formula expr = (shared.difference(shared)).one().forAll(decl); - - Formula fin = expr.and(expr.not()); - - List atomlist = new LinkedList(); - atomlist.add("R$0"); - atomlist.add("R$1"); - atomlist.add("R$2"); - - Universe universe = new Universe(atomlist); - TupleFactory factory = universe.factory(); - Bounds bounds = new Bounds(universe); - - bounds.bound(r, factory.allOf(1)); - bounds.bound(s, factory.allOf(2)); - - Solver solver = new Solver(); - solver.options().setSolver(SATFactory.DefaultSAT4J); - solver.options().setBitwidth(4); - solver.options().setSkolemDepth(0); - solver.options().setLogTranslation(0); - Solution sol = solver.solve(fin, bounds); - assertNull(sol.instance()); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/EnumerationTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/EnumerationTest.java deleted file mode 100644 index 6b18309a2..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/EnumerationTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * - */ -package tests.basic; - -import java.util.Arrays; -import java.util.Iterator; - -import examples.alloy.CeilingsAndFloors; -import examples.alloy.Dijkstra; -import junit.framework.TestCase; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * Tests the solution enumeration functionality of the Solver class. - * - * @author Emina Torlak - */ -public class EnumerationTest extends TestCase { - - private final Solver solver; - - /** - * Constructs a new EnumerationTest. - */ - public EnumerationTest(String arg0) { - super(arg0); - solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - } - - public final void testCeilingsAndFloors() { - final CeilingsAndFloors model = new CeilingsAndFloors(); - final Formula f = model.checkBelowTooAssertion(); - - // has exactly one instance - Iterator sol = solver.solveAll(f, model.bounds(2, 2)); - assertNotNull(sol.next().instance()); - assertNull(sol.next().instance()); - assertFalse(sol.hasNext()); - - // has more than one instance - sol = solver.solveAll(f, model.bounds(3, 3)); - assertNotNull(sol.next().instance()); - assertNotNull(sol.next().instance()); - assertTrue(sol.hasNext()); - - // has no instances - sol = solver.solveAll(model.checkBelowTooDoublePrime(), model.bounds(3, 3)); - assertNull(sol.next().instance()); - } - - public final void testDijkstra() { - final Dijkstra model = new Dijkstra(); - final Formula f = model.showDijkstra(); - - Iterator sol = solver.solveAll(f, model.bounds(5, 2, 2)); - // has more than one instance - assertNotNull(sol.next().instance()); - assertNotNull(sol.next().instance()); - assertTrue(sol.hasNext()); - - } - - public final void testTrivial() { - final Relation r = Relation.unary("r"); - final Universe u = new Universe(Arrays.asList("a", "b", "c")); - final TupleFactory f = u.factory(); - final Bounds b = new Bounds(u); - b.bound(r, f.setOf("a"), f.allOf(1)); - final Formula someR = r.some(); - - Iterator sol = solver.solveAll(someR, b); - // has a trivial instance, followed by 2 non-trivial instances - assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, sol.next().outcome()); - assertEquals(Solution.Outcome.SATISFIABLE, sol.next().outcome()); - assertEquals(Solution.Outcome.SATISFIABLE, sol.next().outcome()); - assertEquals(Solution.Outcome.UNSATISFIABLE, sol.next().outcome()); - assertFalse(sol.hasNext()); - - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/EvaluatorTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/EvaluatorTest.java deleted file mode 100644 index a8a24380b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/EvaluatorTest.java +++ /dev/null @@ -1,389 +0,0 @@ -/* - * EvaluatorTest.java - * Created on Jun 21, 2005 - */ -package tests.basic; - -import java.net.URL; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Evaluator; -import kodkod.instance.Instance; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Tests kodkod.engine.Evaluator using the instance produced by running the - * AlloyAnalyzer on examples/puzzles/handshake.als - * - * @author Emina Torlak - */ -public class EvaluatorTest extends TestCase { - - private final String SOLUTION = "handshake.xml"; - private final String PATH = "examples/puzzles/handshake/"; - private final String UNIV_PATH = "alloy/lang/univ/"; - - private Evaluator evaluator; - private Relation univ, hilary, jocelyn, person, spouse, shaken; - - /** - * Constructor for EvaluatorTest. - * - * @param arg0 - */ - public EvaluatorTest(String arg0) { - super(arg0); - } - - private static Relation relation(Map nameToRelation, String path, String name) { - return nameToRelation.get(path + name); - } - - /* - * @see TestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - - URL resource = getClass().getResource(SOLUTION); - - evaluator = new Evaluator(InstanceCreator.getInstance(resource.openStream())); - Map nameToRelation = new HashMap(); - for (Relation r : evaluator.instance().relations()) { - nameToRelation.put(r.name(), r); - } - univ = relation(nameToRelation, UNIV_PATH, "univ"); - hilary = relation(nameToRelation, PATH, "Hilary"); - jocelyn = relation(nameToRelation, PATH, "Jocelyn"); - person = relation(nameToRelation, PATH, "Person"); - spouse = relation(nameToRelation, PATH, "spouse"); - shaken = relation(nameToRelation, PATH, "shaken"); - } - - /* - * @see TestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - private boolean eval(Formula formula) { - return evaluator.evaluate(formula); - } - - private Set eval(Expression expression) { - return evaluator.evaluate(expression); - } - - private Set value(Relation relation) { - return evaluator.instance().tuples(relation); - } - - public final void testEvalUnion() { - // Hilary + Hilary = Hilary - assertEquals(eval(hilary.union(hilary)), value(hilary)); - // Hilary + Jocelyn + Person = Person - assertEquals(eval(hilary.union(jocelyn).union(person)), value(person)); - // spouse + shaken = spouse + shaken - Set spousePlusShaken = new HashSet(); - spousePlusShaken.addAll(value(spouse)); - spousePlusShaken.addAll(value(shaken)); - assertEquals(eval(spouse.union(shaken)), spousePlusShaken); - // shaken + spouse = spouse + shaken - assertEquals(eval(shaken.union(spouse)), spousePlusShaken); - // spouse + Person = arity mismatch - try { - eval(spouse.union(person)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - - } - - public final void testEvalDifference() { - // Jocelyn - Jocelyn = {} - assertTrue(eval(jocelyn.difference(jocelyn)).isEmpty()); - // Hilary - Jocelyn = Hilary - assertEquals(value(hilary), eval(hilary.difference(jocelyn))); - // spouse + shaken - spouse = shaken - assertEquals(value(shaken), eval(spouse.union(shaken).difference(spouse))); - // spouse - Person = arity mismatch - try { - eval(spouse.difference(person)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - - } - - public final void testEvalJoin() { - // Hilary.spouse = Jocelyn - assertEquals(eval(hilary.join(spouse)), value(jocelyn)); - // arity(spouse.shaken) = 2 - assertEquals(spouse.join(shaken).arity(), 2); - // spouse.Person = univ - assertEquals(eval(spouse.join(person)), value(univ)); - // spouse.spouse.Hilary = Hilary - assertEquals(eval(spouse.join(spouse).join(hilary)), value(hilary)); - // (univ - Person.shaken).shaken = {} - assertTrue(eval(univ.difference(person.join(shaken)).join(shaken)).isEmpty()); - // Hilary.Jocelyn = arity mismatch - try { - eval(hilary.join(jocelyn)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - } - - public final void testEvalProduct() { - // Hilary->Jocelyn = Hilary->Jocelyn - final Set hilaryAndJocelyn = eval(hilary.product(jocelyn)); - final Tuple hj = hilaryAndJocelyn.iterator().next(); - assertEquals(hilaryAndJocelyn.size(), 1); - assertEquals(hj.atom(0), value(hilary).iterator().next().atom(0)); - assertEquals(hj.atom(1), value(jocelyn).iterator().next().atom(0)); - - // Person->(spouse->shaken) = (Person->spouse)->shaken - assertEquals(eval(person.product(spouse.product(shaken))), eval(person.product(spouse).product(shaken))); - // Person->(spouse + shaken) = Person->spouse + Person->shaken - assertEquals(eval(person.product(spouse.union(shaken))), eval(person.product(spouse).union(person.product(shaken)))); - // arity(spouse->shaken) = 4 - assertEquals(spouse.product(shaken).arity(), 4); - } - - public final void testEvalIntersection() { - // Hilary & Person = Hilary - assertEquals(eval(hilary.intersection(person)), value(hilary)); - // Hilary & Person = Person & Hilary - assertEquals(eval(hilary.intersection(person)), eval(person.intersection(hilary))); - // spouse & shaken = {} - assertTrue(eval(spouse.intersection(shaken)).isEmpty()); - // spouse & Person = arity mismatch - try { - eval(spouse.intersection(person)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - - } - - public final void testEvalOverride() { - // Hilary ++ Hilary = Hilary - assertEquals(eval(hilary.override(hilary)), value(hilary)); - // Hilary ++ Jocelyn = Hilary + Jocelyn - assertEquals(eval(hilary.override(jocelyn)), eval(hilary.union(jocelyn))); - // spouse ++ shaken = shaken + (spouse - (shaken.Person)->Person) - assertEquals(eval(spouse.override(shaken)), eval(shaken.union(spouse.difference(shaken.join(person).product(person))))); - } - - public final void testEvalTranspose() { - // ~spouse = spouse - assertEquals(eval(spouse.transpose()), value(spouse)); - // ~(Hilary->Jocelyn) = Jocelyn->Hilary - assertEquals(eval(hilary.product(jocelyn).transpose()), eval(jocelyn.product(hilary))); - // ~(~shaken) = shaken - assertEquals(eval(shaken.transpose().transpose()), value(shaken)); - // ~Person = arity error - try { - eval(person.transpose()); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - - } - - public final void testEvalTransitiveClosure() { - // // ^(Hilary->Jocelyn) = Hilary->Jocelyn - // assertEquals(eval(hilary.product(jocelyn).closure()), - // eval(hilary.product(jocelyn))); - // // ^spouse = spouse + spouse.spouse - // assertEquals(eval(spouse.closure()), - // eval(spouse.union(spouse.join(spouse)))); - // // Hilary.^shaken = univ - (univ - Person.shaken) - // assertEquals(eval(hilary.join(shaken.closure())), - // eval(univ.difference(univ.difference(person.join(shaken))))); - // try { - // eval(person.closure()); - // fail("Expected IllegalArgumentException"); - // } catch (IllegalArgumentException iae) {} - - // ^r = value(^r) - final Relation r = Relation.binary("r"); - final Universe u = evaluator.instance().universe(); - final TupleFactory f = u.factory(); - final Instance instance = new Instance(u); - - // value(r) = u[0]->u[1] + u[1]->u[2] + u[2]->u[3] + u[3]->u[4] - TupleSet s = f.noneOf(r.arity()); - for (int i = 0; i < 4; i++) - s.add(f.tuple(u.atom(i), u.atom(i + 1))); - instance.add(r, s); - // value(^r) = value(r) + u[0]->u[2] + u[0]->u[3] + u[0]->u[4] + - // u[1]->u[3] u[1]->u[4] + u[2]->u[4] - Set result = new HashSet(); - for (int i = 0; i < 4; i++) { - for (int j = i + 1; j < 5; j++) { - result.add(f.tuple(u.atom(i), u.atom(j))); - } - } - assertEquals((new Evaluator(instance)).evaluate(r.closure()), result); - // value(*r) = value(^r) + iden - for (int i = 0; i < 10; i++) { - result.add(f.tuple(u.atom(i), u.atom(i))); - } - - assertEquals((new Evaluator(instance)).evaluate(r.reflexiveClosure()), result); - } - - public final void testEvalSubset() { - // Hilary in Person = true - assertTrue(eval(hilary.in(person))); - // shaken in spouse = false - assertFalse(eval(shaken.in(spouse))); - // spouse in Person->Person = true - assertTrue(eval(spouse.in(person.product(person)))); - // spouse in Person = arity mismatch - try { - eval(spouse.in(person)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - } - - public final void testEvalEquals() { - // Person = univ = true - assertTrue(eval(person.eq(univ))); - // univ = Person = true - assertTrue(eval(univ.eq(person))); - // spouse = shaken = false - assertFalse(eval(spouse.eq(shaken))); - // shaken = Person - try { - eval(shaken.in(person)); - fail("Expected IllegalArgumentException"); - } catch (IllegalArgumentException iae) {} - } - - public final void testEvalAnd() { - // Hilary in Person && Jocelyn in Person = true - assertTrue(eval(hilary.in(person).and(jocelyn.in(person)))); - // Jocelyn in Person && Hilary in Person = true - assertTrue(eval(jocelyn.in(person).and(hilary.in(person)))); - // shaken in spouse && univ = Person = false - assertFalse(eval(shaken.in(spouse).and(univ.eq(person)))); - // Person = univ && spouse in shaken = false - assertFalse(eval(person.eq(univ).and(spouse.in(shaken)))); - // spouse in shaken && Hilary = Jocelyn = false - assertFalse(eval(spouse.in(shaken).and(hilary.eq(jocelyn)))); - } - - public final void testEvalOr() { - // Hilary in Person || Jocelyn in Person = true - assertTrue(eval(hilary.in(person).or(jocelyn.in(person)))); - // Jocelyn in Person || Hilary in Person = true - assertTrue(eval(jocelyn.in(person).or(hilary.in(person)))); - // shaken in spouse || univ = Person = true - assertTrue(eval(shaken.in(spouse).or(univ.eq(person)))); - // Person = univ || spouse in shaken = true - assertTrue(eval(person.eq(univ).or(spouse.in(shaken)))); - // spouse in shaken || Hilary = Jocelyn = false - assertFalse(eval(spouse.in(shaken).or(hilary.eq(jocelyn)))); - } - - public final void testEvalNot() { - // !(Hilary in Person) = false - assertFalse(eval(hilary.in(person).not())); - // !(Hilary = Jocelyn) = true - assertTrue(eval(hilary.eq(jocelyn).not())); - } - - public final void testEvalImplies() { - // Hilary in Person => Jocelyn in Person = true - assertTrue(eval(hilary.in(person).implies(jocelyn.in(person)))); - // Hilary in Person => Person in Jocelyn = false - assertFalse(eval(hilary.in(person).implies(person.in(jocelyn)))); - // Hilary = Jocelyn => Person = univ = true - assertTrue(eval(hilary.eq(jocelyn).implies(person.eq(univ)))); - // Hilary = Jocelyn => spouse = shaken = true - assertTrue(eval(hilary.eq(jocelyn).implies(spouse.eq(shaken)))); - } - - public final void testEvalIff() { - // Hilary in Person <=> Jocelyn in Person = true - assertTrue(eval(hilary.in(person).iff(jocelyn.in(person)))); - // Hilary = Jocelyn <=> spouse = shaken = true - assertTrue(eval(hilary.eq(jocelyn).iff(spouse.eq(shaken)))); - // shaken in spouse <=> univ = Person = false - assertFalse(eval(shaken.in(spouse).iff(univ.eq(person)))); - // Person = univ <=> spouse in shaken = false - assertFalse(eval(person.eq(univ).iff(spouse.in(shaken)))); - } - - public final void testMultiplicityFormula() { - // some Person = true - assertTrue(eval(person.some())); - // some (Person - univ) = false - assertFalse(eval(person.difference(univ).some())); - // no Person = false - assertFalse(eval(person.no())); - // no (Person - univ) = true - assertTrue(eval(person.difference(univ).no())); - // one Hilary = true - assertTrue(eval(hilary.one())); - // one spouse = false - assertFalse(eval(spouse.one())); - // lone (Person - univ) = true - assertTrue(eval(person.difference(univ).lone())); - // lone shaken = false - assertFalse(eval(shaken.lone())); - - } - - public final void testQuantifiedFormula() { - - final Variable p = Variable.unary("p"), q = Variable.unary("q"); - final Decl pdecl = p.oneOf(person), qdecl = q.oneOf(person); - final Decls pqdecls = pdecl.and(qdecl); - // all p: Person | some p.spouse = true - assertTrue(eval(p.join(spouse).some().forAll(pdecl))); - // all p, q: Person | (p.spouse = q) => ! (q in p.shaken) = true - assertTrue(eval((p.join(spouse).eq(q).implies(q.in(p.join(shaken)).not()).forAll(pqdecls)))); - // some p: Person | no p.shaken = true - assertTrue(eval(p.join(shaken).no().forSome(pdecl))); - // all p: Person | some q: Person | p.shaken = q = false - assertFalse(eval((p.join(shaken).eq(q).forSome(qdecl)).forAll(pdecl))); - // some p, q: Person | !(p = q) && (p.shaken = q.shaken) = true - assertTrue(eval(p.eq(q).not().and(p.join(shaken).eq(q.join(shaken))).forSome(pqdecls))); - // some p: Person | all q: Person-p | p in q.shaken = false - assertFalse(eval((p.in(q.join(shaken)).forAll(q.oneOf(person.difference(p)))).forSome(pdecl))); - } - - public final void testComprehension() { - final Variable[] vars = new Variable[3]; - final Decl[] decls = new Decl[3]; - for (int i = 0; i < 3; i++) { - Variable v = Variable.unary("v" + i); - Decl d = v.oneOf(person); - vars[i] = v; - decls[i] = d; - } - - // {v0: Person | no v0.shaken} = univ - shaken.Person - assertEquals(eval(vars[0].join(shaken).no().comprehension(decls[0])), eval(univ.difference(shaken.join(person)))); - // {v0, v1: Person | v1 in v0.shaken} = shaken - assertEquals(eval(vars[1].in(vars[0].join(shaken)).comprehension(decls[0].and(decls[1]))), value(shaken)); - // {v0, v1, v2: Person | no v1.shaken} = Person->(univ - - // shaken.Person)->Person - assertEquals(eval(vars[1].join(shaken).no().comprehension(decls[0].and(decls[1]).and(decls[2]))), eval(person.product(univ.difference(shaken.join(person))).product(person))); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/ExamplesTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/ExamplesTest.java deleted file mode 100644 index f85534055..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/ExamplesTest.java +++ /dev/null @@ -1,417 +0,0 @@ -package tests.basic; - -import static kodkod.engine.Solution.Outcome.SATISFIABLE; -import static kodkod.engine.Solution.Outcome.TRIVIALLY_UNSATISFIABLE; -import static kodkod.engine.Solution.Outcome.UNSATISFIABLE; - -import examples.alloy.AbstractWorldDefinitions; -import examples.alloy.CeilingsAndFloors; -import examples.alloy.Dijkstra; -import examples.alloy.FileSystem; -import examples.alloy.Handshake; -import examples.alloy.Hotel; -import examples.alloy.Lists; -import examples.alloy.Pigeonhole; -import examples.alloy.RingElection; -import examples.alloy.Toughnut; -import examples.alloy.Trees; -import examples.netconfig.Bigconfig; -import examples.tptp.ALG195; -import examples.tptp.ALG197; -import examples.tptp.ALG212; -import examples.tptp.COM008; -import examples.tptp.GEO091; -import examples.tptp.GEO092; -import examples.tptp.GEO115; -import examples.tptp.GEO158; -import examples.tptp.GEO159; -import examples.tptp.LAT258; -import examples.tptp.MED007; -import examples.tptp.MED009; -import examples.tptp.NUM374; -import examples.tptp.NUM378; -import examples.tptp.SET943; -import examples.tptp.SET948; -import examples.tptp.SET967; -import examples.tptp.TOP020; -import junit.framework.TestCase; -import kodkod.ast.Formula; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; - -public class ExamplesTest extends TestCase { - - private final Solver solver; - - public ExamplesTest(String arg0) { - super(arg0); - this.solver = new Solver(); - this.solver.options().setSolver(SATFactory.MiniSat); - } - - private Solution solve(Formula formula, Bounds bounds) { - return solver.solve(formula, bounds); - } - - private void check(String name, Solution sol, Solution.Outcome outcome, int primaryVars, int vars, int clauses) { - assertEquals(outcome, sol.outcome()); - // System.out.println(Runtime.getRuntime().freeMemory() + "\t" - // +sol.stats().translationTime() + "\t" + sol.stats().solvingTime() + - // "\t" + sol.stats().primaryVariables() + "\t" + - // sol.stats().variables() +"\t" + sol.stats().clauses() ); - // assertEquals(primaryVars, sol.stats().primaryVariables()); - // assertEquals(vars, sol.stats().variables()); - // assertEquals(clauses, sol.stats().clauses()); - // System.out.println(name+":"+sol.stats().primaryVariables()+":"+sol.stats().variables()+":"+sol.stats().clauses()+":"+sol.stats().translationTime()+":"+sol.stats().solvingTime()); - } - - /** - * Runs the Bigconfig example for 1 hq, 9 subs, 4 unwindings. - */ - public void testBigconfig() { - final Bigconfig prob = new Bigconfig(4); - final Solution sol = solve(prob.show(), prob.bounds(1, 9, 10)); - check(prob.getClass().getSimpleName(), sol, SATISFIABLE, 100, 2227, 4170); - } - - /** - * Runs the CeilingsAndFloors.checkBelowTooDoublePrime example for 6 Man, 6 - * Platform. - */ - public void testCeilingsAndFloors_BelowTooDoublePrime() { - final CeilingsAndFloors prob = new CeilingsAndFloors(); - final Solution sol = solve(prob.checkBelowTooDoublePrime(), prob.bounds(6, 6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 90, 1750, 3414); - } - - /** - * Runs the CeilingsAndFloors.checkBelowTooAssertion example for 6 Man, 6 - * Platform. - */ - public void testCeilingsAndFloors_BelowTooAssertion() { - final CeilingsAndFloors prob = new CeilingsAndFloors(); - final Solution sol = solve(prob.checkBelowTooAssertion(), prob.bounds(6, 6)); - check(prob.getClass().getSimpleName(), sol, SATISFIABLE, 90, 1750, 3414); - } - - /** - * Runs the Dijkstra example for 6 States, 6 Processes, and 6 Mutexes. - */ - public void testDijkstra() { - final Dijkstra prob = new Dijkstra(); - final Solution sol = solve(prob.checkDijkstraPreventsDeadlocks(), prob.bounds(6, 6, 6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs FileSystem.checkNoDirAliases for 5. - */ - public void testFileSystem() { - final FileSystem prob = new FileSystem(); - final Solution sol = solve(prob.checkNoDirAliases(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, SATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs Handshake.runPuzzle for 6. - */ - public void testHandshake() { - final Handshake prob = new Handshake(); - final Solution sol = solve(prob.runPuzzle(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, SATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs Hotel.checkNoBadEntry for 4 and 6. - */ - public void testHotel() { - final Hotel prob = new Hotel(); - check(prob.getClass().getSimpleName(), solve(prob.checkNoBadEntry(), prob.bounds(4)), UNSATISFIABLE, 444, 4341, 18485); - check(prob.getClass().getSimpleName(), solve(prob.checkNoBadEntry(), prob.bounds(6)), SATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs Lists.runShow for 5. - */ - public void testLists_runShow() { - final Lists prob = new Lists(); - final Solution sol = solve(prob.runShow(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, SATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs Lists.checkEmpties for 5. - */ - public void testLists_checkEmpties() { - final Lists prob = new Lists(); - final Solution sol = solve(prob.checkEmpties(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs Lists.checkReflexive for 5. - */ - public void testLists_checkReflexive() { - final Lists prob = new Lists(); - final Solution sol = solve(prob.checkReflexive(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs Lists.checkSymmetric for 5. - */ - public void testLists_checkSymmetric() { - final Lists prob = new Lists(); - final Solution sol = solve(prob.checkSymmetric(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 444, 4341, 18485); - } - - /** - * Runs the Pigeonhole example for 10 Pigeons, 9 Holes. - */ - public void testPigeonhole() { - final Pigeonhole prob = new Pigeonhole(); - final Formula show = prob.declarations().and(prob.pigeonPerHole()); - final Solution sol = solve(show, prob.bounds(10, 9)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 90, 1133, 2126); - } - - /** - * Runs RingElection.checkAtMostOneElected for 10 Times, 5 Processes. - */ - public void testRingElection() { - final RingElection prob = new RingElection(); - final Solution sol = solve(prob.checkAtMostOneElected(), prob.bounds(5, 10)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 325, 8665, 29589); - } - - /** - * Runs Trees.checkEquivOfTreeDefns example for 4. - */ - // TODO: see why this test fails when noOverflow is set to true!!! - public void testTrees() { - final Trees prob = new Trees(); - final Solution sol = solve(prob.checkEquivOfTreeDefns(), prob.bounds(4)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 325, 8665, 29589); - } - - /** - * Runs the Toughnut example for an 8x8 board. - */ - public void testToughnut() { - final Toughnut prob = new Toughnut(); - final Solution sol = solve(prob.checkBelowTooDoublePrime(), prob.bounds(8)); - check(prob.getClass().getSimpleName(), sol, TRIVIALLY_UNSATISFIABLE, 0, 0, 0); - } - - /** - * Runs AbstractWorldDefinitions.checkA241 for 5. - */ - public void testAWD_A241() { - final AbstractWorldDefinitions prob = new AbstractWorldDefinitions(); - final Solution sol = solve(prob.checkA241(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs AbstractWorldDefinitions.checkAbOp_total for 5. - */ - public void testAWD_AbOp_total() { - final AbstractWorldDefinitions prob = new AbstractWorldDefinitions(); - final Solution sol = solve(prob.checkAbOp_total(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, TRIVIALLY_UNSATISFIABLE, 0, 0, 0); - - } - - /** - * Runs AbstractWorldDefinitions.checkAbIgnore_inv for 5. - */ - public void testAWD_AbIgnore_inv() { - final AbstractWorldDefinitions prob = new AbstractWorldDefinitions(); - final Solution sol = solve(prob.checkAbIgnore_inv(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs AbstractWorldDefinitions.checkAbTransfer_inv for 5. - */ - public void testAWD_AbTransfer_inv() { - final AbstractWorldDefinitions prob = new AbstractWorldDefinitions(); - final Solution sol = solve(prob.checkAbTransfer_inv(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs ALG195.checkCO1. - */ - public void testALG195() { - final ALG195 prob = new ALG195(); - final Solution sol = solve(prob.checkCO1(), prob.bounds()); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs ALG197.checkCO1. - */ - public void testALG197() { - final ALG197 prob = new ALG197(); - final Solution sol = solve(prob.checkCO1(), prob.bounds()); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs ALG212.checkDistLong for 4. - */ - public void testALG212() { - final ALG212 prob = new ALG212(); - final Solution sol = solve(prob.checkDistLong(), prob.bounds(4)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs COM008.checkGoalToBeProved for 5. - */ - public void testCOM008() { - final COM008 prob = new COM008(); - final Solution sol = solve(prob.checkGoalToBeProved(), prob.bounds(5)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs GEO091.checkTheorem_2_13 for 6. - */ - public void testGEO091() { - final GEO091 prob = new GEO091(); - final Solution sol = solve(prob.checkTheorem_2_13(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs GEO092.checkProposition2141 for 6. - */ - public void testGEO092() { - final GEO092 prob = new GEO092(); - final Solution sol = solve(prob.checkProposition2141(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs GEO115.checkTheorem385 for 6. - */ - public void testGEO115() { - final GEO115 prob = new GEO115(); - final Solution sol = solve(prob.checkTheorem385(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs GEO158.checkConsistent for 6. - */ - public void testGEO158() { - final GEO158 prob = new GEO158(); - final Solution sol = solve(prob.checkConsistent(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs GEO159.checkDefs for 6. - */ - public void testGEO159() { - final GEO159 prob = new GEO159(); - final Solution sol = solve(prob.checkDefs(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs GRA019.checkGoalToBeProved for 6. - */ - // public void testGRA019() { - // final GRA013_026 prob = new GRA013_026(); - // final Solution sol = solve(prob.checkGoalToBeProved(), prob.bounds(6)); - // check(prob.getClass().getSimpleName(), sol, SATISFIABLE, 407, 6968, - // 15413); - // } - - /** - * Runs LAT258.checkGoalToBeProved for 6. - */ - public void testLAT258() { - final LAT258 prob = new LAT258(); - final Solution sol = solve(prob.checkGoalToBeProved(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs MED007.checkTranssls2_qilt27 for 6. - */ - public void testMED007() { - final MED007 prob = new MED007(); - final Solution sol = solve(prob.checkTranssls2_qilt27(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs MED009.checkTranssls2_qige27 for 6. - */ - public void testMED009() { - final MED009 prob = new MED009(); - final Solution sol = solve(prob.checkTranssls2_qige27(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs NUM374.checkWilkie for 3. - */ - public void testNUM374() { - final NUM374 prob = new NUM374(); - final Solution sol = solve(prob.checkWilkie(), prob.bounds(3)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs NUM378.checkInequalities. - */ - public void testNUM378() { - final NUM378 prob = new NUM378(); - final Solution sol = solve(prob.checkInequalities(), prob.bounds()); - check(prob.getClass().getSimpleName(), sol, TRIVIALLY_UNSATISFIABLE, 0, 0, 0); - } - - /** - * Runs SET943.checkT96_zfmisc_1 for 3. - */ - public void testSET943() { - final SET943 prob = new SET943(); - final Solution sol = solve(prob.checkT96_zfmisc_1(), prob.bounds(3)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs SET948.checkT101_zfmisc_1 for 3. - */ - public void testSET948() { - final SET948 prob = new SET948(); - final Solution sol = solve(prob.checkT101_zfmisc_1(), prob.bounds(3)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs SET967.checkT120_zfmisc_1 for 3. - */ - public void testSET967() { - final SET967 prob = new SET967(); - final Solution sol = solve(prob.checkT120_zfmisc_1(), prob.bounds(3)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } - - /** - * Runs TOP020.checkChallenge_AMR_1_4_4 for 6. - */ - public void testTOP020() { - final TOP020 prob = new TOP020(); - final Solution sol = solve(prob.checkChallenge_AMR_1_4_4(), prob.bounds(6)); - check(prob.getClass().getSimpleName(), sol, UNSATISFIABLE, 407, 6968, 15413); - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/HOLSome4AllTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/HOLSome4AllTest.java deleted file mode 100644 index a1b85723b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/HOLSome4AllTest.java +++ /dev/null @@ -1,376 +0,0 @@ -package tests.basic; - -import java.util.LinkedList; -import java.util.List; - -import org.junit.Test; - -import junit.framework.TestCase; -import kodkod.ast.Decl; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.QuantifiedFormula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Evaluator; -import kodkod.engine.HOLSolver; -import kodkod.engine.Solution; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -//FIXED: tests are failing because atom relations are not automatically created -//TODO: add this test -// for x: X | some set s: S | ... -public class HOLSome4AllTest extends TestCase { - - private static final IntConstant M1 = IntConstant.constant(-1); - private static final IntConstant I0 = IntConstant.constant(0); - private static final IntConstant I1 = IntConstant.constant(1); - private static final IntConstant I2 = IntConstant.constant(2); - private static final IntConstant I3 = IntConstant.constant(3); - - protected Bounds bounds; - protected Options options; - protected Universe universe; - protected TupleFactory factory; - - protected Relation Node; - protected Relation S; - protected Variable s; - protected IntExpression si; - protected Variable ns; - - protected int bw() { - return 5; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - createRelations(); - createBounds(); - setupOptions(); - } - - @Test - public void testE1() { - // SAT: some s: ints | all ns: set Node | #ns > s - Formula f = ns.count().gt(si).forAll(ns.setOf(Node)).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertEquals(true, sol.sat()); - assertEquals(-1, evalS(sol)); - } - - @Test - public void testE1i() { - // SAT: some s: ints | all s: set Node | #s > s - Variable ns = Variable.unary("s"); - Formula f = ns.count().gt(si).forAll(ns.setOf(Node)).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertEquals(true, sol.sat()); - assertEquals(-1, evalS(sol)); - } - - @Test - public void testE1ii() { - // SAT: some s: ints | all $s: set Node | #$s > s - Variable ns = Variable.unary("$s"); - Formula f = ns.count().gt(si).forAll(ns.setOf(Node)).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertEquals(true, sol.sat()); - assertEquals(-1, evalS(sol)); - } - - @Test - public void testE2() { - // UNSAT: some s: ints | s > 0 && (all ns: set Node | #ns > s) - Formula cnd = si.gt(I0); - Formula f = cnd.and(ns.count().gt(si).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertEquals(false, sol.sat()); - } - - @Test - public void testE3() { - // SAT: some s: ints | s > 0 && (all ns: set Node | some ns => #ns > s) - Formula cnd = si.gt(I0); - Formula f = cnd.and(ns.some().implies(ns.count().gt(si)).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertTrue(sol.sat()); - assertEquals(0, eval(sol, Node).size()); - } - - @Test - public void testE4() { - // UNSAT: some Node && some s: ints | s > 0 && (all ns: set Node | some - // ns => #ns > s) - Formula cnd = si.gt(I0); - Formula f = Node.some().and(cnd.and(ns.some().implies(ns.count().gt(si)).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS))); - Solution sol = solve(f); - assertFalse(sol.sat()); - } - - @Test - public void testE4i() { - // UNSAT: some Node && - // all n: Node | some n && - // some s: ints | s > 0 && (all ns: set Node | some ns => #ns > s) - Variable n = Variable.unary("n"); - Formula cnd = si.gt(I0); - Formula f = Formula.and(Node.some(), n.some().forAll(n.oneOf(Node)), cnd.and(ns.some().implies(ns.count().gt(si)).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS))); - Solution sol = solve(f); - assertFalse(sol.sat()); - } - - @Test - public void testE5() { - // SAT: some Node && some s: ints | s >= 0 && (all ns: set Node | some - // ns => #ns > s) - Formula cnd = si.gte(I0); - Formula f = Node.some().and(cnd.and(ns.some().implies(ns.count().gt(si)).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS))); - Solution sol = solve(f); - assertEquals(true, sol.sat()); - assertEquals(0, evalS(sol)); - } - - @Test - public void testE6() { - // SAT: some s: ints | - // s > 1 || (all ns: set Node | #ns > s) - Formula cnd = si.gt(I1); - Formula f = cnd.or(ns.count().gt(si).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertTrue(sol.sat()); - } - - @Test - public void testE7() { - // SAT: some s: ints | - // s > 3 || (all ns: set Node | #ns > s) - Formula cnd = si.gt(I3); - QuantifiedFormula allQF = (QuantifiedFormula) ns.count().gt(si).forAll(ns.setOf(Node)); - Decl someDecls = s.oneOf(Expression.INTS); - { - Formula f = cnd.or(allQF).forSome(someDecls); - Solution sol = solve(f); - assertTrue(sol.sat()); - assertEquals(-1, evalS(sol)); - } - { - Formula f = cnd.or(flip(allQF)).forSome(someDecls); - Solution sol = solve(f); - assertTrue(sol.sat()); - assertEquals(-1, evalS(sol)); - } - } - - @Test - public void testE8() { - // UNSAT: some s: ints - (-1) | - // s > 3 || (all ns: set Node | #ns > s) - Formula cnd = si.gt(I3); - QuantifiedFormula allQF = (QuantifiedFormula) ns.count().gt(si).forAll(ns.setOf(Node)); - Decl someDecls = s.oneOf(Expression.INTS.difference(M1.toExpression())); - { - Formula f = cnd.or(allQF).forSome(someDecls); - assertFalse(solve(f).sat()); - } - // same thing, but inner flipped - // UNSAT: some s: ints - (-1) | - // s > 3 || (all ns: set Node | #ns > s) - { - Formula f = cnd.or(flip(allQF)).forSome(someDecls); - assertFalse(solve(f).sat()); - } - } - - @Test - public void testE9() { - // UNSAT: some s: ints - (-1) | - // s > 3 || (some ns: set Node | #ns > s + 3) - Formula cnd = si.gt(I3); - QuantifiedFormula innerSomeQF = (QuantifiedFormula) ns.count().gt(si.plus(I3)).forSome(ns.setOf(Node)); - Decl someDecls = s.oneOf(Expression.INTS.difference(M1.toExpression())); - Formula f = cnd.or(innerSomeQF).forSome(someDecls); - assertFalse(solve(f).sat()); - } - - @Test - public void testE9i() { - // SAT: some s: ints | - // s > 3 || (some ns: set Node | #ns > s + 3) - Formula cnd = si.gt(I3); - QuantifiedFormula innerSomeQF = (QuantifiedFormula) ns.count().gt(si.plus(I3)).forSome(ns.setOf(Node)); - Decl someDecls = s.oneOf(Expression.INTS); - Formula f = cnd.or(innerSomeQF).forSome(someDecls); - Solution sol = solve(f); - assertTrue(sol.sat()); - assertEquals(-1, evalS(sol)); - } - - @Test - public void testE9ii() { - // SAT: some s: ints - 1 | - // s > 2 || (some ns: set Node | #ns > s + 3) - Formula cnd = si.gt(I2); - QuantifiedFormula innerSomeQF = (QuantifiedFormula) ns.count().gt(si.plus(I3)).forSome(ns.setOf(Node)); - Decl someDecls = s.oneOf(Expression.INTS.difference(M1.toExpression())); - Formula f = cnd.or(innerSomeQF).forSome(someDecls); - Solution sol = solve(f); - assertTrue(sol.sat()); - assertEquals(3, evalS(sol)); - } - - @Test - public void testParallel1() { - doTestParallel1(Variable.unary("ns2")); - doTestParallel1(Variable.unary("ns")); - } - - @Test - public void testParallel1i() { - doTestParallel1i(Variable.unary("ns2")); - doTestParallel1i(Variable.unary("ns")); - } - - @Test - public void testSome4AllLone() { - // SAT: - // pred P { some s: Node | all p: lone Node | #s >= #p } - // check { P <=> P } - Variable vs = Variable.unary("s"); - Variable vp = Variable.unary("p"); - Formula f = vs.count().gte(vp.count()).forAll(vp.loneOf(Node)).forSome(vs.oneOf(Node)); - Solution sol = solve(f.iff(f).not()); - assertFalse(sol.sat()); - } - - private void doTestParallel1(Variable ns2) { - // SAT: some s: ints { - // all ns: set Node | #ns > s - // all ns2: set Node | #ns2 > s - // } - Formula h1 = ns.count().gt(si).forAll(ns.setOf(Node)); - Formula h2 = ns2.count().gt(si).forAll(ns2.setOf(Node)); - Formula f = h1.and(h2).forSome(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertTrue(sol.sat()); - assertEquals(-1, evalS(sol)); - } - - private void doTestParallel1i(Variable ns2) { - // UNSAT: some s: ints { - // s > 0 - // all ns: set Node | #ns > s - // all ns2: set Node | #ns2 > s - // } - Formula h1 = ns.count().gt(si).forAll(ns.setOf(Node)); - Formula h2 = ns2.count().gt(si).forAll(ns2.setOf(Node)); - Formula f = h1.and(h2).and(si.gt(I0)).forSome(s.oneOf(Expression.INTS)); - assertFalse(solve(f).sat()); - } - - public void testParallel2() { - // UNSAT: some s: ints { - // all ns: set Node | #ns > s - // all ns2: set Node | #ns2 < s - // } - Variable ns2 = Variable.unary("ns2"); - Formula h1 = ns.count().gt(si).forAll(ns.setOf(Node)); - Formula h2 = ns2.count().lt(si).forAll(ns2.setOf(Node)); - Formula f = h1.and(h2).forSome(s.oneOf(Expression.INTS)); - assertFalse(solve(f).sat()); - } - - @Test - public void testA1() { - // SAT: all s: ints | s < 0 => (all ns: set Node | #ns > s) - Formula f = si.lt(I0).implies(ns.count().gt(si).forAll(ns.setOf(Node))).forAll(s.oneOf(Expression.INTS)); - Solution sol = solve(f); - assertTrue(sol.sat()); - } - - protected int evalS(Solution sol) { - Instance inst = sol.instance(); - TupleSet x = inst.tuples(inst.skolems().iterator().next()); - return (Integer) x.iterator().next().atom(0); - } - - protected int eval(Solution sol, IntExpression ie) { - Evaluator ev = new Evaluator(sol.instance()); - return ev.evaluate(ie); - } - - protected TupleSet eval(Solution sol, Expression e) { - Evaluator ev = new Evaluator(sol.instance()); - return ev.evaluate(e); - } - - protected Solution solve(Formula f) { - HOLSolver s = HOLSolver.solver(options); - return s.solve(f, bounds); - } - - private void createRelations() { - Node = Relation.unary("Node"); - S = Relation.unary("$S"); - s = Variable.unary("s"); - si = s.sum(); - ns = Variable.unary("ns"); - } - - private Universe getUniverse() { - List atoms = new LinkedList(); - atoms.add("Node1"); - atoms.add("Node2"); - atoms.add("Node3"); - atoms.add(-1); - atoms.add(0); - atoms.add(1); - atoms.add(2); - atoms.add(3); - return new Universe(atoms); - } - - private void createBounds() { - universe = getUniverse(); - factory = universe.factory(); - bounds = new Bounds(universe); - bounds.bound(Node, factory.setOf("Node1", "Node2", "Node3")); - bounds.boundExactly(-1, factory.setOf(-1)); - bounds.boundExactly(0, factory.setOf(0)); - bounds.boundExactly(1, factory.setOf(1)); - bounds.boundExactly(2, factory.setOf(2)); - bounds.boundExactly(3, factory.setOf(3)); - bounds.bound(S, factory.noneOf(1), factory.setOf(-1, 0, 1, 2, 3)); - } - - protected void setupOptions() { - options = new Options(); - options.setNoOverflow(true); - options.setBitwidth(bw()); - options.setSolver(SATFactory.MiniSat); - options.setAllowHOL(true); - } - - private Formula flip(QuantifiedFormula qf) { - return qf.formula().not().quantify(qf.quantifier().opposite, qf.decls()).not(); - } - - public static void main(String[] args) throws Exception { - HOLSome4AllTest t = new HOLSome4AllTest(); - t.setUp(); - // t._testTmp(); - // t.testE9ii(); - // t._testA1(); - t.testParallel2(); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowEnumTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowEnumTest.java deleted file mode 100644 index bc672274f..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowEnumTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package tests.basic; - -import java.util.Iterator; - -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.engine.Evaluator; -import kodkod.engine.IncrementalSolver; -import kodkod.engine.Solution; -import kodkod.instance.Bounds; - -public class IncrementalOverflowEnumTest extends OverflowEnumTest { - - @Override - protected Solution solve(Formula formula) { - return IncrementalSolver.solver(options).solve(formula, bounds); - } - - @Override - protected Iterator solveAll(final Formula formula) { - final IncrementalSolver solver = IncrementalSolver.solver(options); - return new Iterator() { - - Solution sol; - - @Override - public boolean hasNext() { - return sol == null || sol.sat(); - } - - @Override - public Solution next() { - if (sol == null) { - sol = solver.solve(formula, bounds); - } else { - Evaluator ev = new Evaluator(sol.instance()); - int a = evalInt(ev, op1); - int b = evalInt(ev, op2); - int r = evalInt(ev, ret); - Formula f = op1.eq(IntConstant.constant(a).toExpression()).and(op2.eq(IntConstant.constant(b).toExpression())).and(ret.eq(IntConstant.constant(r).toExpression())).not(); - sol = solver.solve(f, new Bounds(factory.universe())); - } - return sol; - } - - @Override - public void remove() { - throw new RuntimeException("Not supported"); - } - - }; - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowNumTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowNumTest.java deleted file mode 100644 index 2781be0aa..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowNumTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package tests.basic; - -import static tests.basic.OverflowTestUtils.assertNoInstance; - -import org.junit.Test; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.Variable; -import kodkod.engine.IncrementalSolver; -import kodkod.engine.Solution; -import kodkod.engine.config.Options; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -public class IncrementalOverflowNumTest extends OverflowNumTest { - - @Override - protected Solution solve(Formula formula) { - return IncrementalSolver.solver(options).solve(formula, bounds); - } - - @Test - public void testBasic() { - Options opt = new Options(); - opt.setNoOverflow(true); - opt.setBitwidth(2); - IncrementalSolver solver = IncrementalSolver.solver(opt); - Universe univ = new Universe("-2", "-1", "0", "1"); - Bounds b = new Bounds(univ); - TupleFactory factory = univ.factory(); - b.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); - b.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); - b.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); - b.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); - Variable n = Variable.unary("n"); - Formula f = n.sum().plus(IntConstant.constant(1)).lte(n.sum()).forSome(n.oneOf(Expression.INTS)); - Solution sol = solver.solve(f, b); - assertNoInstance(sol); - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowSigTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowSigTest.java deleted file mode 100644 index be2194067..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/IncrementalOverflowSigTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package tests.basic; - -import kodkod.ast.Formula; -import kodkod.engine.IncrementalSolver; -import kodkod.engine.Solution; - -public class IncrementalOverflowSigTest extends OverflowSigTest { - - @Override - protected Solution solve(Formula formula) { - return IncrementalSolver.solver(options).solve(formula, bounds); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/InstanceCreator.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/InstanceCreator.java deleted file mode 100644 index 5645b683b..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/InstanceCreator.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * InstanceCreator.java - * Created on Jun 21, 2005 - */ -package tests.basic; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import kodkod.ast.Relation; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Creates an {@link kodkod.instance.Instance Instance} from a file containing a - * verbose XML representation of an instance generated by the AlloyAnalyzer. - * - * @author Emina Torlak - */ -final class InstanceCreator { - - private final String MODULE = "module"; - private final String SIG = "sig"; - private final String FIELD = "field"; - private final String SKOLEM = "skolem"; - private final String TUPLE = "tuple"; - private final String ARITY = "arity"; - private final String ATOM = "atom"; - private final String NAME = "name"; - - private Document document; - private final Set atoms; - private final Map>> relations; - - private InstanceCreator(File file) { - this(getStream(file)); - } - - private static FileInputStream getStream(File file) { - try { - return new FileInputStream(file); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } - - public InstanceCreator(InputStream in) { - try { - this.relations = new HashMap>>(); - this.atoms = new LinkedHashSet(); - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - this.document = builder.parse(in); - } catch (SAXException sxe) { - // Error generated during parsing - Exception x = sxe; - if (sxe.getException() != null) - x = sxe.getException(); - throw new InstanceCreationException("Error generated during parsing: " + x.getMessage()); - - } catch (ParserConfigurationException pce) { - // Parser with specified options can't be built - throw new InstanceCreationException("Parser with specified options cannot be built: " + pce.getMessage()); - - } catch (IOException ioe) { - // I/O error - throw new InstanceCreationException("I/O error: " + ioe.getMessage()); - } finally { - try { - in.close(); - } catch (IOException e) { - // ignore - } - } - } - - /** - * Returns an Iterator of all children of the given element that are themselves - * elements with the given tag. The order of children is given by - * element.getChildNodes - */ - private Iterator getChildrenByTag(Element element, String tag) { - final List elts = new LinkedList(); - final NodeList children = element.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(tag)) { - elts.add((Element) child); - } - } - return elts.iterator(); - } - - /** - * Returns the value of the NAME attribute of the given element. - */ - private String getName(Element element) { - return element.getAttribute(NAME).intern(); - } - - /** - * Returns the values of the NAME attributes of the elements returned by the - * given iterator. - */ - private List getNames(Iterator elements) { - List names = new LinkedList(); - while (elements.hasNext()) { - names.add(getName(elements.next())); - } - return names; - } - - /** - * Creates a unary Relation r with the name specified by the NAME attribute of - * the module and the unaryRelation. It adds a mapping to this.relations from r - * to a set of unary tuples assigned to the given unaryRelation. - */ - private void processAtoms(Element module, Element unaryRelation) { - - final Set> tuples = new LinkedHashSet>(); - for (Iterator t = getChildrenByTag(unaryRelation, ATOM); t.hasNext();) { - String atom = getName(t.next()).intern(); - tuples.add(Collections.singletonList(atom)); - atoms.add(atom); // add the atom to the pool of atoms - } - relations.put(Relation.unary(getName(module) + "/" + getName(unaryRelation)), tuples); - - } - - /** - * Creates a Relation r whose name specified by the NAME attribute of the module - * and the field, and whose arity is specified by the ARITY attribute of the - * field. It adds a mapping to this.relations from r to a set of tuples that - * represents all the tuples assigned to the given field. - */ - private void processField(Element module, Element field) { - try { - final Relation fieldRelation = Relation.nary(getName(module) + "/" + getName(field), Integer.parseInt(field.getAttribute(ARITY))); - final Set> tuples = new LinkedHashSet>(); - for (Iterator t = getChildrenByTag(field, TUPLE); t.hasNext();) { - tuples.add(getNames(getChildrenByTag(t.next(), ATOM))); - } - - relations.put(fieldRelation, tuples); - - } catch (NumberFormatException nfe) { - throw new InstanceCreationException("Fields must have an arity atribute: " + field.getAttribute(NAME)); - } - } - - /** - * Intializes the list of all atoms and the relations map. Throws an - * InstanceCreationException if an error is encountered. - */ - private void initAtomsAndRelations() { - - final NodeList modules = document.getElementsByTagName(MODULE); - for (int i = 0; i < modules.getLength(); i++) { - Element module = (Element) modules.item(i); - for (Iterator sigs = getChildrenByTag(module, SIG); sigs.hasNext();) { - Element sig = sigs.next(); - processAtoms(module, sig); - for (Iterator fields = getChildrenByTag(sig, FIELD); fields.hasNext();) { - processField(module, fields.next()); - } - } - for (Iterator skolems = getChildrenByTag(module, SKOLEM); skolems.hasNext();) { - processAtoms(module, skolems.next()); - } - } - - } - - /** - * Fills the instance with the relations specified in this.document; if an error - * occurs during processing, the instance remains null - */ - private Instance getInstance() { - initAtomsAndRelations(); - final Universe u = new Universe(atoms); - final TupleFactory f = u.factory(); - final Instance instance = new Instance(u); - for (Map.Entry>> entry : relations.entrySet()) { - Relation r = entry.getKey(); - TupleSet s = f.noneOf(r.arity()); - for (List< ? > atoms : entry.getValue()) { - s.add(f.tuple(atoms)); - } - instance.add(r, s); - } - - return instance; - } - - /** - * Creates an Instance from the specified file. - * - * @return an Instance corresponding to the data in the file designated by the - * given fileName - * @throws a InstanceCreationException if an error occurs during processing - */ - public static Instance getInstance(String fileName) { - InstanceCreator creator = new InstanceCreator(new File(fileName)); - return creator.getInstance(); - } - - public static Instance getInstance(InputStream in) { - InstanceCreator creator = new InstanceCreator(in); - return creator.getInstance(); - } - - public static void main(String[] args) { - System.out.println(getInstance(args[0])); - } - - public static class InstanceCreationException extends RuntimeException { - - private static final long serialVersionUID = 0; - - public InstanceCreationException(String msg) { - super(msg); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/IntTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/IntTest.java deleted file mode 100644 index a637407be..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/IntTest.java +++ /dev/null @@ -1,489 +0,0 @@ -package tests.basic; - -import static kodkod.ast.operator.IntCompOperator.EQ; -import static kodkod.ast.operator.IntCompOperator.GT; -import static kodkod.ast.operator.IntCompOperator.GTE; -import static kodkod.ast.operator.IntCompOperator.LT; -import static kodkod.ast.operator.IntCompOperator.LTE; -import static kodkod.ast.operator.IntOperator.AND; -import static kodkod.ast.operator.IntOperator.DIVIDE; -import static kodkod.ast.operator.IntOperator.MINUS; -import static kodkod.ast.operator.IntOperator.MODULO; -import static kodkod.ast.operator.IntOperator.MULTIPLY; -import static kodkod.ast.operator.IntOperator.OR; -import static kodkod.ast.operator.IntOperator.PLUS; -import static kodkod.ast.operator.IntOperator.SHA; -import static kodkod.ast.operator.IntOperator.SHL; -import static kodkod.ast.operator.IntOperator.SHR; -import static kodkod.ast.operator.IntOperator.XOR; -import static kodkod.engine.config.Options.IntEncoding.TWOSCOMPLEMENT; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.IntCompOperator; -import kodkod.ast.operator.IntOperator; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; -import kodkod.util.ints.IntRange; -import kodkod.util.ints.Ints; - -/** - * Tests translation of cardinality expressions/formulas. - * - * @author Emina Torlak - */ -public class IntTest extends TestCase { - - private static final int SIZE = 16; - private final TupleFactory factory; - private final Solver solver; - private final Relation r1; - private Bounds bounds; - - public IntTest(String arg0) { - super(arg0); - this.solver = new Solver(); - List atoms = new ArrayList(SIZE); - for (int i = 0; i < SIZE; i++) { - atoms.add(String.valueOf(i)); - } - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - r1 = Relation.unary("r1"); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - bounds = new Bounds(factory.universe()); - solver.options().setSolver(SATFactory.MiniSat); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - private Solution solve(Formula formula) { - // System.out.println(formula); - // System.out.println(bounds); - return solver.solve(formula, bounds); - - } - - private IntExpression[] constants() { - final Options options = solver.options(); - final IntRange range = options.integers(); - final int min = range.min(), max = range.max(); - final IntExpression[] vals = new IntExpression[max - min + 1]; - for (int i = min; i <= max; i++) { - vals[i - min] = constant(i); - } - return vals; - } - - private IntExpression[] nonConstants() { - final Options options = solver.options(); - - final IntRange range = options.integers(); - final int min = range.min(), max = range.max(); - final int size = range.size(); - - final Relation[] r = new Relation[size]; - - final TupleFactory f = bounds.universe().factory(); - for (int i = 0; i < size; i++) { - int arity = i % 3 + 1; - r[i] = Relation.nary("r" + i, arity); - - TupleSet b = f.noneOf(arity); - for (int j = (i / 3) * ((int) Math.pow(SIZE, arity - 1)), jmax = j + size; j < jmax; j++) { - b.add(f.tuple(arity, j % b.capacity())); - } - - bounds.bound(r[i], b); - } - - final IntExpression[] vals = new IntExpression[max - min + 1]; - for (int i = 0; i < size; i++) { - vals[i] = i + min < 0 ? r[i].count().negate() : r[i].count(); - } - - return vals; - } - - private static IntExpression constant(int i) { - return IntConstant.constant(i); - } - - private final void testBinOp(IntOperator op, IntExpression ei, IntExpression ej, int i, int j, int result, int mask) { - testBinOp(op, ei, ej, i, j, result, result, mask); - } - - private final void testBinOp(IntOperator op, IntExpression ei, IntExpression ej, int i, int j, int result, int realResult, int mask) { - final IntExpression e = ei.compose(op, ej); - final Formula f = ei.eq(constant(i)).and(ej.eq(constant(j))).and(e.eq(constant(result))); - final Solution s = solve(f); - Instance inst = s.instance(); - if (overflows(op, ei, ej, i, j, realResult)) { - assertNull(f.toString(), inst); - } else { - assertNotNull(f.toString(), inst); - final Evaluator eval = new Evaluator(inst, solver.options()); - assertEquals(f.toString(), result & mask, eval.evaluate(e) & mask); - } - } - - private boolean overflows(IntExpression ei, int i, int realResult) { - if (!solver.options().noOverflow()) - return false; - int bw = solver.options().bitwidth(); - if (outOfBounds(realResult, bw)) - return true; - if (ei.toString().contains("-#") && outOfBounds(-i, bw)) - return true; - return false; - } - - private boolean overflows(IntOperator op, IntExpression ei, IntExpression ej, int i, int j, int realResult) { - if (!solver.options().noOverflow()) - return false; - int bw = solver.options().bitwidth(); - if (ei.toString().contains("-#") && outOfBounds(-i, bw)) - return true; - if (ej.toString().contains("-#") && outOfBounds(-j, bw)) - return true; - if (op == SHA || op == SHR) - return false; - if (op == SHL) { - if (i == 0 || j == 0) - return false; - if (j < 0 || j >= solver.options().bitwidth()) - return true; - } - if (outOfBounds(realResult, bw)) - return true; - return false; - } - - private boolean outOfBounds(int num, int bitwidth) { - int max = 1 << bitwidth - 1; - return !(num < max && num >= -max); - } - - /** - * Tests all binary ops for this.solver.options and range of vals. - * - * @requires this.solver.options.intEncoding = binary - * @requires vals contains int expressions that represent all integers allowed - * by this.solver.options, in proper sequence - */ - private final void test2sComplementBinOps(IntExpression[] vals) { - final Options options = solver.options(); - - final IntRange range = options.integers(); - final int min = range.min(), max = range.max(); - final int mask = ~(-1 << options.bitwidth()); - final int shiftmask = ~(-1 << (32 - Integer.numberOfLeadingZeros(options.bitwidth() - 1))); - - for (int i = min; i <= max; i++) { - IntExpression vi = vals[i - min]; - for (int j = min; j <= max; j++) { - IntExpression vj = vals[j - min]; - testBinOp(PLUS, vi, vj, i, j, i + j, mask); - testBinOp(MINUS, vi, vj, i, j, i - j, mask); - testBinOp(MULTIPLY, vi, vj, i, j, i * j, mask); - - if (j != 0) { - testBinOp(DIVIDE, vi, vj, i, j, i / j, mask); - testBinOp(MODULO, vi, vj, i, j, i % j, mask); - } - - testBinOp(AND, vi, vj, i, j, i & j, mask); - testBinOp(OR, vi, vj, i, j, i | j, mask); - testBinOp(XOR, vi, vj, i, j, i ^ j, mask); - - testBinOp(SHL, vi, vj, i, j, i << (j & shiftmask), i << j, mask); - testBinOp(SHR, vi, vj, i, j, (i & mask) >>> (j & shiftmask), mask); - testBinOp(SHA, vi, vj, i, j, i >> (j & shiftmask), mask); - } - } - - } - - public final void testConstant2sComplementBinOps() { - solver.options().setNoOverflow(false); - test2sComplementBinOps(constants()); - } - - public final void testNonConstant2sComplementBinOps() { - solver.options().setNoOverflow(false); - solver.options().setBitwidth(3); - test2sComplementBinOps(nonConstants()); - } - - private final void testUnOp(IntOperator op, IntExpression ei, int i, int result, int mask) { - final IntExpression e = ei.apply(op); - final Formula f = ei.eq(constant(i)).and(e.eq(constant(result))); - final Solution s = solve(f); - if (overflows(ei, i, result)) { - assertNull(f.toString(), s.instance()); - } else { - assertNotNull(f.toString(), s.instance()); - final Evaluator eval = new Evaluator(s.instance(), solver.options()); - assertEquals(result & mask, eval.evaluate(e) & mask); - } - } - - private final void test2sComplementUnOps(IntExpression[] vals) { - final Options options = solver.options(); - - final IntRange range = options.integers(); - final int min = range.min(), max = range.max(); - final int mask = ~(-1 << options.bitwidth()); - - for (int i = min; i <= max; i++) { - IntExpression vi = vals[i - min]; - testUnOp(IntOperator.NEG, vi, i, -i, mask); - testUnOp(IntOperator.NOT, vi, i, ~i, mask); - testUnOp(IntOperator.ABS, vi, i, Math.abs(i), mask); - testUnOp(IntOperator.SGN, vi, i, i < 0 ? -1 : i > 0 ? 1 : 0, mask); - } - } - - public final void testConstant2sComplementUnOps() { - test2sComplementUnOps(constants()); - } - - public final void testNonConstant2sComplementUnOps() { - solver.options().setBitwidth(3); - test2sComplementUnOps(nonConstants()); - } - - private final void testCompOp(IntCompOperator op, IntExpression ei, IntExpression ej, int i, int j, boolean result) { - final Formula e = ei.compare(op, ej); - final Formula f = ei.eq(constant(i)).and(ej.eq(constant(j))).and(result ? e : e.not()); - final Solution s = solve(f); - if (overflows(ei, i, 0) || overflows(ej, j, 0)) { - assertNull(f.toString(), s.instance()); - } else { - assertNotNull(f.toString(), s.instance()); - final Evaluator eval = new Evaluator(s.instance(), solver.options()); - assertFalse(result ^ eval.evaluate(e)); - } - } - - /** - * Tests all comparison ops for this.solver.options and range of vals. - * - * @requires this.solver.options.intEncoding = binary - * @requires vals contains int expressions that represent all integers allowed - * by this.solver.options, in proper sequence - */ - private final void testComparisonOps(IntExpression[] vals) { - final Options options = solver.options(); - - final IntRange range = options.integers(); - final int min = range.min(), max = range.max(); - - for (int i = min; i <= max; i++) { - IntExpression vi = vals[i - min]; - - for (int j = min; j <= max; j++) { - - IntExpression vj = vals[j - min]; - - testCompOp(EQ, vi, vj, i, j, i == j); - testCompOp(LT, vi, vj, i, j, i < j); - testCompOp(LTE, vi, vj, i, j, i <= j); - testCompOp(GT, vi, vj, i, j, i > j); - testCompOp(GTE, vi, vj, i, j, i >= j); - - } - } - - } - - public final void testConstant2sComplementComparisonOps() { - testComparisonOps(constants()); - } - - public final void testNonConstant2sComplementComparisonOps() { - solver.options().setBitwidth(3); - testComparisonOps(nonConstants()); - } - - public void testSum() { - solver.options().setBitwidth(6); - TupleSet r1b = factory.setOf("1", "5", "9"); - bounds.bound(r1, r1b, r1b); - - Formula f = r1.sum().eq(IntConstant.constant(0)); - Solution s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(5, factory.setOf(factory.tuple("5"))); - - f = r1.sum().eq(IntConstant.constant(5)); - s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(2, factory.setOf(factory.tuple("2"))); - - f = r1.sum().eq(IntConstant.constant(5)); - s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(1, factory.setOf(factory.tuple("9"))); - f = r1.sum().eq(IntConstant.constant(6)); - s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(-8, factory.setOf(factory.tuple("1"))); - f = r1.sum().eq(IntConstant.constant(-2)); - s = solve(f); - assertNotNull(s.instance()); - - bounds.bound(r1, r1b); - f = r1.sum().eq(IntConstant.constant(-2)); - s = solve(f); - assertNotNull(s.instance()); - assertEquals(s.instance().tuples(r1), r1b); - } - - public void testIntCast() { - solver.options().setBitwidth(6); - TupleSet r1b = factory.setOf("1", "5", "9"); - bounds.bound(r1, r1b, r1b); - - Formula f = r1.sum().toExpression().eq(Expression.NONE); - Solution s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(5, factory.setOf(factory.tuple("5"))); - f = r1.sum().toExpression().eq(IntConstant.constant(5).toExpression()); - s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(1, factory.setOf(factory.tuple("1"))); - bounds.boundExactly(6, factory.setOf(factory.tuple("6"))); - - f = r1.sum().toExpression().eq(IntConstant.constant(6).toExpression()); - s = solve(f); - assertNotNull(s.instance()); - - bounds.bound(r1, r1b); - f = r1.sum().toExpression().eq(IntConstant.constant(6).toExpression()); - s = solve(f); - assertNotNull(s.instance()); - - bounds.boundExactly(6, factory.setOf(factory.tuple("1"))); - f = r1.sum().toExpression().eq(IntConstant.constant(6).toExpression()); - s = solve(f); - assertNull(s.instance()); - - } - - public void testBitsetCast() { - final int width = 4, msb = width - 1; - solver.options().setBitwidth(width); - final List atoms = new ArrayList(width); - for (int i = 0; i < msb; i++) { - atoms.add(Integer.valueOf(1 << i)); - } - atoms.add(Integer.valueOf(-1 << msb)); - final Bounds b = new Bounds(new Universe(atoms)); - final TupleFactory f = b.universe().factory(); - for (Integer i : atoms) { - b.boundExactly(i, f.setOf(i)); - } - b.bound(r1, f.allOf(1)); - - for (int i = -1 << msb, max = 1 << msb; i < max; i++) { - Formula test = r1.sum().toBitset().eq(IntConstant.constant(i).toBitset()); - Solution sol = solver.solve(test, b); - Instance inst = sol.instance(); - assertNotNull(inst); - Evaluator eval = new Evaluator(inst, solver.options()); - assertEquals(i, eval.evaluate(r1.sum())); - } - - } - - private void testIfIntExpr(Options.IntEncoding encoding) { - solver.options().setIntEncoding(encoding); - bounds.bound(r1, factory.setOf("15"), factory.setOf("15")); - Formula f = (r1.some().thenElse(r1.count(), IntConstant.constant(5))).eq(IntConstant.constant(1)); - Solution s = solve(f); - assertNotNull(s.instance()); - assertEquals(Ints.singleton(15), s.instance().tuples(r1).indexView()); - - f = (r1.some().thenElse(r1.sum(), IntConstant.constant(5))).eq(IntConstant.constant(1)); - s = solve(f); - assertNull(s.instance()); - - bounds.bound(r1, factory.setOf("3"), factory.allOf(1)); - bounds.boundExactly(3, factory.setOf("3")); - bounds.boundExactly(1, factory.setOf("1")); - f = ((r1.count().eq(IntConstant.constant(2))).thenElse(r1.sum(), IntConstant.constant(5))).eq(IntConstant.constant(4)); - s = solve(f); - assertNotNull(s.instance()); - assertTrue(s.instance().tuples(r1).indexView().contains(1)); - assertTrue(s.instance().tuples(r1).indexView().contains(3)); - assertEquals(2, s.instance().tuples(r1).size()); - - f = Formula.TRUE.thenElse(IntConstant.constant(2), IntConstant.constant(3)).eq(IntConstant.constant(4)); - s = solve(f); - assertEquals(Solution.Outcome.TRIVIALLY_UNSATISFIABLE, s.outcome()); - - f = Formula.FALSE.thenElse(IntConstant.constant(2), IntConstant.constant(3)).eq(IntConstant.constant(3)); - s = solve(f); - assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, s.outcome()); - } - - public void testIfIntExpr() { - solver.options().setBitwidth(8); - testIfIntExpr(TWOSCOMPLEMENT); - } - - private void testIntSum(Options.IntEncoding encoding) { - solver.options().setIntEncoding(encoding); - final Variable x = Variable.unary("x"); - bounds.bound(r1, factory.setOf("13", "14", "15"), factory.setOf("13", "14", "15")); - Formula f = IntConstant.constant(3).eq(IntConstant.constant(1).sum(x.oneOf(r1))); - Solution s = solve(f); - - assertNotNull(s.instance()); - bounds.bound(r1, factory.noneOf(1), factory.setOf("1", "3", "5")); - bounds.boundExactly(1, factory.setOf("1")); - bounds.boundExactly(3, factory.setOf("3")); - bounds.boundExactly(5, factory.setOf("5")); - - f = IntConstant.constant(9).eq(x.sum().sum(x.oneOf(r1))); - s = solve(f); - assertNotNull(s.instance()); - assertEquals(s.instance().tuples(r1), factory.setOf("1", "3", "5")); - } - - public void testIntSum() { - solver.options().setBitwidth(8); - testIntSum(TWOSCOMPLEMENT); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/MinCostTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/MinCostTest.java deleted file mode 100644 index 4d2dd217e..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/MinCostTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package tests.basic; - -// Mincost not supported -/** - * Tests the optimal-solution functionality provided by - * {@link kodkod.engine.Solver#solve(Formula, Bounds, Cost) }. - * - * @author Emina Torlak - */ -// public class MinCostTest extends TestCase { -// private final int USIZE = 10; -// private final TupleFactory factory; -// private final Solver solver; -// private final Relation ra, rb, rab, rba; -// private final Bounds bounds; -// private final Cost cost; -// private final Map cmap; -// -// public MinCostTest(String arg0) { -// super(arg0); -// this.solver = new Solver(); -// solver.options().setSolver(SATFactory.ZChaffMincost); -// List atoms = new ArrayList(USIZE); -// for (int i = 0; i < USIZE; i++) { -// atoms.add(""+i); -// } -// final Universe universe = new Universe(atoms); -// this.factory = universe.factory(); -// this.ra = Relation.unary("ra"); -// this.rb = Relation.unary("rb"); -// this.rab = Relation.binary("rab"); -// this.rba = Relation.binary("rba"); -// this.bounds = new Bounds(universe); -// this.cmap = new LinkedHashMap(); -// cmap.put(ra, 1); -// cmap.put(rb, 2); -// cmap.put(rab, 4); -// cmap.put(rba, 8); -// this.cost = new Cost() { -// public int edgeCost(Relation relation) { -// return cmap.containsKey(relation) ? cmap.get(relation) : 0; -// } -// }; -// } -// -// protected void setUp() throws Exception { -// super.setUp(); -// bounds.bound(ra, factory.setOf("0","1","2","3","4")); -// bounds.bound(rb, factory.setOf("5","6","7","8","9")); -// bounds.bound(rab, bounds.upperBound(ra).product(bounds.upperBound(rb))); -// bounds.bound(rba, bounds.upperBound(rb).product(bounds.upperBound(ra))); -// } -// -// private Solution solve(Formula formula) { -// -// return solver.solve(formula, bounds, cost); -// -// } -// -// private Solution solve(Formula formula, Bounds bounds) { -// -// return solver.solve(formula, bounds, cost); -// -// } -// -//// private Solution simpleSolve(Formula formula) { -//// try { -//// solver.options().setSolver(SATFactory.ZChaffBasic); -//// return solver.solve(formula, bounds); -//// } catch (TimeoutException te) { -//// fail("Timed out solving " + formula); -//// return null; -//// } -//// } -// -// public void testNoSolution() { -// Formula f = ra.some().and(rab.no()).and(ra.in(Expression.UNIV.join(rab))); -// Solution s = solve(f); -// assertEquals(Solution.Outcome.UNSATISFIABLE, s.outcome()); -// } -// -// public void testOneSolution() { -// final examples.sudoku.Sudoku model = new Sudoku(3); -// final Solution sol = solve(model.rules(), -// model.bounds(Sudoku.defaultPuzzle())); -// assertEquals(Solution.Outcome.SATISFIABLE, sol.outcome()); -// } -// -// public void testMultipleSolutions() { -// Formula f = ra.some().or(rb.some()).or(rab.some()).or(rba.some()); -// Solution s = solve(f); -// assertEquals(Solution.Outcome.SATISFIABLE, s.outcome()); -// assertEquals(1, s.instance().tuples(ra).size()); -// assertEquals(0, s.instance().tuples(rb).size()); -// assertEquals(0, s.instance().tuples(rab).size()); -// assertEquals(0, s.instance().tuples(rba).size()); -// } -// } diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowEnumTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowEnumTest.java deleted file mode 100644 index 22fa236ce..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowEnumTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package tests.basic; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.junit.Test; - -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.instance.Bounds; - -public class OverflowEnumTest extends OverflowNumTest { - - private Bounds superBounds; - - protected Relation op1; - protected Relation op2; - - public OverflowEnumTest() { - super(); - this.superBounds = bounds; - } - - @Override - protected int bw() { - return 4; - } - - class Res { - - public final int op1, op2, res; - - public Res(int op1, int op2, int res) { - this.op1 = op1; - this.op2 = op2; - this.res = res; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getOuterType().hashCode(); - result = prime * result + op1; - result = prime * result + op2; - result = prime * result + res; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Res other = (Res) obj; - if (!getOuterType().equals(other.getOuterType())) - return false; - if (op1 != other.op1) - return false; - if (op2 != other.op2) - return false; - if (res != other.res) - return false; - return true; - } - - private OverflowEnumTest getOuterType() { - return OverflowEnumTest.this; - } - } - - @Test - @Override - public void testTmp() {} - - @Override - protected void runTestForAll(Tester t) { - GenericTester gt = (GenericTester) t; - this.op1 = Relation.unary("a"); - this.op2 = Relation.unary("b"); - bounds = superBounds.clone(); - bounds.bound(op1, factory.noneOf(1), factory.allOf(1)); - bounds.bound(op2, factory.noneOf(1), factory.allOf(1)); - - Formula goal = op1.one().and(op2.one()).and(ret.one()); - // goal = goal.and(ret.sum().eq(gt.kodkodOpExpr(op1.sum(), op2.sum()))); - goal = goal.and(ret.eq(gt.kodkodOpExpr(op1.sum(), op2.sum()).toExpression())); - Set kkRes = new HashSet(); - Iterator sols = solveAll(goal); - while (sols.hasNext()) { - Solution sol = sols.next(); - if (sol.unsat()) - break; - Evaluator evaluator = new Evaluator(sol.instance()); - int ia = evalInt(evaluator, op1); - int ib = evalInt(evaluator, op2); - int ir = evalInt(evaluator, ret); - kkRes.add(new Res(ia, ib, ir)); - } - - Set jRes = new HashSet(); - int min = min(); - int max = max(); - for (int i = min; i <= max; i++) { - for (int j = min; j <= max; j++) { - if (gt.skip(i, j)) - continue; - int res = gt.exeJava(i, j); - if (res < min || res > max) - continue; - jRes.add(new Res(i, j, res)); - } - } - - assertEquals(kkRes, jRes); - } - - protected int evalInt(Evaluator ev, Expression a) { - return Integer.parseInt(ev.evaluate(a).iterator().next().atom(0).toString()); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowNumTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowNumTest.java deleted file mode 100644 index a981a937a..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowNumTest.java +++ /dev/null @@ -1,394 +0,0 @@ -package tests.basic; - -import static kodkod.ast.IntExpression.compose; -import static kodkod.ast.operator.IntOperator.DIVIDE; -import static kodkod.ast.operator.IntOperator.MINUS; -import static kodkod.ast.operator.IntOperator.MODULO; -import static kodkod.ast.operator.IntOperator.MULTIPLY; -import static kodkod.ast.operator.IntOperator.PLUS; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.junit.Test; - -import junit.framework.TestCase; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.operator.IntOperator; -import kodkod.engine.Evaluator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -public class OverflowNumTest extends TestCase { - - protected final TupleFactory factory; - protected final Relation ret; - protected Bounds bounds; - protected Options options; - - private static final int DEF_VAL = -1; - - @SuppressWarnings("serial" ) - public class NoSol extends RuntimeException {} - - public abstract class Tester { - - public abstract void doTest(int i, int j); - } - - public abstract class GenericTester extends Tester { - - public void doTmpTest() { - int bw = 5, l = -(1 << (bw - 1)), h = (1 << (bw - 1)); - IntOperator[] ops = new IntOperator[] { - PLUS, MINUS, MULTIPLY, DIVIDE, MODULO - }; - for (IntOperator op : ops) - for (int i = l; i < h; i++) - for (int j = l; j < h; j++) { - Formula f = ret.eq(compose(op, IntConstant.constant(i), IntConstant.constant(j)).toExpression()); - int javaResult = -1; - try { - javaResult = exeJava(op, i, j); - } catch (ArithmeticException e) { - continue; - } - if (javaResult >= h || javaResult < l) { - try { - int kkResult = exeKodkod(f); - fail(String.format("Overflow not detected: (%s) %s (%s) != %s", i, op, j, kkResult)); - } catch (NoSol e) {} - } else { - try { - int kkResult = exeKodkod(f); - assertEquals(String.format("Wrong result: (%s) %s (%s) != %s", i, op, j, kkResult), javaResult, kkResult); - } catch (NoSol e) { - fail(String.format("No solution for (%s) %s (%s); expected: %s", i, op, j, javaResult)); - } - } - } - } - - private int exeKodkod(Formula f) { - Solution sol = solve(f); - return eval(sol.instance()); - } - - private int exeJava(IntOperator op, int i, int j) { - switch (op) { - case PLUS : - return i + j; - case MINUS : - return i - j; - case MULTIPLY : - return i * j; - case DIVIDE : - return i / j; - case MODULO : - return i % j; - default : - throw new RuntimeException("unknown op: " + op); - } - } - - // =================================== - - @Override - public void doTest(int i, int j) { - doTestNoDef(i, j); - doTestDef(i, j); - } - - protected void doTestDef(int i, int j) { - int min = min(); - int max = max(); - String op = getOp(); - int res; - boolean of = false; - try { - res = exeJava(i, j); - if (res > max || res < min) { - of = true; - res = DEF_VAL; - } - } catch (Exception e) { - of = true; - res = DEF_VAL; - } - try { - int x = exeKodkodDef(i, j); - String msg = of ? String.format("Expected the default value (%d) due to overflow ((%d) %s (%d)) but got %d", DEF_VAL, i, op, j, x) : String.format("Wrong result: %s %s %s != %s", i, op, j, x); - assertEquals(msg, res, x); - } catch (NoSol e) { - String msg = String.format("Expected the default value (%d) due to overflow (%d %s %d) but got exception: %s", DEF_VAL, i, op, j, e.getClass().getSimpleName() + ": " + e.getMessage()); - fail(msg); - } - } - - protected void doTestNoDef(int i, int j) { - if (skip(i, j)) - return; - int min = min(); - int max = max(); - String op = getOp(); - int res = exeJava(i, j); - if (res > max || res < min) { - try { - int x = exeKodkod(i, j); - fail(String.format("Overflow not detected: (%s) %s (%s) != %s", i, op, j, x)); - } catch (NoSol e) {} - } else { - try { - int x = exeKodkod(i, j); - assertEquals(String.format("Wrong result: (%s) %s (%s) != %s", i, op, j, x), res, x); - } catch (NoSol e) { - fail(String.format("No solution for (%s) %s (%s); expected: %s", i, op, j, res)); - } - } - } - - protected int eval(Instance instance) { - if (instance == null) - throw new NoSol(); - Evaluator ev = new Evaluator(instance); - return Integer.parseInt(ev.evaluate(ret).iterator().next().atom(0).toString()); - } - - protected int exeKodkod(int i, int j) { - Formula f = ret.eq(kodkodOpExpr(IntConstant.constant(i), IntConstant.constant(j)).toExpression()); - Solution sol = solve(f); - return eval(sol.instance()); - } - - protected int exeKodkodDef(int i, int j) { - IntExpression kkIntExpr = kodkodOpExpr(IntConstant.constant(i), IntConstant.constant(j)); - Expression kkExpr = kkIntExpr.toExpression(); - Formula f = ret.eq(kkExpr.some().thenElse(kkIntExpr.toExpression(), IntConstant.constant(DEF_VAL).toExpression())); - Solution sol = solve(f); - return eval(sol.instance()); - } - - protected abstract int exeJava(int i, int j); - - protected abstract IntExpression kodkodOpExpr(IntExpression i, IntExpression j); - - protected abstract String getOp(); - - protected boolean skip(int i, int j) { - return false; - } - } - - public OverflowNumTest() { - this.ret = Relation.unary("ret"); - int min = min(); - int max = max(); - List atoms = new ArrayList(max - min + 1); - for (int i = min; i <= max; i++) { - atoms.add(String.valueOf(i)); - } - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - this.bounds = new Bounds(factory.universe()); - for (int i = min; i <= max; i++) { - bounds.boundExactly(i, factory.setOf(String.valueOf(i))); - } - bounds.bound(ret, factory.noneOf(1), factory.allOf(1)); - } - - protected int bw() { - return 5; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - setupOptions(); - } - - protected void setupOptions() { - options = new Options(); - options.setNoOverflow(true); - options.setBitwidth(bw()); - options.setSolver(SATFactory.MiniSat); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - protected Solution solve(Formula formula) { - return new Solver(options).solve(formula, bounds); - } - - protected Iterator solveAll(Formula formula) { - return new Solver(options).solveAll(formula, bounds); - } - - @Test - public void testPlus() { - runTestForAll(new GenericTester() { - - @Override - protected int exeJava(int i, int j) { - return i + j; - } - - @Override - protected IntExpression kodkodOpExpr(IntExpression i, IntExpression j) { - return i.plus(j); - } - - @Override - protected String getOp() { - return "+"; - } - }); - } - - @Test - public void testMinus() { - runTestForAll(new GenericTester() { - - @Override - protected int exeJava(int i, int j) { - return i - j; - } - - @Override - protected IntExpression kodkodOpExpr(IntExpression i, IntExpression j) { - return i.minus(j); - } - - @Override - protected String getOp() { - return "-"; - } - }); - } - - @Test - public void testTimes() { - runTestForAll(new GenericTester() { - - @Override - protected int exeJava(int i, int j) { - return i * j; - } - - @Override - protected IntExpression kodkodOpExpr(IntExpression i, IntExpression j) { - return i.multiply(j); - } - - @Override - protected String getOp() { - return "*"; - } - }); - } - - @Test - public void testDiv() { - runTestForAll(new GenericTester() { - - @Override - protected int exeJava(int i, int j) { - return i / j; - } - - @Override - protected IntExpression kodkodOpExpr(IntExpression i, IntExpression j) { - return i.divide(j); - } - - @Override - protected String getOp() { - return "/"; - } - - @Override - protected boolean skip(int i, int j) { - return j == 0; - } - }); - } - - @Test - public void testMod() { - runTestForAll(new GenericTester() { - - @Override - protected int exeJava(int i, int j) { - return i % j; - } - - @Override - protected IntExpression kodkodOpExpr(IntExpression i, IntExpression j) { - return i.modulo(j); - } - - @Override - protected String getOp() { - return "%"; - } - - @Override - protected boolean skip(int i, int j) { - return j == 0; - } - }); - } - - @Test - public void testTmp() { - new GenericTester() { - - @Override - protected IntExpression kodkodOpExpr(IntExpression i, IntExpression j) { - return null; - } - - @Override - protected String getOp() { - return null; - } - - @Override - protected int exeJava(int i, int j) { - return 0; - } - }.doTmpTest(); - } - - protected void runTestForAll(Tester t) { - int min = min(); - int max = max(); - for (int i = min; i <= max; i++) { - for (int j = min; j <= max; j++) { - t.doTest(i, j); - } - } - } - - protected int min() { - return -(1 << (bw() - 1)); - } - - protected int max() { - return (1 << (bw() - 1)) - 1; - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowSigTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowSigTest.java deleted file mode 100644 index d78f27b9c..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowSigTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package tests.basic; - -import static tests.basic.OverflowTestUtils.applyIntOp; -import static tests.basic.OverflowTestUtils.assertInstance; -import static tests.basic.OverflowTestUtils.assertNoInstance; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.junit.Test; - -import junit.framework.TestCase; -import kodkod.ast.Formula; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.IntOperator; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -public class OverflowSigTest extends TestCase { - - interface Func { - - IntExpression call(IntExpression lhs, IntExpression rhs); - } - - protected Options options; - protected TupleFactory factory; - protected Bounds bounds; - - private Relation s, x, sa, sb, sc; - private List sAtoms, xAtoms; - private Formula facts; - private Formula check; - private Formula goal; - private Solution sol; - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - protected Solution solve(Formula formula) { - return new Solver(options).solve(formula, bounds); - } - - protected void checkTrue(Formula f) { - assertNoInstance(solve(f.not())); - } - - protected void checkFalse(Formula f) { - assertInstance(solve(f.not())); - } - - protected void createRelations() { - s = Relation.unary("S"); - x = Relation.unary("X"); - sa = Relation.binary("sa"); - sb = Relation.binary("sb"); - sc = Relation.binary("sc"); - } - - /** - * sAtoms = [S0, S1, ..., S] xAtoms = [X0, X1, ..., S] - */ - protected void createAtoms(int numS, int numX) { - sAtoms = new ArrayList(numS); - xAtoms = new ArrayList(numX); - for (int i = 0; i < numS; i++) - sAtoms.add(String.format("S%d", i)); - for (int i = 0; i < numX; i++) - xAtoms.add(String.format("X%d", i)); - } - - protected void createBounds() { - Collection atoms = new ArrayList(sAtoms.size() + xAtoms.size()); - atoms.addAll(sAtoms); - atoms.addAll(xAtoms); - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - this.bounds = new Bounds(universe); - TupleSet sTs = factory.setOf(sAtoms.toArray()); - TupleSet xTs = factory.setOf(xAtoms.toArray()); - bounds.bound(s, sTs); - bounds.bound(x, xTs); - bounds.bound(sa, sTs.product(xTs)); - bounds.bound(sb, sTs.product(xTs)); - bounds.bound(sc, sTs.product(xTs)); - } - - /** - * all v: S | [#s.sa, #s.sb] = #s.sc = {plus, minus, times, - * div, mod} - */ - protected void createFacts(IntOperator intOp) { - Variable vs = Variable.unary("vs"); - Formula body = applyIntOp(intOp, vs.join(sa).count(), vs.join(sb).count()).eq(vs.join(sc).count()); - this.facts = body.forAll(vs.oneOf(s)); - } - - protected void createOptions(int bw) { - this.options = new Options(); - options.setNoOverflow(true); - options.setBitwidth(bw); - options.setSolver(SATFactory.MiniSat); - } - - /** - * some s.sa && some s.sb => some.sc - */ - protected void createCheck() { - Variable vs = Variable.unary("s"); - Formula body = vs.join(sa).some().and(vs.join(sb).some()).implies(vs.join(sc).some()); - this.check = body.forAll(vs.oneOf(s)); - } - - protected Solution check() { - this.goal = facts.and(check.not()); - this.sol = solve(goal); - return sol; - } - - public Solution checkForBw(IntOperator intOp, int bw) { - createRelations(); - createAtoms(1, 8); - createBounds(); - createFacts(intOp); - createOptions(bw); - createCheck(); - return check(); - } - - @Test - public void testOverBw() { - IntOperator[] ops = new IntOperator[] { - IntOperator.PLUS, IntOperator.MULTIPLY - }; - for (IntOperator op : ops) { - for (int i = 1; i < 6; i++) { - Solution solution = checkForBw(op, i); - assertNoInstance(solution); - } - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowTestUtils.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowTestUtils.java deleted file mode 100644 index 2bd40b662..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowTestUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -package tests.basic; - -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; - -import kodkod.ast.BinaryIntExpression; -import kodkod.ast.IntExpression; -import kodkod.ast.operator.IntOperator; -import kodkod.engine.Solution; - -public class OverflowTestUtils { - - public static IntExpression applyIntOp(IntOperator intOp, IntExpression lhs, IntExpression rhs) { - return new BinaryIntExpression(lhs, intOp, rhs); - } - - public static void assertInstance(Solution[] sols) { - for (Solution sol : sols) - assertInstance(sol); - } - - @SuppressWarnings("deprecation" ) - public static void assertInstance(Solution sol) { - assertNotNull("expected sat, actual " + sol.outcome(), sol.instance()); - } - - public static void assertNoInstance(Solution[] sols) { - for (Solution sol : sols) - assertNoInstance(sol); - } - - @SuppressWarnings("deprecation" ) - public static void assertNoInstance(Solution sol) { - assertNull("expected unsat, actual " + sol.outcome(), sol.instance()); - } - - public static int min(int bw) { - return -(1 << (bw - 1)); - } - - public static int max(int bw) { - return (1 << (bw - 1)) - 1; - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowTheoremTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowTheoremTest.java deleted file mode 100644 index c500fdee2..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/OverflowTheoremTest.java +++ /dev/null @@ -1,370 +0,0 @@ -package tests.basic; - -import static tests.basic.OverflowTestUtils.assertInstance; -import static tests.basic.OverflowTestUtils.assertNoInstance; -import static tests.basic.OverflowTestUtils.max; -import static tests.basic.OverflowTestUtils.min; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -import junit.framework.TestCase; -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.Options; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -public class OverflowTheoremTest extends TestCase { - - private final int bw = 5; - - private Options options; - - protected IntConstant ZERO; - protected IntConstant MININT, MAXINT; - private Variable a; - private Variable b; - private IntExpression as; - private IntExpression bs; - private Decls decls; - - private Bounds bounds; - - @Override - protected void setUp() throws Exception { - super.setUp(); - setupOptions(); - setupBounds(); - - ZERO = IntConstant.constant(0); - MININT = IntConstant.constant(min(bw)); - MAXINT = IntConstant.constant(max(bw)); - a = Variable.unary("a"); - b = Variable.unary("b"); - as = a.sum(); - bs = b.sum(); - decls = a.oneOf(Expression.INTS).and(b.oneOf(Expression.INTS)); - } - - protected void setupBounds() { - Relation ret = Relation.unary("ret"); - int min = min(bw); - int max = max(bw); - List atoms = new ArrayList(max - min + 1); - for (int i = min; i <= max; i++) { - atoms.add(String.valueOf(i)); - } - final Universe universe = new Universe(atoms); - TupleFactory factory = universe.factory(); - this.bounds = new Bounds(factory.universe()); - for (int i = min; i <= max; i++) { - bounds.boundExactly(i, factory.setOf(String.valueOf(i))); - } - bounds.bound(ret, factory.noneOf(1), factory.allOf(1)); - } - - protected void setupOptions() { - options = new Options(); - options.setNoOverflow(true); - options.setBitwidth(bw); - options.setSolver(SATFactory.MiniSat); - options.setSkolemDepth(0); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - protected Solution[] solve(Formula formula) { - Solution s1 = new Solver(options).solve(formula, bounds); - Options opt2 = options.clone(); - opt2.setSkolemDepth(2); - // Solution s2 = new Solver(opt2).solve(formula, bounds); - return new Solution[] { - s1 - }; - } - - protected void checkTrue(Formula f) { - assertNoInstance(solve(f.not())); - } - - protected void checkFalse(Formula f) { - assertInstance(solve(f.not())); - } - - protected void checkSat(Formula f) { - assertInstance(solve(f)); - } - - protected void checkUnsat(Formula f) { - assertNoInstance(solve(f)); - } - - /** - * all decl | pre => post !!(all decl | pre => post) all decl | !!(pre => post) - * all decl | !(pre && !post) all decl | !pre || post !(some decl | !(pre => - * post)) !!!(some decl | !(pre => post)) !(some decl | pre && !post) !(some - * decl | !!(pre && !post)) !(some decl | !(!pre || post)) - */ - protected void checkTrue(Formula pre, Formula post, Decls forAllDecls) { - Formula f = pre.implies(post).forAll(forAllDecls); - checkTrue(f); - - f = pre.implies(post).forAll(forAllDecls).not().not(); - checkTrue(f); - - f = pre.implies(post).not().not().forAll(forAllDecls); - checkTrue(f); - - f = pre.and(post.not()).not().forAll(forAllDecls); - checkTrue(f); - - f = pre.not().or(post).forAll(forAllDecls); - checkTrue(f); - - f = pre.implies(post).not().forSome(forAllDecls).not().not().not(); - checkTrue(f); - - f = pre.implies(post).not().forSome(forAllDecls).not(); - checkTrue(f); - - f = pre.and(post.not()).forSome(forAllDecls).not(); - checkTrue(f); - - f = pre.and(post.not()).not().not().forSome(forAllDecls).not(); - checkTrue(f); - - f = pre.not().or(post).not().forSome(forAllDecls).not(); - checkTrue(f); - } - - /** - * all s : set univ | #s >= 0 !some(s : set univ | #s < 0) - */ - @Test - public void testCardinality0() { - Variable s = Variable.unary("s"); - Formula f = (s.count().gte(IntConstant.constant(0))).forAll(s.setOf(Expression.UNIV)); - checkTrue(f); - - f = (s.count().lt(IntConstant.constant(0))).forSome(s.setOf(Expression.UNIV)).not(); - checkTrue(f); - } - - /** - * all s : set univ | (some s) iff #s > 0 - */ - @Test - public void testCardinality1() { - Variable s = Variable.unary("s"); - Formula f = s.some().iff(s.count().gt(IntConstant.constant(0))).forAll(s.setOf(Expression.UNIV)); - checkTrue(f); - } - - /** - * all s, t : set univ | #(s + t) >= #s && #(s + t) >= #t - */ - @Test - public void testCardinality2() { - Variable s = Variable.unary("s"); - Variable t = Variable.unary("t"); - IntExpression sutCnt = s.union(t).count(); - Decls dcls = s.setOf(Expression.UNIV).and(t.setOf(Expression.UNIV)); - Formula f = sutCnt.gte(s.count()).and(sutCnt.gte(t.count())).forAll(dcls); - checkTrue(f); - } - - /** - * all a, b: set univ | a in b => #a <= #b - */ - @Test - public void testCardinality3() { - Variable a = Variable.unary("a"); - Variable b = Variable.unary("b"); - Decls dcls = a.setOf(Expression.UNIV).and(b.setOf(Expression.UNIV)); - Formula pre = a.in(b); - Formula post = a.count().lte(b.count()); - checkTrue(pre, post, dcls); - } - - /** - * all a, b: set univ | no a & b && some a => #(a + b) > #b - */ - @Test - public void testCardinality4() { - Variable a = Variable.unary("a"); - Variable b = Variable.unary("b"); - Decls dcls = a.setOf(Expression.UNIV).and(b.setOf(Expression.UNIV)); - Formula pre = a.some().and(a.intersection(b).no()); - Formula post = a.union(b).count().gt(b.count()); - checkTrue(pre, post, dcls); - } - - /** - * all a, b: Int | a > 0 && b > 0 => a + b > 0 && a + b > a && a + b > b all a, - * b: Int | a < 0 && b < 0 => a + b < 0 && a + b < a && a + b < b - */ - @Test - public void testTh1() { - { - Formula pre = as.gt(ZERO).and(bs.gt(ZERO)); - IntExpression apb = as.plus(bs); - Formula post = apb.gt(ZERO).and(apb.gt(as)).and(apb.gt(bs)); - checkTrue(pre, post, decls); - } - { - Formula pre = as.lt(ZERO).and(bs.lt(ZERO)); - IntExpression apb = as.plus(bs); - Formula post = apb.lt(ZERO).and(apb.lt(as)).and(apb.lt(bs)); - checkTrue(pre, post, decls); - } - } - - /** - * all a, b: Int | a > 0 && b < 0 => a - b > 0 && a - b > a && a - b > b all a, - * b: Int | a < 0 && b > 0 => a - b < 0 && a - b < a && a - b < b - */ - @Test - public void testTh2() { - { - Formula pre = as.gt(ZERO).and(bs.lt(ZERO)); - IntExpression amb = as.minus(bs); - Formula post = amb.gt(ZERO).and(amb.gt(as)).and(amb.gt(bs.negate())); - checkTrue(pre, post, decls); - } - { - Formula pre = as.lt(ZERO).and(bs.gt(ZERO)); - IntExpression amb = as.minus(bs); - Formula post = amb.lt(ZERO).and(amb.lt(as)).and(amb.lt(bs.negate())); - checkTrue(pre, post, decls); - } - } - - /** - * all a, b: Int | a > 0 && b > 0 => a * b > 0 && a * b >= a && a * b >= b all - * a, b: Int | a < 0 && b < 0 => a * b > 0 && a * b >= -a && a * b >= -b - */ - @Test - public void testTh3() { - { - Formula pre = as.gt(ZERO).and(bs.gt(ZERO)); - IntExpression atb = as.multiply(bs); - Formula post = atb.gt(ZERO).and(atb.gte(as)).and(atb.gte(bs)); - checkTrue(pre, post, decls); - } - { - Formula pre = as.lt(ZERO).and(bs.lt(ZERO)); - IntExpression atb = as.multiply(bs); - Formula post = atb.gt(ZERO).and(atb.gte(as.negate())).and(atb.gte(bs.negate())); - checkTrue(pre, post, decls); - } - } - - /** - * all a, b: Int | a > 0 && b < 0 => a * b < 0 && -(a * b) > a && -(a * b) > -b - * all a, b: Int | a < 0 && b > 0 => a * b < 0 && -(a * b) > -a && -(a * b) > b - */ - @Test - public void testTh4() { - { - Formula pre = as.gt(ZERO).and(bs.lt(ZERO)); - IntExpression atb = as.multiply(bs); - Formula post = atb.lt(ZERO).and(atb.negate().gte(as)).and(atb.negate().gte(bs.negate())); - checkTrue(pre, post, decls); - } - { - Formula pre = as.lt(ZERO).and(bs.gt(ZERO)); - IntExpression atb = as.multiply(bs); - Formula post = atb.lt(ZERO).and(atb.negate().gte(as.negate())).and(atb.negate().gte(bs)); - checkTrue(pre, post, decls); - } - } - - /** - * UNSAT: all a: Int | some b: Int | b = MAXINT && (a = MAXINT => a+a = b+b) - * UNSAT !(some a: Int | all b: Int | !(b = MAXINT && (a = MAXINT => a+a = - * b+b))) UNSAT: some b: Int | all a: Int | b = MAXINT && (a = MAXINT => a+a = - * b+b) UNSAT: !(all b: Int | some a: Int | !(b = MAXINT && (a = MAXINT => a+a = - * b+b))) ---- UNSAT: all x: Int | all a: Int | some b: Int | b = MAXINT && (a = - * MAXINT => a+a = b+b) UNSAT !(some x: Int | some a: Int | all b: Int | !(b = - * MAXINT && (a = MAXINT => a+a = b+b))) UNSAT: all x: Int | some b: Int | all - * a: Int | b = MAXINT && (a = MAXINT => a+a = b+b) UNSAT: !(some x: Int | all - * b: Int | some a: Int | !(b = MAXINT && (a = MAXINT => a+a = b+b))) - */ - public void testUnsat() { - Formula body = bs.eq(MAXINT).and(as.eq(MAXINT).implies(as.plus(as).eq(bs.plus(bs)))); - - checkUnsat(body.forSome(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS))); - checkUnsat(body.not().forAll(b.oneOf(Expression.INTS)).forSome(a.oneOf(Expression.INTS)).not()); - - checkUnsat(body.forAll(a.oneOf(Expression.INTS)).forSome(b.oneOf(Expression.INTS))); - checkUnsat(body.not().forSome(a.oneOf(Expression.INTS)).forAll(b.oneOf(Expression.INTS)).not()); - - Variable x = Variable.unary("x"); - - checkUnsat(body.forSome(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS)).forAll(x.oneOf(Expression.INTS))); - checkUnsat(body.not().forAll(b.oneOf(Expression.INTS)).forSome(a.oneOf(Expression.INTS)).forSome(x.oneOf(Expression.INTS)).not()); - - checkUnsat(body.forAll(a.oneOf(Expression.INTS)).forSome(b.oneOf(Expression.INTS)).forAll(x.oneOf(Expression.INTS))); - checkUnsat(body.not().forSome(a.oneOf(Expression.INTS)).forAll(b.oneOf(Expression.INTS)).forSome(x.oneOf(Expression.INTS)).not()); - } - - /** - * UNSAT: all a: Int | some b: Int | b = MAXINT && (a = MAXINT => (a + b = a + - * b)) SAT: some a: Int | all b: Int | b = MAXINT && (a = MAXINT => (a + b = a + - * b)) - */ - public void testSatUnsat() { - Formula body = bs.eq(MAXINT).and(as.eq(MAXINT).implies(as.plus(bs).eq(as.plus(bs)))); - checkUnsat(body.forSome(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS))); - checkSat(body.forAll(a.oneOf(Expression.INTS)).forSome(b.oneOf(Expression.INTS))); - } - - /** - * UNSAT: all a: Int | some b: Int | b = MAXINT && (a = MAXINT => a+a = b+b) - * UNSAT: some a: Int | all b: Int | b = MAXINT && (a = MAXINT => a+a = b+b) - */ - public void testUnsatUnsat() { - Formula body = bs.eq(MAXINT).and(as.eq(MAXINT).implies(as.plus(as).eq(bs.plus(bs)))); - checkUnsat(body.forSome(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS))); - checkUnsat(body.forAll(b.oneOf(Expression.INTS)).forSome(a.oneOf(Expression.INTS))); - } - - /** - * SAT: all a: Int | all b: Int | b = MAXINT => (a = MAXINT => a+a = b+b) SAT: - * !(some a: Int | some b: Int | !(b = MAXINT => (a = MAXINT => a+a = b+b)) - */ - public void testSat() { - Formula body = bs.eq(MAXINT).implies(as.eq(MAXINT).implies(as.plus(as).eq(bs.plus(bs)))); - checkSat(body.forAll(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS))); - checkSat(body.not().forSome(b.oneOf(Expression.INTS)).forSome(a.oneOf(Expression.INTS)).not()); - } - - public void test2() { - Formula body = bs.eq(MAXINT).and(as.eq(MAXINT).implies(as.plus(as).eq(bs.plus(bs)))); - Formula qf = body.forSome(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS)); - checkSat(qf.implies(ZERO.eq(ZERO))); - checkSat(qf.implies(ZERO.neq(ZERO))); - - checkSat(qf.not().implies(ZERO.eq(ZERO))); - checkUnsat(qf.not().implies(ZERO.neq(ZERO))); - - Formula qfnot = body.not().forAll(b.oneOf(Expression.INTS)).forSome(a.oneOf(Expression.INTS)); - checkSat(qfnot.implies(ZERO.eq(ZERO))); - checkUnsat(qfnot.implies(ZERO.neq(ZERO))); - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/ReductionAndProofTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/ReductionAndProofTest.java deleted file mode 100644 index 5918468d2..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/ReductionAndProofTest.java +++ /dev/null @@ -1,212 +0,0 @@ -package tests.basic; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import junit.framework.TestCase; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.satlab.SATFactory; -import kodkod.engine.ucore.ECFPStrategy; -import kodkod.engine.ucore.NCEStrategy; -import kodkod.instance.Bounds; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; -import kodkod.util.collections.IdentityHashSet; -import kodkod.util.nodes.Nodes; - -/** - * Tests the reduction algorithm for trivially (un)satisfiable formulas, and - * does limited testing of core extraction. - * - * @author Emina Torlak - */ -public class ReductionAndProofTest extends TestCase { - - private final int USIZE = 10; - private final TupleFactory factory; - private final Solver solver; - private final Relation a, b, a2b, b2a; - private final Relation first, last, ordered, total; - private final Bounds bounds; - - public ReductionAndProofTest(String arg0) { - super(arg0); - this.solver = new Solver(); - solver.options().setLogTranslation(2); - solver.options().setSolver(SATFactory.MiniSatProver); - List atoms = new ArrayList(USIZE); - for (int i = 0; i < USIZE; i++) { - atoms.add("" + i); - } - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - this.a = Relation.unary("a"); - this.b = Relation.unary("b"); - this.a2b = Relation.binary("a2b"); - this.b2a = Relation.binary("b2a"); - this.first = Relation.unary("first"); - this.last = Relation.unary("last"); - this.ordered = Relation.unary("ordered"); - this.total = Relation.binary("total"); - this.bounds = new Bounds(universe); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - bounds.bound(a, factory.setOf("0", "1", "2", "3", "4")); - bounds.bound(b, factory.setOf("5", "6", "7", "8", "9")); - bounds.bound(a2b, bounds.upperBound(a).product(bounds.upperBound(b))); - bounds.bound(b2a, bounds.upperBound(b).product(bounds.upperBound(a))); - - bounds.boundExactly(first, factory.setOf("0")); - bounds.boundExactly(last, factory.setOf("4")); - bounds.boundExactly(ordered, bounds.upperBound(a)); - bounds.boundExactly(total, factory.setOf(factory.tuple("0", "1"), factory.tuple("1", "2"), factory.tuple("2", "3"), factory.tuple("3", "4"))); - } - - private Set reduce(Formula formula) { - - final Solution sol = solver.solve(formula, bounds); - assertEquals(Solution.Outcome.TRIVIALLY_UNSATISFIABLE, sol.outcome()); - sol.proof().minimize(null); - return Nodes.minRoots(formula, sol.proof().highLevelCore().values()); - - } - - public final void testReduction() { - Formula f0, f1, f2, f3, f4, f5, f6; - - f0 = a.difference(b).eq(a); // T - assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(f0, bounds).outcome()); - - f1 = a2b.join(b2a).some(); - assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(f0.or(f1), bounds).outcome()); - - f2 = total.totalOrder(ordered, first, last); - f3 = first.join(total).no(); // F - - Set reduction = reduce(f3.and(f0).and(f1).and(f2)); - assertEquals(1, reduction.size()); - assertTrue(reduction.contains(f3)); - - f4 = total.acyclic(); - f5 = total.closure().intersection(Expression.IDEN).some(); // F - - reduction = reduce(f4.and(f1).and(f0).and(f5)); - assertEquals(1, reduction.size()); - assertTrue(reduction.contains(f5)); - - bounds.boundExactly(a2b, bounds.upperBound(a2b)); - bounds.boundExactly(a, bounds.upperBound(a)); - bounds.boundExactly(b, bounds.upperBound(b)); - f6 = a2b.function(a, b); // F - - reduction = reduce(f1.and(f2).and(f6)); - assertEquals(1, reduction.size()); - assertTrue(reduction.contains(f6)); - - } - - public final void testProof() { - Variable v0 = Variable.unary("v0"), v1 = Variable.unary("v1"), v2 = Variable.unary("v2"); - Formula f0 = v0.join(a2b).eq(v1.union(v2)).and(v1.eq(v2).not()); - Formula f1 = f0.forSome(v0.oneOf(a).and(v1.oneOf(b)).and(v2.oneOf(b))); - Formula f2 = a2b.function(a, b); - Formula f3 = f1.and(f2).and(total.totalOrder(ordered, first, last)); - - Solution sol = null; - - solver.options().setLogTranslation(0); - solver.options().setSolver(SATFactory.MiniSat); - sol = solver.solve(f3, bounds); - assertEquals(Solution.Outcome.UNSATISFIABLE, sol.outcome()); - assertNull(sol.proof()); - solver.options().setLogTranslation(1); - sol = solver.solve(f3, bounds); - assertNull(sol.proof()); - - solver.options().setSolver(SATFactory.MiniSatProver); - sol = solver.solve(f3, bounds); - - // System.out.println(f3 + ", " + bounds); - - sol.proof().minimize(new ECFPStrategy()); - final Set top = Nodes.minRoots(f3, sol.proof().highLevelCore().values()); - assertEquals(2, top.size()); - assertTrue(top.contains(f1)); - assertTrue(top.contains(f2)); - // for(Iterator itr = sol.proof().core(); - // itr.hasNext(); ) { - // System.out.println(itr.next()); - // } - - } - - private Set reduce(Formula formula, int granularity) { - solver.options().setCoreGranularity(granularity); - final Solution sol = solver.solve(formula, bounds); - assertEquals(Solution.Outcome.TRIVIALLY_UNSATISFIABLE, sol.outcome()); - sol.proof().minimize(null); - return new IdentityHashSet(sol.proof().highLevelCore().values()); - - } - - private Set core(Formula formula, int granularity) { - solver.options().setCoreGranularity(granularity); - final Solution sol = solver.solve(formula, bounds); - assertEquals(Solution.Outcome.UNSATISFIABLE, sol.outcome()); - sol.proof().minimize(new NCEStrategy(sol.proof().log())); - return new IdentityHashSet(sol.proof().highLevelCore().values()); - - } - - public final void testGranularity() { - final Variable x = Variable.unary("x"); - final Variable y = Variable.unary("y"); - - final Formula f0 = a.some(); - final Formula f1 = b.some(); - final Formula f2 = a.eq(b); - - final Formula f3 = x.product(y).in(Expression.UNIV.product(Expression.UNIV)); - final Formula f4 = x.eq(y); - - final Formula f5 = f3.or(f4).forSome(y.oneOf(b)); - final Formula f6 = f5.forAll(x.oneOf(a)); - - final Formula f7 = f2.or(f6).not(); - - final Formula f8 = b.intersection(Expression.UNIV).some(); - - final Formula f9 = Formula.and(f0, f1, f7, f8); - - Set core = core(f9, 0); - assertEquals(2, core.size()); - assertTrue(core.contains(f1)); - assertTrue(core.contains(f7)); - - core = core(f9, 1); - assertEquals(2, core.size()); - assertTrue(core.contains(f1)); - assertTrue(core.contains(f6)); - - core = reduce(f9, 2); - assertEquals(2, core.size()); - assertTrue(core.contains(f1)); - assertTrue(core.contains(f5)); - - core = core(f9, 3); - assertEquals(2, core.size()); - assertTrue(core.contains(f1)); - assertTrue(core.contains(f3)); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/SkolemizationTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/SkolemizationTest.java deleted file mode 100644 index f7c64e4ef..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/SkolemizationTest.java +++ /dev/null @@ -1,223 +0,0 @@ -package tests.basic; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import junit.framework.TestCase; -import kodkod.ast.Decl; -import kodkod.ast.Decls; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.Multiplicity; -import kodkod.engine.Solver; -import kodkod.engine.fol2sat.HigherOrderDeclException; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.Universe; - -/** - * Tests skolemization. - */ -public class SkolemizationTest extends TestCase { - - private final int USIZE = 10; - private final TupleFactory factory; - private final Solver solver; - private final Relation r1a, r1b, r2a, r2b; - private final Bounds bounds; - - public SkolemizationTest(String arg0) { - super(arg0); - this.solver = new Solver(); - List atoms = new ArrayList(USIZE); - for (int i = 0; i < USIZE; i++) { - atoms.add("" + i); - } - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - this.r1a = Relation.unary("r1a"); - this.r1b = Relation.unary("r1b"); - this.r2a = Relation.binary("r2a"); - this.r2b = Relation.binary("r2b"); - this.bounds = new Bounds(universe); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - bounds.bound(r1a, factory.setOf("0", "1", "2", "3", "4")); - bounds.bound(r1b, factory.setOf("5", "6", "7", "8", "9")); - bounds.bound(r2a, bounds.upperBound(r1a).product(bounds.upperBound(r1b))); - bounds.bound(r2b, bounds.upperBound(r1b).product(bounds.upperBound(r1a))); - } - - private Instance solve(Formula formula) { - - return solver.solve(formula, bounds).instance(); - - } - - private final void testNoSkolems(Decls d, Formula f) { - Instance inst = solve(f.not()); - assertEquals(bounds.relations(), inst.relations()); - - inst = solve(f.or(r2a.in(r2b))); - assertEquals(bounds.relations(), inst.relations()); - - inst = solve(f.iff(r2a.in(r2b))); - assertEquals(bounds.relations(), inst.relations()); - - inst = solve(r2a.in(r2b).implies(f)); - assertEquals(bounds.relations(), inst.relations()); - - } - - private final void testNoSkolems(Multiplicity mult) { - final Variable v = Variable.unary("v"); - final Decl d = v.declare(mult, r1a); - - testNoSkolems(d, v.join(r2a).some().forAll(d).not()); - testNoSkolems(d, v.join(r2a).some().forSome(d)); - - } - - public final void testNoSkolems() { - testNoSkolems(Multiplicity.ONE); - try { - testNoSkolems(Multiplicity.LONE); - fail(); - } catch (HigherOrderDeclException hode) {} - try { - testNoSkolems(Multiplicity.SOME); - fail(); - } catch (HigherOrderDeclException hode) {} - try { - testNoSkolems(Multiplicity.SET); - fail(); - } catch (HigherOrderDeclException hode) {} - } - - private final void assertSkolems(Bounds bounds, Instance inst, Set skolems) { - assertEquals(skolems.size(), inst.relations().size() - bounds.relations().size()); - for (Relation r : inst.relations()) { - assertTrue(skolems.contains(r.name()) || bounds.relations().contains(r)); - } - } - - private final void testSkolems(Multiplicity mult) { - final Variable va = Variable.unary("va"); - final Variable vb = Variable.unary("vb"); - final Set skolems = new HashSet(4); - - Decl da = va.declare(mult, r1a); - Decl db = vb.declare(mult, r1b); - - skolems.add("$" + va.name()); - - Instance inst = solve(va.in(r1b.join(r2b)).forAll(da).not()); - assertSkolems(bounds, inst, skolems); - - inst = solve((r2b.some().implies(va.in(r1b.join(r2b)).forAll(da))).not()); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(r1b.join(r2b)).forSome(da)); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(r1b.join(r2b)).forSome(da).and(va.in(r1b).not().forAll(mult == Multiplicity.ONE ? da : va.oneOf(r1a)))); - assertSkolems(bounds, inst, skolems); - final Expression e0 = va.join(r2a); - final Formula f0 = e0.some().forSome(va.oneOf(r1a)); - final Formula f1 = e0.no().forAll(va.oneOf(r2a.join(r1b))); - - inst = solve(f0.and(f1)); - assertSkolems(bounds, inst, skolems); - - skolems.add("$" + vb.name()); - - inst = solve(va.in(vb.join(r2b)).forSome(da.and(vb.oneOf(va.join(r2a))))); - assertSkolems(bounds, inst, skolems); - - inst = solve((va.in(vb.join(r2b)).forAll(vb.oneOf(va.join(r2a))).forAll(da)).not()); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(vb.join(r2b)).forAll(da.and(db)).not()); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(vb.join(r2b)).forSome(da.and(db))); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(r1b.join(r2b)).forSome(da).and(r1b.in(vb).forAll(db).not())); - assertSkolems(bounds, inst, skolems); - - } - - public final void testSkolems() { - testSkolems(Multiplicity.ONE); - testSkolems(Multiplicity.LONE); - testSkolems(Multiplicity.SOME); - testSkolems(Multiplicity.SET); - } - - private final void testDeepSkolems(Multiplicity mult) { - final Variable va = Variable.unary("va"); - final Variable vb = Variable.unary("vb"); - final Variable vc = Variable.unary("vc"); - final Variable vd = Variable.unary("vd"); - final Set skolems = new HashSet(4); - - Decl da1 = va.oneOf(r1a); - Decl db = vb.declare(mult, r1b); - Decl dc = vc.declare(mult, r1a); - Decl dc1 = vc.oneOf(r1a); - Decl dd = vd.declare(mult, r1b); - Decl dd1 = vd.oneOf(r1b); - - skolems.add("$" + vb.name()); - - Instance inst = solve(va.in(vb.join(r2b)).forSome(db).forAll(da1)); - assertSkolems(bounds, inst, skolems); - - skolems.add("$" + vc.name()); - inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forAll(da1).forSome(dc).forAll(dd1)); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forSome(dc).forAll(da1.and(dd1))); - assertSkolems(bounds, inst, skolems); - - skolems.add("$" + vd.name()); - inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forAll(da1).forSome(dc).not().forAll(dd).not()); - - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forAll(dc).forAll(db).forSome(da1).not().forAll(dd1)); - skolems.remove("$" + vd.name()); - assertSkolems(bounds, inst, skolems); - - inst = solve(va.in(vb.join(r2b).union(vd.join(r2b)).union(vc)).forSome(db).forAll(dc1).forAll(da1).forAll(dd1)); - skolems.remove("$" + vc.name()); - assertSkolems(bounds, inst, skolems); - - } - - public final void testDeepSkolems() { - solver.options().setSkolemDepth(3); - testDeepSkolems(Multiplicity.ONE); - testDeepSkolems(Multiplicity.LONE); - testDeepSkolems(Multiplicity.SOME); - testDeepSkolems(Multiplicity.SET); - final Variable va = Variable.unary("va"); - final Variable vb = Variable.unary("vb"); - Decl da1 = va.oneOf(r1a); - Decl db = vb.oneOf(r1b); - final Formula f0 = va.in(vb.join(r2b)); - final Formula f1 = f0.forAll(db).not().forAll(da1); - final Formula f2 = f0.forSome(db).forSome(da1); - Instance inst = solve(f1.and(f2)); - assertEquals(bounds.relations().size() + 3, inst.relations().size()); - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/SparseSequenceTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/SparseSequenceTest.java deleted file mode 100644 index 39765d3ed..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/SparseSequenceTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package tests.basic; - -import java.util.Iterator; - -import junit.framework.TestCase; -import kodkod.util.ints.ArraySequence; -import kodkod.util.ints.IndexedEntry; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; -import kodkod.util.ints.Ints; -import kodkod.util.ints.RangeSequence; -import kodkod.util.ints.SparseSequence; -import kodkod.util.ints.TreeSequence; - -/** - * Tests sparse sequence implementation(s). - * - * @author Emina Torlak - */ -public class SparseSequenceTest extends TestCase { - - private SparseSequence s0; - - @Override - protected void setUp() throws Exception { - s0 = new TreeSequence(); - } - - public void testPutGetRemoveSize() { - assertTrue(s0.size() == 0); - s0.put(0, 0); - assertTrue(s0.get(0).intValue() == 0); - assertTrue(s0.size() == 1); - s0.put(Integer.MIN_VALUE, Integer.MIN_VALUE); - assertTrue(s0.get(Integer.MIN_VALUE).intValue() == Integer.MIN_VALUE); - assertTrue(s0.size() == 2); - s0.put(Integer.MAX_VALUE, Integer.MAX_VALUE); - assertTrue(s0.get(Integer.MAX_VALUE).intValue() == Integer.MAX_VALUE); - assertTrue(s0.size() == 3); - s0.put(2, 0); - assertTrue(s0.get(0).intValue() == 0); - assertTrue(s0.size() == 4); - s0.put(1, 0); - assertTrue(s0.get(1).intValue() == 0); - assertTrue(s0.size() == 5); - s0.put(-1, 0); - assertTrue(s0.get(-1).intValue() == 0); - assertTrue(s0.size() == 6); - s0.put(3, 0); - assertTrue(s0.get(3).intValue() == 0); - assertTrue(s0.size() == 7); - s0.remove(0); - assertTrue(s0.size() == 6); - s0.remove(Integer.MIN_VALUE); - assertTrue(s0.size() == 5); - s0.remove(3); - assertTrue(s0.size() == 4); - s0.put(2, 2); - assertTrue(s0.get(2).intValue() == 2); - assertTrue(s0.size() == 4); - s0.put(0, 2); - assertTrue(s0.get(0).intValue() == 2); - assertTrue(s0.size() == 5); - s0.put(1, 2); - assertTrue(s0.get(1).intValue() == 2); - assertTrue(s0.size() == 5); - // System.out.println(s0); - } - - public void testIterator() { - for (int i = 0; i < 10; i++) - s0.put(i, 0); - // System.out.println(s0); - Iterator> iter = s0.iterator(); - for (int i = 0; i < 10; i++) { - iter.next(); - // System.out.println(iter.next()); - } - // if (iter.hasNext()) - // System.out.println(iter.next()); - assertFalse(iter.hasNext()); - } - - public void testRange() { - s0 = new RangeSequence(); - s0.put(16, 0); - s0.put(17, 0); - // System.out.println(s0); - s0.put(16, 1); - s0.put(17, 2); - // System.out.println(s0); - } - - public void testRemove() { - // [2597 b NIL [2630 r [2616 b [2604 b NIL NIL] [2623 b NIL NIL]] - // [2658 b [2644 r [2637 b NIL NIL] [2651 b NIL [2655 r NIL NIL]]] [2660 - // b NIL NIL]]]] - // s0 = new TreeSequence(); - // s0.put(2597, 0); - // s0.put(2630, 0); - // s0.put(2616, 0); - // s0.put(2604, 0); - // s0.put(2623, 0); - // s0.put(2658, 0); - // s0.put(2644, 0); - // s0.put(2637, 0); - // s0.put(2651, 0); - // System.out.println(s0); - // s0.remove(2616); - // System.out.println(s0); - - // root: [221 b [51 r [45 b NIL NIL] [168 b NIL NIL]] [331 b NIL NIL]] - // z: [51 b null null] - // root: [221 b [168 b [45 r NIL NIL] NIL] [331 b NIL NIL]] - s0.clear(); - - s0.put(331, 0); - s0.put(221, 0); - s0.put(168, 0); - // s0.put(48, 0); - // s0.put(42, 0); - s0.put(45, 0); - s0.put(51, 0); - - System.out.println(s0); - s0.remove(51); - System.out.println(s0); - } - - // public void testFirstLast() { - // for(int i = 0; i < 10; i++) - // s0.put(i, 0); - // IndexedEntry e0 = s0.first(); - // while (e0 != null) { - // System.out.println(e0); - // e0 = s0.successor(e0.index()); - // } - // } - - public void testClone() { - final IntSet s = Ints.bestSet(3); - s.add(1); - s.add(2); - s0 = new ArraySequence(s); - s0.put(1, 0); - s0.put(2, 0); - try { - SparseSequence s1 = s0.clone(); - assertTrue(s1.equals(s0)); - assertNotSame(s1, s0); - SparseSequence s2 = new ArraySequence(s); - s2.putAll(s0); - s1.remove(1); - assertTrue(s2.equals(s0)); - assertFalse(s1.equals(s0)); - } catch (CloneNotSupportedException e) { - assert false; - } - - } - - public void testIntTreeSet() { - IntTreeSet s = new IntTreeSet(); - // s.add(1); - // System.out.println(s); - // s.add(3); - // System.out.println(s); - // s.add(2); - // System.out.println(s); - s.add(331); - s.add(221); - for (int i = 42; i <= 45; i++) - s.add(i); - for (int i = 47; i <= 51; i++) - s.add(i); - s.add(167); - s.add(168); - s.add(220); - - System.out.println(s); - s.add(46); - System.out.println(s); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/SymmetryBreakingTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/SymmetryBreakingTest.java deleted file mode 100644 index 879625b85..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/SymmetryBreakingTest.java +++ /dev/null @@ -1,186 +0,0 @@ -package tests.basic; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.Statistics; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Tests symmetry breaking code for total orderings and acyclic relations. - * - * @author Emina Torlak - */ -public class SymmetryBreakingTest extends TestCase { - - private static final int USIZE = 10; - private final TupleFactory factory; - private final Relation to1, ord1, first1, last1, to2, ord2, first2, last2, to3, ord3, first3, last3, ac1, ac2, - ac3, r1, r2; - private Bounds bounds; - private int pVars, iVars, clauses; - private final Solver solver; - - public SymmetryBreakingTest(String arg0) { - super(arg0); - this.solver = new Solver(); - - List atoms = new ArrayList(USIZE); - for (int i = 0; i < USIZE; i++) { - atoms.add("" + i); - } - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - - to1 = Relation.binary("to1"); - ord1 = Relation.unary("ord1"); - first1 = Relation.unary("first1"); - last1 = Relation.unary("last1"); - - to2 = Relation.binary("to2"); - ord2 = Relation.unary("ord2"); - first2 = Relation.unary("first2"); - last2 = Relation.unary("last2"); - - to3 = Relation.binary("to3"); - ord3 = Relation.unary("ord3"); - first3 = Relation.unary("first3"); - last3 = Relation.unary("last3"); - - ac1 = Relation.binary("ac1"); - ac2 = Relation.binary("ac2"); - ac3 = Relation.binary("ac3"); - - r1 = Relation.unary("r1"); - r2 = Relation.binary("r2"); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - bounds = new Bounds(factory.universe()); - } - - private Instance solve(Formula f, Bounds b) { - - final Solution sol = solver.solve(f, b); - final Statistics stats = sol.stats(); - pVars = stats.primaryVariables(); - iVars = stats.variables() - pVars; - clauses = stats.clauses(); - return sol.instance(); - - } - - private Instance solve(Formula f) { - return solve(f, bounds); - } - - private void assertPrimVarNum(int primVars) { - assertEquals(primVars, pVars); - } - - private void assertAuxVarNum(int auxVars) { - assertEquals(auxVars, iVars); - } - - private void assertClauseNum(int clauses) { - assertEquals(clauses, this.clauses); - } - - public void testTotalOrdering() { - bounds.bound(to1, factory.area(factory.tuple("0", "0"), factory.tuple("4", "4"))); - bounds.bound(ord1, factory.setOf("0", "1", "2", "3", "4")); - bounds.bound(first1, bounds.upperBound(ord1)); - bounds.bound(last1, bounds.upperBound(ord1)); - final Formula ordered1 = to1.totalOrder(ord1, first1, last1); - assertNotNull(solve(to1.some().and(ordered1))); - assertPrimVarNum(0); - assertAuxVarNum(0); - assertClauseNum(0); - - bounds.bound(r1, factory.range(factory.tuple("0"), factory.tuple("4"))); - assertNotNull(solve(to1.join(r1).some().and(ordered1))); - assertPrimVarNum(bounds.upperBound(r1).size()); - - bounds.boundExactly(r1, bounds.upperBound(r1)); - assertNotNull(solve(to1.join(r1).some().and(ordered1))); - assertPrimVarNum(0); - - bounds.bound(to2, factory.setOf("5", "6", "7", "8", "9").product(factory.setOf("5", "7", "8"))); - bounds.bound(ord2, factory.setOf("5", "7", "8")); - bounds.bound(first2, bounds.upperBound(ord2)); - bounds.bound(last2, bounds.upperBound(ord2)); - final Formula ordered2 = to2.totalOrder(ord2, first2, last2); - assertNotNull(solve(to1.difference(to2).some().and(ordered2).and(ordered1))); - assertPrimVarNum(0); - assertAuxVarNum(0); - assertClauseNum(0); - - bounds.bound(to3, factory.allOf(2)); - bounds.bound(ord3, factory.allOf(1)); - bounds.bound(first3, factory.setOf("9")); - bounds.bound(last3, factory.setOf("8")); - final Formula ordered3 = to3.totalOrder(ord3, first3, last3); - assertNotNull(solve(to3.product(to1).some().and(ordered1).and(ordered3))); - assertPrimVarNum(bounds.upperBound(to3).size() + bounds.upperBound(ord3).size() + 2); - - // SAT solver takes a while - // bounds.boundExactly(r2, factory.setOf(factory.tuple("9","8"))); - // assertNotNull(solve(r2.in(to3).and(ordered3))); - bounds.bound(to3, factory.allOf(2)); - bounds.bound(ord3, factory.setOf("3")); - bounds.bound(first3, factory.allOf(1)); - bounds.bound(last3, factory.allOf(1)); - - Instance instance = solve(ordered3); - assertNotNull(instance); - assertTrue(instance.tuples(to3).isEmpty()); - assertTrue(instance.tuples(ord3).equals(bounds.upperBound(ord3))); - assertTrue(instance.tuples(first3).equals(bounds.upperBound(ord3))); - assertTrue(instance.tuples(last3).equals(bounds.upperBound(ord3))); - } - - public void testAcyclic() { - bounds.bound(ac1, factory.area(factory.tuple("0", "0"), factory.tuple("4", "4"))); - assertNotNull(solve(ac1.some().and(ac1.acyclic()))); - assertPrimVarNum(10); - - bounds.bound(r1, factory.range(factory.tuple("0"), factory.tuple("4"))); - assertNotNull(solve(ac1.join(r1).some().and(ac1.acyclic()))); - assertPrimVarNum(10 + bounds.upperBound(r1).size()); - - TupleSet ac2b = factory.setOf("5", "6", "7", "8"); - ac2b = ac2b.product(ac2b); - bounds.bound(ac2, ac2b); - assertNotNull(solve(ac1.difference(ac2).some().and(ac1.acyclic()).and(ac2.acyclic()))); - assertPrimVarNum(10 + 6); - - bounds.boundExactly(r2, factory.setOf(factory.tuple("5", "6"))); - assertNotNull(solve(ac2.join(r2).some().and(ac2.acyclic()))); - - final TupleSet ac3Bound = factory.allOf(2); - ac3Bound.remove(factory.tuple("9", "9")); - bounds.bound(ac3, ac3Bound); - - assertNotNull(solve(ac1.difference(ac2).union(ac3).some().and(ac1.acyclic()).and(ac2.acyclic()))); - assertPrimVarNum(ac3Bound.size() + 10 + 6); - - bounds.bound(to3, factory.allOf(2)); - bounds.bound(ord3, factory.setOf("0", "1", "2")); - bounds.bound(first3, bounds.upperBound(ord3)); - bounds.bound(last3, bounds.upperBound(ord3)); - assertNotNull(solve(to3.product(ac1).some().and(ac1.acyclic()).and(to3.totalOrder(ord3, first3, last3)))); - assertPrimVarNum(bounds.upperBound(ac1).size()); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/TranslatorTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/TranslatorTest.java deleted file mode 100644 index d4d09825a..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/TranslatorTest.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * TranslatorTest.java - * Created on Jul 6, 2005 - */ -package tests.basic; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import junit.framework.TestCase; -import kodkod.ast.Expression; -import kodkod.ast.Formula; -import kodkod.ast.IntConstant; -import kodkod.ast.IntExpression; -import kodkod.ast.Relation; -import kodkod.ast.Variable; -import kodkod.ast.operator.ExprOperator; -import kodkod.ast.operator.FormulaOperator; -import kodkod.ast.operator.IntOperator; -import kodkod.ast.operator.Multiplicity; -import kodkod.ast.operator.Quantifier; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.instance.Bounds; -import kodkod.instance.Instance; -import kodkod.instance.Tuple; -import kodkod.instance.TupleFactory; -import kodkod.instance.TupleSet; -import kodkod.instance.Universe; - -/** - * Tests {@link kodkod.engine.fol2sat.Translator FOL to SAT translation} and - * {@link kodkod.engine.fol2sat.Sat2CnfTranslator SAT to CNF translation}. - * - * @author Emina Torlak - */ -public class TranslatorTest extends TestCase { - - private final TupleFactory factory; - private final Solver solver; - private final Relation[] r1, r2, r3; - private final Tuple t112, t212, t312; - private final Bounds bounds; - - public TranslatorTest(String arg0) { - super(arg0); - this.solver = new Solver(); - List atoms = new ArrayList(10); - for (int i = 0; i < 10; i++) { - atoms.add(i); - } - final Universe universe = new Universe(atoms); - this.factory = universe.factory(); - this.t112 = factory.tuple(1, 4); - this.t212 = factory.tuple(2, 57); - this.t312 = factory.tuple(3, 345); - this.r1 = new Relation[4]; - this.r2 = new Relation[4]; - this.r3 = new Relation[4]; - for (int i = 0; i < 4; i++) { - - r1[i] = Relation.unary("r1" + i); - r2[i] = Relation.binary("r2" + i); - r3[i] = Relation.ternary("r3" + i); - - } - - bounds = new Bounds(universe); - - bounds.bound(r1[0], factory.allOf(1)); - bounds.bound(r1[1], factory.range(factory.tuple(2), t112)); - bounds.bound(r1[2], factory.range(t112, t112)); - bounds.bound(r1[3], factory.range(factory.tuple(5), factory.tuple(8))); - - bounds.bound(r2[0], factory.allOf(2)); - bounds.bound(r2[1], factory.area(factory.tuple(2, 35), t212)); - bounds.bound(r2[2], factory.setOf(t212)); - bounds.bound(r2[3], factory.area(factory.tuple(2, 60), factory.tuple(2, 86))); - - bounds.bound(r3[0], factory.allOf(3)); - bounds.bound(r3[1], factory.area(factory.tuple(3, 123), t312)); - bounds.bound(r3[2], factory.setOf(t312)); - bounds.bound(r3[3], factory.area(factory.tuple(3, 700), factory.tuple(3, 897))); - - // System.out.println(bounds.upperBound(r3[0]).size()); - // System.out.println(bounds.upperBound(r3[1]).size()); - // System.out.println(bounds.upperBound(r3[2]).size()); - // System.out.println(bounds.upperBound(r3[3]).size()); - - } - - private Instance solve(Formula formula) { - - return solver.solve(formula, bounds).instance(); - - } - - private boolean isSatisfiable(Formula formula) { - return (solve(formula) == null ? false : true); - } - - private final void testIntersectionMultiplicity(Multiplicity mult, Relation p, Relation q, Tuple intersection) { - final Instance m = solve(p.intersection(q).apply(mult)); - assertNotNull(m); - final Set ps = m.tuples(p), qs = m.tuples(q); - assertFalse(ps.isEmpty()); - assertFalse(qs.isEmpty()); - assertTrue(ps.contains(intersection)); - assertTrue(qs.contains(intersection)); - } - - private final void testTranslateNonEmptyMultiplicity(Multiplicity mult) { - - testTranslateMultiplicity(mult, true, false); - testIntersectionMultiplicity(mult, r1[1], r1[2], t112); - testIntersectionMultiplicity(mult, r2[1], r2[2], t212); - testIntersectionMultiplicity(mult, r3[1], r3[2], t312); - } - - private final void testTranslateMultiplicity(Multiplicity mult, boolean trueTest, boolean falseTest) { - for (int i = 0; i < 4; i++) { - assertTrue(isSatisfiable(r1[i].apply(mult))); - assertTrue(isSatisfiable(r2[i].apply(mult))); - // assertTrue(solve(r3[i].apply(mult))); - } - - // mult rx1 & rx3 - assertEquals(falseTest, isSatisfiable(r1[1].intersection(r1[3]).apply(mult))); - assertEquals(falseTest, isSatisfiable(r2[1].intersection(r2[3]).apply(mult))); - assertEquals(falseTest, isSatisfiable(r3[1].intersection(r3[3]).apply(mult))); - - // mult rx3 - rx3 - assertEquals(falseTest, isSatisfiable(r1[3].difference(r1[3]).apply(mult))); - assertEquals(falseTest, isSatisfiable(r2[3].difference(r2[3]).apply(mult))); - assertEquals(falseTest, isSatisfiable(r3[3].difference(r3[3]).apply(mult))); - - // mult r11->r13 & r21 - assertEquals(trueTest, isSatisfiable(r1[1].product(r1[3]).intersection(r2[1]).apply(mult))); - // mult r11->r21 & r31 - assertEquals(trueTest, isSatisfiable(r1[1].product(r2[1]).intersection(r3[1]).apply(mult))); - - // mult rx1 + rx3 - assertEquals(trueTest, isSatisfiable(r1[1].union(r1[3]).apply(mult))); - assertEquals(trueTest, isSatisfiable(r2[1].union(r2[3]).apply(mult))); - assertEquals(trueTest, isSatisfiable(r3[1].union(r3[3]).apply(mult))); - - // mult r21.r13 - assertEquals(trueTest, isSatisfiable(r2[1].join(r1[3]).apply(mult))); - // mult r31.r21 - assertEquals(trueTest, isSatisfiable(r3[1].join(r2[1]).apply(mult))); - - // mult ^r21 - assertEquals(trueTest, isSatisfiable(r2[1].closure().apply(mult))); - // mult ~r23 - assertEquals(trueTest, isSatisfiable(r2[3].transpose().apply(mult))); - } - - public final void testTranslateMultiplicityFormula_NO() { - testTranslateMultiplicity(Multiplicity.NO, true, true); - } - - public final void testTranslateMultiplicityFormula_LONE() { - // testTranslateMultiplicity(MultiplicityFormula.Multiplicity.LONE, - // true, true); - assertEquals(true, isSatisfiable(r3[1].union(r3[3]).apply(Multiplicity.LONE))); - // assertEquals(true, - // isSatisfiable(r3[3].difference(r3[1]).apply(MultiplicityFormula.Multiplicity.LONE))); - } - - public final void testTranslateMultiplicityFormula_ONE() { - testTranslateNonEmptyMultiplicity(Multiplicity.ONE); - } - - public final void testTranslateMultiplicityFormula_SOME() { - testTranslateNonEmptyMultiplicity(Multiplicity.SOME); - } - - public final void testTranslateComparisonFormula() { - for (int i = 0; i < 4; i++) { - assertTrue(isSatisfiable(r1[i].in(r1[i]))); - assertTrue(isSatisfiable(r2[i].in(r2[i]))); - assertTrue(isSatisfiable(r3[i].in(r3[i]))); - } - - // some rx2 && (rx1 & rx2 in rx2) - assertTrue(isSatisfiable(r1[2].some().and(r1[1].intersection(r1[2]).in(r1[2])))); - assertTrue(isSatisfiable(r2[2].some().and(r2[1].intersection(r2[2]).in(r2[2])))); - assertTrue(isSatisfiable(r3[2].some().and(r3[1].intersection(r3[2]).in(r3[2])))); - - // one rx2 && (rx1 & rx2 = rx2) - assertTrue(isSatisfiable(r1[2].one().and(r1[1].intersection(r1[2]).eq(r1[2])))); - assertTrue(isSatisfiable(r2[2].one().and(r2[1].intersection(r2[2]).eq(r2[2])))); - assertTrue(isSatisfiable(r3[2].one().and(r3[1].intersection(r3[2]).eq(r3[2])))); - - // !(rx3 in rx0) - assertTrue(isSatisfiable(r1[3].in(r1[0]).not())); - assertTrue(isSatisfiable(r2[3].in(r2[0]).not())); - assertTrue(isSatisfiable(r3[3].in(r3[0]).not())); - - // some rx0 && (rx1 + rx2 + rx3 in rx0) - assertTrue(isSatisfiable(r1[0].some().and(r1[1].union(r1[2]).union(r1[3]).in(r1[0])))); - assertTrue(isSatisfiable(r2[0].some().and(r2[1].union(r2[2]).union(r2[3]).in(r2[0])))); - assertTrue(isSatisfiable(r3[0].some().and(r3[1].union(r3[2]).union(r3[3]).in(r3[0])))); - - // System.out.println("-----------------"); - // System.out.println(bounds.upperBound(r1[1])); - // System.out.println(bounds.upperBound(r1[3])); - // System.out.println(bounds.upperBound(r2[1])); - // some r11 && some r13 && r11->r13 = r21 - assertTrue(isSatisfiable(r1[1].some().and(r1[3].some()).and(r1[1].product(r1[3]).eq(r2[1])))); - - // r21.r13 in r11 - assertTrue(isSatisfiable(r2[1].join(r1[3]).in(r1[1]))); - - // *r22 in r21 + iden - assertTrue(isSatisfiable(r2[2].reflexiveClosure().in(r2[1].union(Expression.IDEN)))); - } - - private final void testTranslateQuantifiedFormula(Quantifier quant) { - // quant v1: r1[i] | v1 in rx0 - final Variable v1 = Variable.unary("v1"), v2 = Variable.unary("v2"); - for (int i = 1; i < 4; i++) { - assertTrue(isSatisfiable(v1.in(r1[0]).quantify(quant, v1.oneOf(r1[i])))); - } - - // quant v1 : r1[2], v2: r1[3] | v1->v2 in r2[1] - assertTrue(isSatisfiable(v1.product(v2).in(r2[1]).quantify(quant, v1.oneOf(r1[2]).and(v2.oneOf(r1[3]))))); - - // quant v1 : r1[3] | some r3[3].v1 & r2[3] - assertTrue(isSatisfiable(r3[3].join(v1).intersection(r2[3]).some().quantify(quant, v1.oneOf(r1[3])))); - - // quant v1 : r1[3] | some v1.(~r2[1]) - assertTrue(isSatisfiable(v1.join(r2[1].transpose()).some().quantify(quant, v1.oneOf(r1[3])))); - // quant v1: r1[3] | some v1.(^r2[3]) - assertTrue(isSatisfiable(v1.join(r2[3].closure()).some().quantify(quant, v1.oneOf(r1[3])))); - - } - - public final void testTranslateQuantifiedFormula_ALL() { - testTranslateQuantifiedFormula(Quantifier.ALL); - } - - public final void testTranslateQuantifiedFormula_SOME() { - testTranslateQuantifiedFormula(Quantifier.SOME); - } - - public final void testTranslateComprehension() { - final Variable v1 = Variable.unary("v1"), v2 = Variable.unary("v2"); - - // some { v1: r11 + r12 | some v1.r21 } - assertTrue(isSatisfiable((v1.join(r2[1]).some()).comprehension(v1.oneOf(r1[1].union(r1[2]))).some())); - - // one { v1: r13, v2: r12 | v1->v2 in r23 } - assertTrue(isSatisfiable((v1.product(v2).in(r2[3]).comprehension(v1.oneOf(r1[3]).and(v2.oneOf(r1[2])))).one())); - - // one { v1: r13, v2: r12 | v2->v1 in ~r23 } - assertTrue(isSatisfiable((v2.product(v1).in(r2[3].transpose()).comprehension(v1.oneOf(r1[3]).and(v2.oneOf(r1[2])))).one())); - - } - - public final void testTranslateProjection() { - - assertTrue(isSatisfiable(r3[0].eq(r2[0].project(IntConstant.constant(0), IntConstant.constant(1), IntConstant.constant(0))))); - - assertTrue(isSatisfiable(r2[1].in(r3[0].project(r1[3].count(), r1[2].count())))); - - final Variable v = Variable.nary("r", 2); - assertFalse(isSatisfiable(v.transpose().eq(v.project(IntConstant.constant(1), IntConstant.constant(0))).not().forSome(v.setOf(r2[0])))); - - bounds.boundExactly(r3[0], bounds.upperBound(r3[0])); - bounds.boundExactly(r2[0], bounds.upperBound(r2[0])); - - assertTrue(isSatisfiable(r3[0].project(IntConstant.constant(0), IntConstant.constant(1)).eq(r2[0]))); - assertTrue(isSatisfiable(r3[0].project(IntConstant.constant(0), IntConstant.constant(4), IntConstant.constant(2)).eq(Expression.NONE.product(Expression.NONE).product(Expression.NONE)))); - assertTrue(isSatisfiable(r3[0].project(IntConstant.constant(0), IntConstant.constant(-1), IntConstant.constant(2)).eq(Expression.NONE.product(Expression.NONE).product(Expression.NONE)))); - - } - - public final void testIFF() { - // some r11 && (r11 in r12 iff r12 in r11) - Formula f = r1[1].some().and(r1[1].in(r1[2]).iff(r1[2].in(r1[1]))); - assertTrue(isSatisfiable(f)); - // some r11 && no r12 && (r11 in r12 iff r12 in r11) - assertFalse(isSatisfiable(f.and(r1[2].no()))); - } - - public final void testFlattening() { - final List atoms = new ArrayList(9); - atoms.add("-1"); - atoms.add("0"); - atoms.add("1"); - atoms.add("null"); - for (int i = 0; i < 5; i++) { - atoms.add("m" + i); - } - final Universe u = new Universe(atoms); - final TupleFactory t = u.factory(); - - final Relation[] m = new Relation[5]; - for (int i = 0; i < 5; i++) { - m[i] = Relation.unary("m" + i); - } - - final Relation univ = Relation.unary("univ"), none = Relation.unary("none"), iden = Relation.binary("inden"), - mutant = Relation.unary("mutant"), inc = Relation.binary("inc"), add = Relation.ternary("add"), - i0 = Relation.unary("i0"), zero = Relation.unary("0"), one = Relation.unary("1"), - ints = Relation.unary("int"); - - final Bounds b = new Bounds(u); - - b.boundExactly(univ, t.allOf(1)); - b.boundExactly(none, t.noneOf(1)); - TupleSet idenSet = t.noneOf(2); - for (String atom : atoms) { - idenSet.add(t.tuple(atom, atom)); - } - b.boundExactly(iden, idenSet); - - b.bound(mutant, t.range(t.tuple("m0"), t.tuple("m4"))); - for (int i = 0; i < 5; i++) { - b.boundExactly(m[i], t.setOf("m" + i)); - } - - b.bound(i0, t.range(t.tuple("-1"), t.tuple("1"))); - b.boundExactly(zero, t.setOf(t.tuple("0"))); - b.boundExactly(one, t.setOf(t.tuple("1"))); - b.boundExactly(ints, t.allOf(1)); - b.boundExactly(inc, t.setOf(t.tuple("-1", "0"), t.tuple("0", "1"))); - - // [1, 1, -1], [1, -1, 0], [1, 0, 1], [-1, 1, 0], [-1, -1, 1], - // [-1, 0, -1], [0, 1, 1], [0, -1, -1], [0, 0, 0]] - b.boundExactly(add, t.setOf(t.tuple("1", "1", "-1"), t.tuple("1", "-1", "0"), t.tuple("1", "0", "1"), t.tuple("-1", "1", "0"), t.tuple("-1", "-1", "1"), t.tuple("-1", "0", "-1"), t.tuple("0", "1", "1"), t.tuple("0", "-1", "-1"), t.tuple("0", "0", "0"))); - - /* - * ((one i0 && one mutant) && !((if (i0 in (0 . ^~inc)) then ((add . 0) . i0) - * else i0) = (if !((if (mutant in m4) then (if (i0 in 0) then 1 else 0) else - * (if (mutant in m3) then (if ((i0 = 0) || (i0 in (0 . ^~inc))) then 1 else 0) - * else (if (mutant in m2) then (if (i0 in (0 . ^inc)) then 1 else 0) else (if - * (mutant in m1) then (if ((i0 = 0) || (i0 in (0 . ^inc))) then 1 else 0) else - * (if (mutant in m0) then (if !(i0 in 0) then 1 else 0) else (if (i0 in (0 . - * ^~inc)) then 1 else 0)))))) in 0) then ((add . 0) . i0) else i0))) - */ - - final Formula[] cm = new Formula[5]; - for (int i = 0; i < 5; i++) { - cm[i] = mutant.in(m[i]); - } - - // (i0 in (0 . ^~inc)) - final Formula fs0 = i0.in(zero.join(inc.transpose().closure())); - // (i0 in (0 . ^inc)) - final Formula fs1 = i0.in(zero.join(inc.closure())); - // (i0 = 0) - final Formula fs2 = i0.eq(zero); - - final Expression em0 = cm[0].thenElse(i0.in(zero).not().thenElse(one, zero), fs0.thenElse(one, zero)); - final Expression em1 = cm[1].thenElse((fs2.or(fs1)).thenElse(one, zero), em0); - final Expression em2 = cm[2].thenElse(fs1.thenElse(one, zero), em1); - final Expression em3 = cm[3].thenElse(fs2.or(fs0).thenElse(one, zero), em2); - final Expression em4 = cm[4].thenElse(i0.in(zero).thenElse(one, zero), em3); - - final Expression es1 = add.join(zero).join(i0); - final Expression expr2 = em4.in(zero).not().thenElse(es1, i0); - final Expression expr1 = fs0.thenElse(es1, i0); - - final Formula f = i0.one().and(mutant.one()).and(expr1.eq(expr2).not()); - - final Instance instance = solver.solve(f, b).instance(); - assertNotNull(instance); - - // System.out.println(instance); - - } - - private final void testNary(ExprOperator op) { - bounds.bound(r1[0], factory.range(factory.tuple(1, 0), factory.tuple(1, 3))); - bounds.bound(r1[1], factory.range(factory.tuple(1, 2), factory.tuple(1, 5))); - bounds.bound(r1[3], factory.range(factory.tuple(1, 3), factory.tuple(1, 6))); - - for (int i = 2; i <= 5; i++) { - final Expression[] exprs = new Expression[i]; - exprs[0] = r1[0]; - Expression binExpr = r1[0]; - for (int j = 1; j < i; j++) { - binExpr = binExpr.compose(op, r1[j % 4]); - exprs[j] = r1[j % 4]; - } - Expression nExpr = Expression.compose(op, exprs); - final Solution sol = solver.solve(binExpr.eq(nExpr).not(), bounds); - assertNull(sol.instance()); - } - - } - - public final void testNaryUnion() { - testNary(ExprOperator.UNION); - } - - public final void testNaryIntersection() { - testNary(ExprOperator.INTERSECTION); - } - - public final void testNaryProduct() { - testNary(ExprOperator.PRODUCT); - } - - public final void testNaryOverride() { - testNary(ExprOperator.OVERRIDE); - } - - private final void testNary(IntOperator op) { - bounds.bound(r1[0], factory.range(factory.tuple(1, 0), factory.tuple(1, 3))); - bounds.bound(r1[1], factory.range(factory.tuple(1, 2), factory.tuple(1, 5))); - bounds.bound(r1[3], factory.range(factory.tuple(1, 3), factory.tuple(1, 6))); - - for (int i = 2; i <= 5; i++) { - final IntExpression[] exprs = new IntExpression[i]; - exprs[0] = r1[0].count(); - IntExpression binExpr = r1[0].count(); - for (int j = 1; j < i; j++) { - binExpr = binExpr.compose(op, r1[j % 4].count()); - exprs[j] = r1[j % 4].count(); - } - IntExpression nExpr = IntExpression.compose(op, exprs); - final Solution sol = solver.solve(binExpr.eq(nExpr).not(), bounds); - assertNull(sol.instance()); - } - - } - - public final void testNaryPlus() { - testNary(IntOperator.PLUS); - } - - public final void testNaryMultiply() { - testNary(IntOperator.MULTIPLY); - } - - public final void testNaryBitwiseAnd() { - testNary(IntOperator.AND); - } - - public final void testNaryBitwiseOr() { - testNary(IntOperator.OR); - } - - private final void testNary(FormulaOperator op) { - bounds.bound(r1[0], factory.range(factory.tuple(1, 0), factory.tuple(1, 3))); - bounds.bound(r1[1], factory.range(factory.tuple(1, 2), factory.tuple(1, 5))); - bounds.bound(r1[3], factory.range(factory.tuple(1, 3), factory.tuple(1, 6))); - - for (int i = 2; i <= 5; i++) { - final Formula[] exprs = new Formula[i]; - exprs[0] = r1[0].some(); - Formula binExpr = r1[0].some(); - for (int j = 1; j < i; j++) { - binExpr = binExpr.compose(op, r1[j % 4].some()); - exprs[j] = r1[j % 4].some(); - } - Formula nExpr = Formula.compose(op, exprs); - final Solution sol = solver.solve(binExpr.iff(nExpr).not(), bounds); - assertNull(sol.instance()); - } - - } - - public final void testNaryAnd() { - testNary(FormulaOperator.AND); - } - - public final void testNaryOr() { - testNary(FormulaOperator.OR); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/UCoreTest.java b/org.alloytools.kodkod.core/src/test/java/tests/basic/UCoreTest.java deleted file mode 100644 index c031118b6..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/UCoreTest.java +++ /dev/null @@ -1,349 +0,0 @@ -/** - * - */ -package tests.basic; - -import junit.framework.TestCase; - -/** - * Tests the unsat core functionality. - * - * @author Emina Torlak - */ -public final class UCoreTest extends TestCase { - - public void test() {} - - // private static final Class< ? >[] FIXED_SCOPE = { - // NUM378.class - // }; - // - // // scopes 1-5 - // private static final Class< ? >[] EASY = { - // Toughnut.class, MED007.class, MED009.class, - // }; - // - // // scopes 1-4 - // private static final Class< ? >[] MEDIUM = { - // Lists.class, Trees.class, Hotel.class, RingElection.class, COM008.class, - // TOP020.class, GEO091.class, - // GEO092.class, GEO115.class, GEO158.class, GEO159.class, LAT258.class, - // }; - // - // // scopes 1-3 - // private static final Class< ? >[] HARD = { - // ALG212.class, NUM374.class, SET943.class, SET948.class, SET967.class, - // }; - // - // private static final int EASY_MAX = 5, MED_MAX = 4, HARD_MAX = 3; - // - // private final Solver solver; - // private final Solver vSolver; - // - // public UCoreTest() { - // solver = new Solver(); - // solver.options().setLogTranslation(1); - // solver.options().setSolver(SATFactory.MiniSatProver); - // vSolver = new Solver(); - // vSolver.options().setSolver(SATFactory.MiniSat); - // } - // - // private final void verify(Set core, Bounds bounds) { - // // check that the conjunction of the high-level core formulas is false - // assertNull(vSolver.solve(Formula.and(core), bounds).instance()); - // - // // check that the core is minimal - // final Set tmpCore = new LinkedHashSet(core); - // for (Iterator itr = core.iterator(); itr.hasNext();) { - // final Formula f = itr.next(); - // tmpCore.remove(f); - // assertNotNull(vSolver.solve(Formula.and(tmpCore), bounds).instance()); - // tmpCore.add(f); - // } - // - // } - // - // private final void minimizeAndVerify(Formula formula, Bounds bounds, - // Proof proof, ReductionStrategy strategy) { - // proof.minimize(strategy); - // final Set core = Nodes.allRoots(formula, - // proof.highLevelCore().values()); - // final Set tcore = proof.highLevelCore().keySet(); - // verify(tcore, proof.log().bounds()); - // if (solver.options().coreGranularity() == 0) { - // assertEquals(tcore.size(), core.size()); - // verify(core, bounds); - // } else { - // assertNull(vSolver.solve(Formula.and(core), bounds).instance()); - // } - // } - // - // private final void testTrivialProofExtractor(Class< ? >[] probs, int - // maxScope) { - // for (Class< ? > prob : probs) { - // Object instance = UCoreStats.instance(prob); - // Map checks = invokeAll(instance, checks(prob)); - // for (Formula check : checks.values()) { - // for (int scope = 1; scope <= maxScope; scope++) { - // Bounds bounds = bounds(instance, scope); - // Solution sol = solver.solve(check, bounds); - // if (sol.outcome() == Solution.Outcome.TRIVIALLY_UNSATISFIABLE) { - // minimizeAndVerify(check, bounds, sol.proof(), null); - // } else { - // break; - // } - // } - // } - // - // } - // } - // - // private final void testTrivialProofExtractor(Class< ? >[] probs) { - // for (Class< ? > prob : probs) { - // Object instance = UCoreStats.instance(prob); - // Map checks = invokeAll(instance, checks(prob)); - // for (Formula check : checks.values()) { - // Bounds bounds = bounds(instance); - // Solution sol = solver.solve(check, bounds); - // if (sol.outcome() == Solution.Outcome.TRIVIALLY_UNSATISFIABLE) { - // minimizeAndVerify(check, bounds, sol.proof(), null); - // } - // } - // - // } - // } - // - // private final void testProofExtractor(Class< ? >[] probs, Class< ? - // extends ReductionStrategy> strategy, - // int maxScope) { - // System.out.println("" + Arrays.toString(probs) + " " + strategy + " " + - // maxScope); - // - // for (Class< ? > prob : probs) { - // Object instance = UCoreStats.instance(prob); - // Map checks = invokeAll(instance, checks(prob)); - // for (Formula check : checks.values()) { - // for (int scope = 1; scope <= maxScope; scope++) { - // Bounds bounds = bounds(instance, scope); - // Solution sol = solver.solve(check, bounds); - // if (sol.outcome() == Solution.Outcome.UNSATISFIABLE) { - // minimizeAndVerify(check, bounds, sol.proof(), strategy(strategy, - // sol.proof().log())); - // } - // } - // } - // - // } - // System.out.println("done"); - // } - // - // private final void testProofExtractor(Class< ? >[] probs, Class< ? - // extends ReductionStrategy> strategy) { - // for (Class< ? > prob : probs) { - // Object instance = UCoreStats.instance(prob); - // Map checks = invokeAll(instance, checks(prob)); - // for (Formula check : checks.values()) { - // Bounds bounds = bounds(instance); - // Solution sol = solver.solve(check, bounds); - // if (sol.outcome() == Solution.Outcome.UNSATISFIABLE) { - // minimizeAndVerify(check, bounds, sol.proof(), strategy(strategy, - // sol.proof().log())); - // } - // } - // - // } - // } - // - // public final void testFixedTrivial0() { - // solver.options().setCoreGranularity(0); - // testTrivialProofExtractor(FIXED_SCOPE); - // testTrivialProofExtractor(EASY, EASY_MAX); - // testTrivialProofExtractor(MEDIUM, MED_MAX); - // testTrivialProofExtractor(HARD, HARD_MAX); - // } - // - // public final void testFixedTrivial1() { - // solver.options().setCoreGranularity(1); - // testTrivialProofExtractor(FIXED_SCOPE); - // testTrivialProofExtractor(EASY, EASY_MAX); - // testTrivialProofExtractor(MEDIUM, MED_MAX); - // testTrivialProofExtractor(HARD, HARD_MAX); - // } - // - // public final void testFixedTrivial2() { - // solver.options().setCoreGranularity(2); - // testTrivialProofExtractor(FIXED_SCOPE); - // testTrivialProofExtractor(EASY, EASY_MAX); - // testTrivialProofExtractor(MEDIUM, MED_MAX); - // testTrivialProofExtractor(HARD, HARD_MAX); - // } - // - // public final void testFixedTrivial3() { - // solver.options().setCoreGranularity(3); - // testTrivialProofExtractor(FIXED_SCOPE); - // testTrivialProofExtractor(EASY, EASY_MAX); - // testTrivialProofExtractor(MEDIUM, MED_MAX); - // testTrivialProofExtractor(HARD, HARD_MAX); - // } - // - // public final void testFixedSCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(FIXED_SCOPE, SCEStrategy.class); - // } - // - // public final void testEasySCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(EASY, SCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumSCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(MEDIUM, SCEStrategy.class, MED_MAX); - // } - // - // public final void testHardSCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(HARD, SCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedSCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(FIXED_SCOPE, SCEStrategy.class); - // } - // - // public final void testEasySCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(EASY, SCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumSCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(MEDIUM, SCEStrategy.class, MED_MAX); - // } - // - // public final void testHardSCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(HARD, SCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedSCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(FIXED_SCOPE, SCEStrategy.class); - // } - // - // public final void testEasySCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(EASY, SCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumSCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(MEDIUM, SCEStrategy.class, MED_MAX); - // } - // - // public final void testHardSCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(HARD, SCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedSCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(FIXED_SCOPE, SCEStrategy.class); - // } - // - // public final void testEasySCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(EASY, SCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumSCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(MEDIUM, SCEStrategy.class, MED_MAX); - // } - // - // public final void testHardSCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(HARD, SCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedRCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(FIXED_SCOPE, RCEStrategy.class); - // } - // - // public final void testEasyRCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(EASY, RCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumRCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(MEDIUM, RCEStrategy.class, MED_MAX); - // } - // - // public final void testHardRCE0() { - // solver.options().setCoreGranularity(0); - // testProofExtractor(HARD, RCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedRCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(FIXED_SCOPE, RCEStrategy.class); - // } - // - // public final void testEasyRCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(EASY, RCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumRCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(MEDIUM, RCEStrategy.class, MED_MAX); - // } - // - // public final void testHardRCE1() { - // solver.options().setCoreGranularity(1); - // testProofExtractor(HARD, RCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedRCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(FIXED_SCOPE, RCEStrategy.class); - // } - // - // public final void testEasyRCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(EASY, RCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumRCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(MEDIUM, RCEStrategy.class, MED_MAX); - // } - // - // public final void testHardRCE2() { - // solver.options().setCoreGranularity(2); - // testProofExtractor(HARD, RCEStrategy.class, HARD_MAX); - // } - // - // public final void testFixedRCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(FIXED_SCOPE, RCEStrategy.class); - // } - // - // public final void testEasyRCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(EASY, RCEStrategy.class, EASY_MAX); - // } - // - // public final void testMediumRCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(MEDIUM, RCEStrategy.class, MED_MAX); - // } - // - // public final void testHardRCE3() { - // solver.options().setCoreGranularity(3); - // testProofExtractor(HARD, RCEStrategy.class, HARD_MAX); - // } - // -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/basic/handshake.xml b/org.alloytools.kodkod.core/src/test/java/tests/basic/handshake.xml deleted file mode 100644 index c60ffbd9f..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/basic/handshake.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - examples/puzzles/handshake/Person - - - - - - - - - - - - -set examples/puzzles/handshake/Person - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkDriver.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkDriver.java deleted file mode 100644 index 5837d1f72..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkDriver.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import static tests.util.Reflection.checks; -import static tests.util.Reflection.findClass; - -/** - * Common code for benchmark drivers - * - * @author Emina Torlak - */ -abstract class BenchmarkDriver { - - /** - * Class name, method, and scope of a problem. - * - * @author Emina Torlak - */ - static final class Problem { - - final String problem, spec, bounds; - - Problem(String problem, String spec, int scope) { - this.problem = problem; - this.spec = spec; - this.bounds = "bounds(" + scope + ")"; - } - - Problem(String problem, String spec) { - this.problem = problem; - this.spec = spec; - this.bounds = "bounds()"; - } - - Problem(String problem, String spec, String bounds) { - this.problem = problem; - this.spec = spec; - this.bounds = bounds; - } - - Problem(String problem, int scope) { - this.problem = problem; - this.spec = checks(findClass(problem)).iterator().next().getName(); - this.bounds = "bounds(" + scope + ")"; - } - - Problem(String problem) { - this.problem = problem; - this.spec = checks(findClass(problem)).iterator().next().getName(); - this.bounds = "bounds()"; - } - } - - static final Problem[] problems = { - new Problem("examples.alloy.Trees", 7), new Problem("examples.alloy.Handshake", "runPuzzle", 10), new Problem("examples.alloy.FileSystem", 30), new Problem("examples.alloy.Dijkstra", 20), new Problem("examples.alloy.RingElection", 8), new Problem("examples.alloy.Lists", "checkEmpties", 60), new Problem("examples.alloy.Lists", "checkReflexive", 14), new Problem("examples.alloy.Lists", "checkSymmetric", 8), new Problem("examples.alloy.AbstractWorldDefinitions", "checkA241", 10), new Problem("examples.alloy.AbstractWorldDefinitions", "checkAbOp_total", 10), new Problem("examples.alloy.AbstractWorldDefinitions", "checkAbIgnore_inv", 10), new Problem("examples.alloy.AbstractWorldDefinitions", "checkAbTransfer_inv", 8), new Problem("examples.tptp.ALG212", 7), new Problem("examples.tptp.ALG195"), new Problem("examples.tptp.ALG197"), new Problem("examples.tptp.COM008", 11), new Problem("examples.tptp.GEO091", 10), new Problem("examples.tptp.GEO092", 8), new Problem("examples.tptp.GEO158", 8), new Problem("examples.tptp.GEO159", 8), new Problem("examples.tptp.GEO115", 9), new Problem("examples.tptp.LAT258", 7), new Problem("examples.tptp.MED007", 35), new Problem("examples.tptp.MED009", 35), new Problem("examples.tptp.NUM374", 5), new Problem("examples.tptp.NUM378"), new Problem("examples.tptp.SET943", 7), new Problem("examples.tptp.SET948", 14), new Problem("examples.tptp.SET967", 4), new Problem("examples.tptp.TOP020", 10), - }; - - static long FIVE_MIN = 300000, ONE_HOUR = 3600000; -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkStats.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkStats.java deleted file mode 100644 index 0b32831a4..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkStats.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import static tests.util.Reflection.construct; -import static tests.util.Reflection.create; - -import java.util.LinkedHashMap; -import java.util.Map; - -import kodkod.ast.Formula; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.bool.BooleanFormula; -import kodkod.engine.bool.BooleanVariable; -import kodkod.engine.bool.BooleanVisitor; -import kodkod.engine.bool.ITEGate; -import kodkod.engine.bool.MultiGate; -import kodkod.engine.bool.NotGate; -import kodkod.engine.config.AbstractReporter; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; - -/** - * Executes a single problem. The output is printed in the following (tab - * separated) format: - * <# of gates> <# of primary vars> <# of vars> <# of - * clauses> - * - * @author Emina Torlak - */ -public final class BenchmarkStats { - - private static void usage() { - System.out.println("Usage: java tests.benchmarks.BenchmarkStats [([,]*)] [([,]*)] [-scope=([,]*)] [-sharing=] [-symm=]"); - System.exit(1); - } - - private static class GateReporter extends AbstractReporter { - - int gates = 0; - long time; - - // public void solvingCNF(int primaryVars, int vars, int clauses) { - // System.out.println("About to start solving, p cnf : " + vars + " " + - // clauses); - // System.out.println("Primary vars and gates : " + primaryVars + " " + - // gates); - // } - @Override - public void translatingToCNF(BooleanFormula v) { - final long start = System.currentTimeMillis(); - final IntSet s = new IntTreeSet(); - final BooleanVisitor counter = new BooleanVisitor() { - - @Override - public Object visit(MultiGate multigate, Object arg) { - if (s.add(multigate.label())) { - for (BooleanFormula f : multigate) { - f.accept(this, arg); - } - } - return null; - } - - @Override - public Object visit(ITEGate ite, Object arg) { - if (s.add(ite.label())) { - for (BooleanFormula f : ite) { - f.accept(this, arg); - } - } - return null; - } - - @Override - public Object visit(NotGate negation, Object arg) { - if (s.add(negation.label())) { - negation.input(0).accept(this, arg); - } - return null; - } - - @Override - public Object visit(BooleanVariable variable, Object arg) { - return null; - } - - }; - v.accept(counter, null); - gates = s.size(); - - final long end = System.currentTimeMillis(); - time = end - start; - } - } - - /** - * Returns a map that maps each option in the given argument array to its value, - * or null if the option has no value. Assumes that all options are of the form - * "-opt=val" or "-opt". - * - * @return a map that maps each option in the given argument array to its value, - * or null if the option has no value. - */ - static Map options(String[] args) { - final Map opts = new LinkedHashMap(); - for (String arg : args) { - if (arg.startsWith("-")) { - String[] opt = arg.split("="); - switch (opt.length) { - case 1 : - opts.put(opt[0], null); - break; - case 2 : - opts.put(opt[0], opt[1]); - break; - default : - throw new IllegalArgumentException("Unrecognized option format: " + arg); - } - } - } - return opts; - } - - /** - * Usage: java tests.benchmarks.BenchmarkStats [([,]*)] [([,]*)] [-scope=([,]*)] [-sharing=] - * [-symm=] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - - try { - final Map opts = options(args); - - final Object instance = construct(args[0].contains("(") ? args[0] : args[0] + "()"); - final Formula formula = create(instance, args[1].contains("(") ? args[1] : args[1] + "()"); - final Bounds bounds = create(instance, opts.containsKey("-scope") ? opts.get("-scope") : "bounds()"); - - final GateReporter reporter = new GateReporter(); - final Solver solver = new Solver(); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setBitwidth(8); - solver.options().setLogTranslation(0); - solver.options().setReporter(reporter); - if (opts.containsKey("-sharing")) - solver.options().setSharing(Integer.parseInt(opts.get("-sharing"))); - if (opts.containsKey("-symm")) - solver.options().setSymmetryBreaking(Integer.parseInt(opts.get("-symm"))); - - // - System.out.print(args[0].split("\\(")[0] + "\t"); - System.out.print(args[1].split("\\(")[0] + "\t"); - System.out.print(bounds.universe().size() + "\t"); - final Solution sol = solver.solve(formula, bounds); - - // <# of gates> <# of primary vars> <# - // of vars> <# of clauses> - System.out.print((sol.instance() == null ? "U" : "S") + "\t"); - System.out.print((sol.stats().translationTime() - reporter.time) + "\t"); - System.out.print(reporter.gates + "\t"); - System.out.print(sol.stats().primaryVariables() + "\t"); - System.out.print(sol.stats().variables() + "\t"); - System.out.print(sol.stats().clauses() + "\t"); - System.out.println(sol.stats().solvingTime()); - - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkStatsDriver.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkStatsDriver.java deleted file mode 100644 index 6a703881f..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkStatsDriver.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; - -import tests.util.ProcessRunner; - -/** - * Calls BenchmarkStats on all problems in examples.tptp.* and most problems in - * examples.* - * - * @author Emina Torlak - */ -public final class BenchmarkStatsDriver extends BenchmarkDriver { - - private static void usage() { - System.out.println("Usage: java tests.benchmarks.BenchmarksStatsDriver "); - System.exit(0); - } - - /** - * Usage: java tests.benchmarks.BenchmarksStatsDriver - */ - public static void main(String args[]) { - if (args.length != 1) - usage(); - - System.out.print("name\t"); - System.out.print("method\t"); - System.out.print("universe\t"); - System.out.print("outcome\t"); - System.out.print("translation (ms)\t"); - System.out.print("gates\t"); - System.out.print("primary vars\t"); - System.out.print("vars\t"); - System.out.print("clauses\t"); - System.out.println("solving time (ms)"); - - for (Problem problem : problems) { - final String cmd = "java -Xmx2G -cp bin tests.benchmarks.BenchmarkStats " + problem.problem + " " + problem.spec + " -scope=" + problem.bounds + " -sharing=" + args[0]; - - // System.out.println(cmd); - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - - try { - runner.join(FIVE_MIN); - if (runner.getState() != Thread.State.TERMINATED) { - runner.interrupt(); - runner.destroyProcess(); - System.out.print(problem.problem + "\t"); - System.out.print(problem.spec + "\t"); - System.out.println("na\tna\tna\tna\tna\tna\tna\tna"); - continue; - } - - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - System.out.println(out.readLine()); - } catch (InterruptedException e) { - System.out.println("INTERRUPTED"); - runner.destroyProcess(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStats.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStats.java deleted file mode 100644 index 0230087bb..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStats.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import static tests.util.Reflection.construct; -import static tests.util.Reflection.create; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.lang.management.ManagementFactory; -import java.lang.management.ThreadMXBean; -import java.math.BigInteger; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Solver; -import kodkod.engine.config.AbstractReporter; -import kodkod.instance.Bounds; -import kodkod.instance.Tuple; -import kodkod.instance.TupleSet; -import kodkod.util.ints.ArrayIntVector; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntVector; -import tests.util.ProcessRunner; - -/** - * Executes a single problem. The output is printed in the following (tab - * separated) format: - * - * - * @author Emina Torlak - */ -public class BenchmarkSymmStats { - - private static void usage() { - System.out.println("Usage: java tests.benchmarks.BenchmarkSymmStats [([,]*)] [([,]*)] [[([,]*)] [([,]*)]]"); - System.exit(1); - } - - private static final ThreadMXBean bean = ManagementFactory.getThreadMXBean(); - static { - bean.setThreadCpuTimeEnabled(true); - } - - private static class SymmReporter extends AbstractReporter { - - long gbpTime; - int[] symms; - Bounds bounds; - - @Override - public void detectingSymmetries(Bounds bounds) { - this.bounds = bounds.clone(); - gbpTime = bean.getCurrentThreadUserTime(); - } - - @Override - public void detectedSymmetries(Set parts) { - final long end = bean.getCurrentThreadUserTime(); - gbpTime = (end - gbpTime) / 1000000; - symms = new int[parts.size()]; - int i = 0; - for (IntSet s : parts) { - symms[i++] = s.size(); - } - } - - @Override - public void optimizingBoundsAndFormula() { - throw new RuntimeException(); - } - - /** - * Returns a new reporter with its gbpTime, bounds and symms fields initialized - * with respect to the given formula and bounds. - */ - static SymmReporter report(Formula formula, Bounds bounds) { - final SymmReporter reporter = new SymmReporter(); - final Solver solver = new Solver(); - solver.options().setReporter(reporter); - try { - solver.solve(formula, bounds); - } catch (RuntimeException ae) {} - return reporter; - } - } - - private static void toNauty(Bounds bounds, PrintStream stream) { - int size = bounds.universe().size() + bounds.ints().size(); - for (Relation r : bounds.relations()) { - final int upsize = bounds.upperBound(r).size(), lowsize = bounds.lowerBound(r).size(); - size += (upsize == lowsize ? upsize : upsize + lowsize) * r.arity(); - } - - stream.println("n=" + size + " $0 *=13 k = 0 " + size + " +d -a -m g"); - - int v = bounds.universe().size(); - final IntVector vec = new ArrayIntVector(); - vec.add(v); - for (Relation r : bounds.relations()) { - final int arity = r.arity(); - final TupleSet up = bounds.upperBound(r), down = bounds.lowerBound(r); - final TupleSet[] sets = up.size() == down.size() || down.size() == 0 ? new TupleSet[] { - up - } : new TupleSet[] { - down, up - }; - for (TupleSet s : sets) { - for (Tuple t : s) { - for (int i = 0, max = arity - 1; i < max; i++) { - stream.println(v + " : " + (v + 1) + " " + t.atomIndex(i) + ";"); - v++; - } - stream.println(v + " : " + t.atomIndex(arity - 1) + ";"); - v++; - } - vec.add(v); - } - } - for (TupleSet s : bounds.intBounds().values()) { - stream.println(v + " : " + s.iterator().next().atomIndex(0) + ";"); - v++; - vec.add(v); - } - - // stream.println("."); - stream.print("f = [ 0:" + (vec.get(0) - 1)); - for (int i = 1; i < vec.size(); i++) { - stream.print(" | " + vec.get(i - 1) + ":" + (vec.get(i) - 1)); - } - stream.println(" ]"); - stream.println("x"); - // stream.println("o"); - stream.println("q"); - } - - private static BigInteger fact(int num) { - BigInteger ret = new BigInteger("1"); - for (int i = 1; i <= num; i++) { - ret = ret.multiply(new BigInteger(String.valueOf(i))); - } - return ret; - } - - /** - * Returns the number of symmetries defined by the given partitions. - */ - private static BigInteger symms(int[] parts) { - BigInteger symms = new BigInteger("1"); - for (int part : parts) { - symms = symms.multiply(fact(part)); - } - return symms; - } - - /** - * Returns the size of the partial model (in bits) - */ - private static int pmBits(Bounds bounds) { - int pm = 0; - for (TupleSet lower : bounds.lowerBounds().values()) { - pm += lower.size(); - } - return pm; - } - - private static void destroy(String name) { - try { - final Process process = Runtime.getRuntime().exec("ps -e"); - process.waitFor(); - final BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream(), "ISO-8859-1")); - final Matcher m = Pattern.compile("(\\d+).*?" + name).matcher(""); - for (String line = out.readLine(); line != null; line = out.readLine()) { - m.reset(line); - if (m.find()) { - Runtime.getRuntime().exec("kill " + m.group(1)).waitFor(); - break; - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - private static void printSymmInfo(Formula formula, Bounds bounds) { - - final SymmReporter reporter = SymmReporter.report(formula, bounds); - - // - System.out.print(pmBits(bounds) + "\t"); - System.out.print(reporter.gbpTime + "\t"); - - System.out.print(symms(reporter.symms) + "\t"); - - // - try { - final long startGen = bean.getCurrentThreadUserTime(); - final File tmp = File.createTempFile("symmgraph", ".txt"); - final PrintStream stream = new PrintStream(new FileOutputStream(tmp)); - toNauty(reporter.bounds, stream); - stream.close(); - final long endGen = bean.getCurrentThreadUserTime(); - - final String cmd = "/Users/emina/Desktop/tools/nauty22/run_dreadnaut " + tmp.getAbsoluteFile(); - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - - try { - - runner.join(BenchmarkDriver.FIVE_MIN); - if (runner.getState() != Thread.State.TERMINATED) { - System.out.print("t\\o\t"); - System.out.print("t\\o\t"); - runner.destroyProcess(); - destroy("dreadnaut"); - return; - } - - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - String line; - - String allSymms = null; - long gadTime = -1; - - final Pattern spattern = Pattern.compile(".+grpsize=(.+?);.*"); - final Matcher smatcher = spattern.matcher(""); - final Pattern tpattern = Pattern.compile(".+cpu time = (.+?)\\s.*"); - final Matcher tmatcher = tpattern.matcher(""); - while ((line = out.readLine()) != null) { - smatcher.reset(line); - if (smatcher.matches()) { - allSymms = smatcher.group(1); - } else { - tmatcher.reset(line); - if (tmatcher.matches()) { - gadTime = (long) (Double.parseDouble(tmatcher.group(1)) * 1000); - if (gadTime == 0) - gadTime++; - } - } - // System.out.println(line); - } - out.close(); - - System.out.print(gadTime < 0 ? "err\t" : (gadTime + (endGen - startGen) / 1000000) + "\t"); - System.out.print(allSymms == null ? "err\t" : allSymms + "\t"); - - } catch (InterruptedException e) { - System.out.println("INTERRUPTED"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } finally { - runner.destroyProcess(); - destroy("dreadnaut"); - tmp.delete(); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - /** - * Usage: java tests.benchmarks.BenchmarkSymmStats [([,]*)] [([,]*)] [([,]*)] - */ - public static void main(String[] args) { - if (args.length != 2 && args.length != 3) - usage(); - - try { - - final Object instance = construct(args[0].contains("(") ? args[0] : args[0] + "()"); - final Formula formula = create(instance, args[1].contains("(") ? args[1] : args[1] + "()"); - final Bounds bounds = create(instance, args.length == 3 ? args[2] : "bounds()"); - - // - System.out.print(args[0] + "\t"); - System.out.print(args[1].split("\\(")[0] + "\t"); - - // - printSymmInfo(formula, bounds); - - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStats2.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStats2.java deleted file mode 100644 index 8eb8816a8..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStats2.java +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import static tests.util.Reflection.construct; -import static tests.util.Reflection.create; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.lang.management.ManagementFactory; -import java.lang.management.ThreadMXBean; -import java.math.BigInteger; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import kodkod.ast.Formula; -import kodkod.ast.Relation; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.config.AbstractReporter; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.instance.Tuple; -import kodkod.instance.TupleSet; -import kodkod.util.ints.ArrayIntVector; -import kodkod.util.ints.IntSet; -import kodkod.util.ints.IntTreeSet; -import kodkod.util.ints.IntVector; -import kodkod.util.ints.Ints; -import tests.util.ProcessRunner; - -/** - * Executes a single problem. The output is printed in the following (tab - * separated) format: <# of symms> - * - * @author Emina Torlak - */ -class BenchmarkSymmStats2 { - - private static void usage() { - System.out.println("Usage: java tests.BenchmarkSymmStats [([,]*)] [([,]*)] [[([,]*)] [([,]*)]]"); - System.exit(1); - } - - private static final ThreadMXBean bean = ManagementFactory.getThreadMXBean(); - static { - bean.setThreadCpuTimeEnabled(true); - } - - private static void toNauty(Bounds bounds, PrintStream stream) { - int size = bounds.universe().size() + bounds.ints().size(); - for (Relation r : bounds.relations()) { - final int upsize = bounds.upperBound(r).size(), lowsize = bounds.lowerBound(r).size(); - size += (upsize == lowsize ? upsize : upsize + lowsize) * r.arity(); - } - - stream.println("n=" + size + " $0 *=13 k = 0 " + size + " +d -a g"); - - int v = bounds.universe().size(); - final IntVector vec = new ArrayIntVector(); - vec.add(v); - for (Relation r : bounds.relations()) { - final int arity = r.arity(); - final TupleSet up = bounds.upperBound(r), down = bounds.lowerBound(r); - final TupleSet[] sets = up.size() == down.size() || down.size() == 0 ? new TupleSet[] { - up - } : new TupleSet[] { - down, up - }; - for (TupleSet s : sets) { - for (Tuple t : s) { - for (int i = 0, max = arity - 1; i < max; i++) { - stream.println(v + " : " + (v + 1) + " " + t.atomIndex(i) + ";"); - v++; - } - stream.println(v + " : " + t.atomIndex(arity - 1) + ";"); - v++; - } - vec.add(v); - } - } - for (TupleSet s : bounds.intBounds().values()) { - stream.println(v + " : " + s.iterator().next().atomIndex(0) + ";"); - v++; - vec.add(v); - } - - // stream.println("."); - stream.print("f = [ 0:" + (vec.get(0) - 1)); - for (int i = 1; i < vec.size(); i++) { - stream.print(" | " + vec.get(i - 1) + ":" + (vec.get(i) - 1)); - } - stream.println(" ]"); - stream.println("x"); - stream.println("o"); - stream.println("q"); - } - - private static void destroy(String name) { - try { - final Process process = Runtime.getRuntime().exec("ps -e"); - process.waitFor(); - final BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream(), "ISO-8859-1")); - final Matcher m = Pattern.compile("(\\d+).*?" + name).matcher(""); - for (String line = out.readLine(); line != null; line = out.readLine()) { - m.reset(line); - if (m.find()) { - Runtime.getRuntime().exec("kill " + m.group(1)).waitFor(); - break; - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - private static class SymmInfo { - - final Set parts; - final String time, symms; - - SymmInfo(Set parts, String time, String symms) { - this.parts = parts; - this.time = time; - this.symms = symms; - } - - SymmInfo(int size) { - this.parts = new LinkedHashSet(); - for (int i = 0, max = size; i < max; i++) { - parts.add(Ints.singleton(i)); - } - this.time = "t\\o"; - this.symms = "t\\o"; - } - } - - private static SymmInfo allSymms(Bounds bounds) { - try { - final long startGen = bean.getCurrentThreadUserTime(); - final File tmp = File.createTempFile("symmgraph", ".txt"); - final PrintStream stream = new PrintStream(new FileOutputStream(tmp)); - toNauty(bounds, stream); - stream.close(); - final long endGen = bean.getCurrentThreadUserTime(); - - final String cmd = "/Users/emina/Desktop/tools/nauty22/run_dreadnaut " + tmp.getAbsoluteFile(); - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - - try { - - runner.join(BenchmarkDriver.FIVE_MIN); - if (runner.getState() != Thread.State.TERMINATED) { - System.out.print("t\\o\t"); - System.out.print("t\\o\t"); - runner.destroyProcess(); - destroy("dreadnaut"); - tmp.delete(); - return new SymmInfo(bounds.universe().size()); - } - - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - String line; - - String allSymms = null; - long time = -1; - final Set parts = new LinkedHashSet(); - - final Matcher smatcher = Pattern.compile(".+grpsize=(.+?);.*").matcher(""); - final Matcher tmatcher = Pattern.compile(".+cpu time = (.+?)\\s.*").matcher(""); - final Matcher omatcher = Pattern.compile("invarproc \"adjacencies\"").matcher(""); - - while ((line = out.readLine()) != null) { - smatcher.reset(line); - if (smatcher.matches()) { - allSymms = smatcher.group(1); - } else { - tmatcher.reset(line); - if (tmatcher.matches()) { - time = (long) (Double.parseDouble(tmatcher.group(1)) * 1000); - if (time == 0) - time++; - } else { - omatcher.reset(line); - if (omatcher.find()) { - break; - } - } - } - } - - if (line != null) { - final StringBuilder builder = new StringBuilder(); - while ((line = out.readLine()) != null) { - builder.append(line); - } - line = builder.toString(); - // System.out.println(line); - final String[] orbits = line.split(";"); - final Matcher dmatcher = Pattern.compile("\\s*(\\d+)\\s*").matcher(""); - for (String n : orbits) { - String[] range = n.split(":"); - if (range.length == 2) { - dmatcher.reset(range[0]); - dmatcher.matches(); - final int min = Integer.parseInt(dmatcher.group(1)); - if (min >= bounds.universe().size()) - break; - dmatcher.reset(range[1]); - dmatcher.matches(); - parts.add(Ints.rangeSet(Ints.range(min, Integer.parseInt(dmatcher.group(1))))); - } else { - range = n.split("\\s+"); - final IntSet part = new IntTreeSet(); - for (int i = 0; i < range.length; i++) { - dmatcher.reset(range[i]); - if (dmatcher.matches()) { - final int match = Integer.parseInt(dmatcher.group(1)); - if (match < bounds.universe().size()) - part.add(match); - else - break; - } - } - if (part.isEmpty()) - break; - else - parts.add(part); - } - - } - } - - out.close(); - tmp.delete(); - runner.destroyProcess(); - - if (time < 0 || allSymms == null || parts.isEmpty()) - throw new IllegalStateException(); - return new SymmInfo(parts, String.valueOf(time + (endGen - startGen) / 1000000), allSymms); - - } catch (IOException e) { - tmp.delete(); - runner.destroyProcess(); - destroy("dreadnaut"); - throw new IllegalStateException(e); - } catch (InterruptedException e) { - tmp.delete(); - runner.destroyProcess(); - destroy("dreadnaut"); - e.printStackTrace(); - throw new IllegalStateException(e); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private static BigInteger fact(int num) { - BigInteger ret = new BigInteger("1"); - for (int i = 1; i <= num; i++) { - ret = ret.multiply(new BigInteger(String.valueOf(i))); - } - return ret; - } - - /** - * Returns the size of the partial model (in bits) - */ - private static int pmBits(Bounds bounds) { - int pm = 0; - for (TupleSet lower : bounds.lowerBounds().values()) { - pm += lower.size(); - } - return pm; - } - - // <# of symms> - private static void printGBP(Formula formula, Bounds bounds) { - final class SymmReporter extends AbstractReporter { - - long gbpTime; - BigInteger symms; - - @Override - public void detectingSymmetries(Bounds bounds) { - gbpTime = bean.getCurrentThreadUserTime(); - } - - @Override - public void detectedSymmetries(Set parts) { - final long end = bean.getCurrentThreadUserTime(); - gbpTime = (end - gbpTime) / 1000000; - symms = new BigInteger("1"); - for (IntSet s : parts) { - symms = symms.multiply(fact(s.size())); - } - // System.out.println(parts); - } - } - - final SymmReporter reporter = new SymmReporter(); - final Solver solver = new Solver(); - solver.options().setBitwidth(8); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setReporter(reporter); - - final Solution sol = solver.solve(formula, bounds); - - // - System.out.print(reporter.gbpTime + "\t"); - System.out.print(reporter.symms + "\t"); - // - System.out.print(sol.stats().primaryVariables() + "\t"); - System.out.print(sol.instance() == null ? "UNSAT\t" : "SAT\t"); - System.out.print(sol.stats().solvingTime() + "\t"); - } - - // <# of symms> - private static void printGAD(Formula formula, Bounds bounds) { - final class SymmReporter extends AbstractReporter { - - String symms, time; - Bounds bounds; - - @Override - public void detectingSymmetries(Bounds bounds) { - this.bounds = bounds.clone(); - } - - @Override - public void detectedSymmetries(Set parts) { - parts.clear(); - final SymmInfo allSymms = allSymms(bounds); - parts.addAll(allSymms.parts); - symms = allSymms.symms; - time = allSymms.time; - // System.out.println(parts); - } - } - - final SymmReporter reporter = new SymmReporter(); - final Solver solver = new Solver(); - solver.options().setBitwidth(8); - solver.options().setSolver(SATFactory.MiniSat); - solver.options().setReporter(reporter); - - final Solution sol = solver.solve(formula, bounds); - - // - System.out.print(reporter.time + "\t"); - System.out.print(reporter.symms + "\t"); - // - System.out.print(sol.stats().primaryVariables() + "\t"); - System.out.print(sol.instance() == null ? "UNSAT\t" : "SAT\t"); - System.out.print(sol.stats().solvingTime() + "\t"); - } - - /** - * Usage: java tests.BenchmarkSymmStats [([,]*)] [([,]*)] [([,]*)] - */ - public static void main(String[] args) { - if (args.length != 3 && args.length != 4) - usage(); - - try { - final int method; - if ("GBP".equals(args[0].toUpperCase())) { - method = 0; - } else if ("GAD".equals(args[0].toUpperCase())) { - method = 1; - } else { - method = 2; - usage(); - } - - final Object instance = construct(args[1].contains("(") ? args[1] : args[1] + "()"); - final Formula formula = create(instance, args[2].contains("(") ? args[2] : args[2] + "()"); - final Bounds bounds = create(instance, "bounds" + (args.length == 4 ? args[3] : "()")); - - // - System.out.print(args[0].split("\\(")[0] + "\t"); - System.out.print(args[1].split("\\(")[0] + "\t"); - System.out.print(pmBits(bounds) + "\t"); - - // <# of symms> - if (method == 0) - printGBP(formula, bounds); - else - printGAD(formula, bounds); - System.out.println(); - } catch (NumberFormatException nfe) { - usage(); - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStatsDriver.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStatsDriver.java deleted file mode 100644 index 442b4cdd2..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/BenchmarkSymmStatsDriver.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; - -import tests.util.ProcessRunner; - -/** - * Calls BenchmarkSymmStats on all problems in examples.tptp.* and most problems - * in examples.* The output is printed in the following (tab separated) format: - * - * - * - * @author Emina Torlak - */ -public final class BenchmarkSymmStatsDriver extends BenchmarkDriver { - - /** - * - * \t - */ - private static void runSymms(Problem problem) { - final String cmd = "java -Xmx2G -cp bin tests.benchmarks.BenchmarkSymmStats " + problem.problem + " " + problem.spec + " " + problem.bounds; - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - try { - runner.join(); - final BufferedReader out; - out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - System.out.print(out.readLine()); - out.close(); - } catch (InterruptedException e) { - e.printStackTrace(); - System.exit(1); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } finally { - runner.destroyProcess(); - } - } - - /** - * \t - */ - private static void runSolveWithSymms(Problem problem) { - final String cmd = "java -Xmx2G -cp bin tests.benchmarks.BenchmarkStats " + problem.problem + " " + problem.spec + " -scope=" + problem.bounds; - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - try { - runner.join(); - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - final String line = out.readLine(); - final String[] data = line.split("\\s"); - if (data.length != 10) - throw new RuntimeException("badly formatted output: " + line); - // <# of gates> <# of primary vars> <# of vars> <# of - // clauses> - System.out.print(data[6] + "\t"); - System.out.print(data[3].startsWith("S") ? "SAT\t" : "UNSAT\t"); - System.out.print(data[9] + "\t"); - out.close(); - } catch (InterruptedException e) { - e.printStackTrace(); - System.exit(1); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } finally { - runner.destroyProcess(); - } - } - - /** - * \n - */ - private static void runSolveNoSymms(Problem problem) { - final String cmd = "java -Xmx2G -cp bin tests.benchmarks.BenchmarkStats " + problem.problem + " " + problem.spec + " -scope=" + problem.bounds + " -symm=" + 0; - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - try { - runner.join(FIVE_MIN); - - if (runner.getState() != Thread.State.TERMINATED) { - runner.interrupt(); - System.out.println("t\\o"); - runner.destroyProcess(); - } else { - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - final String line = out.readLine(); - final String[] data = line.split("\\s"); - System.out.println(data.length == 10 ? data[9] : "t\\o"); - out.close(); - } - } catch (InterruptedException e) { - e.printStackTrace(); - System.exit(1); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } finally { - runner.destroyProcess(); - } - } - - /** - * Usage: java tests.benchmarks.BenchmarksSymmStatsDriver - */ - public static void main(String args[]) { - - System.out.print("class\t"); - System.out.print("method\t"); - System.out.print("partial model (bits)\t"); - System.out.print("gbp (ms)\t"); - System.out.print("gbp (symms)\t"); - System.out.print("gad (ms)\t"); - System.out.print("gad (symms)\t"); - System.out.print("state space (bits)\t"); - System.out.print("sat | unsat\t"); - System.out.print("solve+sbp (ms)\t"); - System.out.println("solve (ms)"); - - for (Problem problem : problems) { - runSymms(problem); // System.out.println(); - runSolveWithSymms(problem); - runSolveNoSymms(problem); - } - - final Problem[] graphProblems = { - new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/mulsol.i.1.col,DIMACS,27)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/mulsol.i.2.col,DIMACS,27)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/mulsol.i.3.col,DIMACS,27)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/mulsol.i.4.col,DIMACS,27)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/mulsol.i.5.col,DIMACS,27)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/school1_nsh.col,DIMACS,13)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/school1.col,DIMACS,13)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/zeroin.i.1.col,DIMACS,27)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/zeroin.i.2.col,DIMACS,28)", "coloring"), new Problem("examples.classicnp.GraphColoring(/Users/emina/Documents/workspace/relations5/src/examples/classicnp/zeroin.i.3.col,DIMACS,27)", "coloring"), - }; - - for (Problem problem : graphProblems) { - runSymms(problem); // System.out.println(); - runSolveWithSymms(problem); - runSolveNoSymms(problem); - } - - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/UCoreStats.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/UCoreStats.java deleted file mode 100644 index 72e618c30..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/UCoreStats.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import static tests.util.Reflection.bounds; -import static tests.util.Reflection.checks; -import static tests.util.Reflection.findClass; -import static tests.util.Reflection.formulaCreator; -import static tests.util.Reflection.invokeAll; -import static tests.util.Reflection.strategy; - -import java.lang.management.ManagementFactory; -import java.lang.management.ThreadMXBean; -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import kodkod.ast.Formula; -import kodkod.ast.Node; -import kodkod.engine.Solution; -import kodkod.engine.Solver; -import kodkod.engine.Statistics; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.engine.satlab.SATFactory; -import kodkod.instance.Bounds; -import kodkod.util.nodes.Nodes; -import kodkod.util.nodes.PrettyPrinter; - -/** - * Test unsat core extraction for a single problem. - * - * @author Emina Torlak - */ -public final class UCoreStats { - - /** - * Checks that the given proof of unsatisfiablity for the given problem is - * miminal. This method assumes that the given proof is correct. - * - * @return true if the core is minimal; false otherwise. - */ - static boolean checkMinimal(Set core, Bounds bounds) { - System.out.print("checking minimality ... "); - final long start = System.currentTimeMillis(); - final Set minCore = new LinkedHashSet(core); - Solver solver = solver(); - solver.options().setSolver(SATFactory.MiniSat); - for (Iterator itr = minCore.iterator(); itr.hasNext();) { - Formula f = itr.next(); - Formula noF = Formula.TRUE; - for (Formula f1 : minCore) { - if (f != f1) - noF = noF.and(f1); - } - if (solver.solve(noF, bounds).instance() == null) { - itr.remove(); - } - } - final long end = System.currentTimeMillis(); - if (minCore.size() == core.size()) { - System.out.println("minimal (" + (end - start) + " ms)."); - return true; - } else { - System.out.println("not minimal (" + (end - start) + " ms). The minimal core has these " + minCore.size() + " formulas:"); - for (Formula f : minCore) { - System.out.println(" " + f); - } - return false; - } - } - - /** - * Checks that the given core is unsatisfiable with respect to the given bounds. - * - * @return true if the core is correct; false otherwise - */ - static boolean checkCorrect(Set core, Bounds bounds) { - System.out.print("checking correctness ... "); - final long start = System.currentTimeMillis(); - Solver solver = solver(); - solver.options().setSolver(SATFactory.MiniSat); - final Solution sol = solver.solve(Formula.and(core), bounds); - final long end = System.currentTimeMillis(); - if (sol.instance() == null) { - System.out.println("correct (" + (end - start) + " ms)."); - return true; - } else { - System.out.println("incorrect! (" + (end - start) + " ms). The core is satisfiable:"); - System.out.println(sol); - return false; - } - } - - /** - * @return strategy with the given name - */ - @SuppressWarnings("unchecked" ) - private static Class< ? extends ReductionStrategy> findStrategy(String className) { - try { - final Class< ? > c = Class.forName(className); - if (ReductionStrategy.class.isAssignableFrom(c)) - return (Class) c; - else { - throw new IllegalArgumentException(className + " is not a known strategy."); - } - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(className + " is not a known strategy."); - } - } - - /** - * @return scope specification corresponding to the given string - */ - private static int scope(String scope) { - int ret; - try { - ret = Integer.parseInt(scope); - } catch (NumberFormatException n) { - ret = -1; - } - if (ret <= 0) { - throw new IllegalArgumentException(scope + " is not a valid scope."); - } - return ret; - } - - private static Map processOptionalArgs(String[] args) { - final Map ret = new LinkedHashMap(); - for (int i = 2; i < args.length;) { - if (!ret.containsKey(args[i])) - if (i + 1 < args.length && !args[i + 1].startsWith("-")) { - ret.put(args[i], args[i + 1]); - i += 2; - } else { - ret.put(args[i], ""); - i++; - } - else { - usage(); - } - } - return ret; - } - - private static Solver solver() { - final Solver solver = new Solver(); - solver.options().setBitwidth(8); - solver.options().setSolver(SATFactory.MiniSatProver); - solver.options().setLogTranslation(1); - return solver; - } - - /** - * Usage: java tests.benchmarks.UCoreStats [-m method] [-s - * strategy | oce] [-d depth] [-o (user | stats) ] - */ - private static void usage() { - System.out.println("Usage: java tests.benchmarks.UCoreStats [-m method] [-s strategy | oce] [-d depth] [-o (user | stats) ]"); - System.exit(2); - } - - /** - * Runs the minimal core finder using the specified strategy (with the given - * resolution depth, if applicable) on the given methods, bounds, and prints out - * results using the given results printer. - */ - private static void findMinCore(final Class< ? extends ReductionStrategy> strategy, final int depth, final Map checks, final Bounds bounds, final ResultPrinter out) { - - try { - - final Solver solver = solver(); - final ThreadMXBean bean = ManagementFactory.getThreadMXBean(); - bean.setThreadCpuTimeEnabled(true); - for (Map.Entry check : checks.entrySet()) { - // System.out.println(PrettyPrinter.print(check.getValue(), 1)); - Solution sol = solver.solve(check.getValue(), bounds); - - if (sol.outcome() == Solution.Outcome.UNSATISFIABLE) { - - final long start = bean.getCurrentThreadUserTime() / 1000000; - final Set initialCore = Nodes.minRoots(check.getValue(), sol.proof().highLevelCore().values()); - final Set minCore; - - if (strategy == null) { // no strategy -- one-step - minCore = initialCore; - } else { - if (strategy.getSimpleName().startsWith("RCE")) { - sol.proof().minimize(strategy(strategy, sol.proof().log(), depth)); - } else { - sol.proof().minimize(strategy(strategy, sol.proof().log())); - } - minCore = Nodes.minRoots(check.getValue(), sol.proof().highLevelCore().values()); - } - final long end = bean.getCurrentThreadUserTime() / 1000000; - - out.printUnsat(check.getKey().getName(), check.getValue(), bounds, sol.stats(), initialCore, minCore, end - start); - - assert checkCorrect(minCore, bounds); - assert checkMinimal(minCore, bounds); - - } else if (sol.outcome() == Solution.Outcome.TRIVIALLY_UNSATISFIABLE) { - - out.printFalse(check.getKey().getName(), check.getValue(), bounds, sol); - - } else { - out.printSat(check.getKey().getName(), check.getValue(), bounds, sol); - } - - } - } catch (IllegalArgumentException e) { - System.out.println(e.getMessage()); - usage(); - } - } - - /** - * Returns a fresh instance of the given class. - * - * @requires the class has a no-argument constructor - * @return a fresh instance of the given class - */ - public static Object instance(Class< ? > c) { - try { - return c.newInstance(); - } catch (InstantiationException e) { - throw new IllegalArgumentException(c.getName() + " has no accessible nullary constructor."); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(c.getName() + " has no accessible nullary constructor."); - } - } - - /** - * Usage: java tests.benchmarks.UCoreStats [-m method] [-s - * strategy | oce] [-d depth] [-o (user | stats) ] - */ - public static void main(String[] args) { - if (args.length < 2) - usage(); - final Class< ? > problem = findClass(args[0]); - final Map optional = processOptionalArgs(args); - - final Object instance = instance(problem); - final Bounds bounds = bounds(instance, scope(args[1])); - final Map checks = invokeAll(instance, optional.containsKey("-m") ? Collections.singleton(formulaCreator(problem, optional.get("-m"))) : checks(problem)); - - if (checks.isEmpty()) { - usage(); - } - - final String extractor; - final Class< ? extends ReductionStrategy> strategy; - if (optional.containsKey("-s")) { - extractor = optional.get("-s"); - if (extractor.equals("rce")) { - strategy = findStrategy("kodkod.engine.ucore.RCEStrategy"); - } else if (extractor.equals("sce")) { - strategy = findStrategy("kodkod.engine.ucore.SCEStrategy"); - } else if (extractor.equals("nce")) { - strategy = findStrategy("kodkod.engine.ucore.NCEStrategy"); - } else if (!extractor.equals("oce")) { - strategy = findStrategy(optional.get("-s")); - } else { - strategy = null; - } - } else { - extractor = "oce"; - strategy = null; - } - - final ResultPrinter out = "stats".equals(optional.get("-o")) ? ResultPrinter.STATS : ResultPrinter.USER; - - if (optional.containsKey("-d")) { - try { - // findMinCore(strategy, Integer.parseInt(optional.get("-d")), - // checks, bounds(instance, 2), out); - findMinCore(strategy, Integer.parseInt(optional.get("-d")), checks, bounds, out); - } catch (NumberFormatException nfe) { - usage(); - } - } else { - findMinCore(strategy, Integer.MAX_VALUE, checks, bounds, out); - } - - } - - /** @return short string representing a given outcome */ - static String outcome(Solution.Outcome outcome) { - switch (outcome) { - case SATISFIABLE : - return "S"; - case UNSATISFIABLE : - return "U"; - case TRIVIALLY_SATISFIABLE : - return "T"; - case TRIVIALLY_UNSATISFIABLE : - return "F"; - default : - throw new AssertionError("unreachable"); - } - } - - private static enum ResultPrinter { - - USER { - - void print(String check, Formula formula, Bounds bounds, Solution.Outcome outcome, Statistics stats) { - System.out.println(check + ": " + outcome); - System.out.println("p cnf " + stats.variables() + " " + stats.clauses()); - System.out.println("translation time: " + stats.translationTime() + " ms"); - System.out.println("solving time: " + stats.solvingTime() + " ms"); - } - - @Override - void printSat(String check, Formula formula, Bounds bounds, Solution sol) { - print(check, formula, bounds, sol.outcome(), sol.stats()); - System.out.println("instance: " + sol.instance()); - } - - @Override - void printFalse(String check, Formula formula, Bounds bounds, Solution sol) { - print(check, formula, bounds, sol.outcome(), sol.stats()); - System.out.println("trivial core:"); - for (Node f : sol.proof().highLevelCore().values()) { - System.out.println(PrettyPrinter.print(f, 2, 100)); - } - } - - @Override - void printUnsat(String check, Formula formula, Bounds bounds, Statistics stats, Set initialCore, Set minCore, long minTime) { - print(check, formula, bounds, Solution.Outcome.UNSATISFIABLE, stats); - System.out.println("formulas: " + Nodes.roots(formula).size()); - System.out.println("initial core: " + initialCore.size()); - System.out.println("minimized core with " + minCore.size() + " formulas found in " + minTime + " ms:"); - for (Formula f : minCore) { - System.out.println(PrettyPrinter.print(f, 2, 100)); - } - } - }, - STATS { - - void print(String check, Formula formula, Bounds bounds, Solution.Outcome outcome, Statistics stats) { - System.out.print(check); - System.out.print("\t"); - System.out.print(outcome(outcome)); - System.out.print("\t"); - System.out.print(stats.variables()); - System.out.print("\t"); - System.out.print(stats.clauses()); - System.out.print("\t"); - System.out.print(stats.translationTime()); - System.out.print("\t"); - System.out.print(stats.solvingTime()); - } - - @Override - void printSat(String check, Formula formula, Bounds bounds, Solution sol) { - print(check, formula, bounds, sol.outcome(), sol.stats()); - System.out.println(); - } - - @Override - void printFalse(String check, Formula formula, Bounds bounds, Solution sol) { - print(check, formula, bounds, sol.outcome(), sol.stats()); - System.out.print("\t"); - System.out.println(sol.proof().highLevelCore().size()); - } - - @Override - void printUnsat(String check, Formula formula, Bounds bounds, Statistics stats, Set initialCore, Set minCore, long minTime) { - print(check, formula, bounds, Solution.Outcome.UNSATISFIABLE, stats); - System.out.print("\t"); - System.out.print(Nodes.roots(formula).size()); - System.out.print("\t"); - System.out.print(initialCore.size()); - System.out.print("\t"); - System.out.print(minCore.size()); - System.out.print("\t"); - System.out.print(minTime); - System.out.println(); - } - }; - - abstract void printSat(String check, Formula formula, Bounds bounds, Solution sol); - - abstract void printUnsat(String check, Formula formula, Bounds bounds, Statistics stats, Set initialCore, Set minCore, long minTime); - - abstract void printFalse(String check, Formula formula, Bounds bounds, Solution sol); - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/UCoreStatsDriver.java b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/UCoreStatsDriver.java deleted file mode 100644 index ec901a814..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/UCoreStatsDriver.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.benchmarks; - -import static tests.util.Reflection.checks; -import static tests.util.Reflection.findClass; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Method; -import java.util.LinkedHashSet; -import java.util.Set; - -import tests.util.ProcessRunner; - -/** - * Calls UCoreUnitTest on all unsatisfiable problems in examples.tptp.* and - * selected unsatisfiable problems in examples.* - * - * @author Emina Torlak - */ -public final class UCoreStatsDriver { - - private static final String[] RANGE_PROBLEMS = { - "examples.alloy.Lists", "examples.alloy.RingElection", "examples.alloy.Trees", "examples.alloy.Hotel", "examples.tptp.ALG212", "examples.tptp.COM008", "examples.tptp.GEO091", "examples.tptp.GEO092", "examples.tptp.GEO115", "examples.tptp.GEO158", "examples.tptp.GEO159", "examples.tptp.LAT258", "examples.tptp.MED007", "examples.tptp.MED009", "examples.tptp.TOP020", "examples.tptp.SET943", "examples.tptp.SET948", "examples.tptp.SET967", "examples.tptp.NUM374" - }; - - private static final class MaxSpec { - - final String problem, check; - @SuppressWarnings("unused" ) - final int scope, depth; - - MaxSpec(String problem, String check, int scope, int depth) { - this.problem = problem; - this.check = check; - this.scope = scope; - this.depth = depth; - } - - MaxSpec(String problem, int scope, int depth) { - this(problem, checks(findClass(problem)).iterator().next().getName(), scope, depth); - } - } - - private static final MaxSpec[] TRAIN_SPECS = { - /** NCE, SCE, RCE */ - new MaxSpec("examples.alloy.Trees", 7, 1), new MaxSpec("examples.alloy.Hotel", 5, 4), new MaxSpec("examples.alloy.RingElection", 8, 3), new MaxSpec("examples.tptp.ALG212", 7, 6), new MaxSpec("examples.tptp.COM008", 9, 2), new MaxSpec("examples.tptp.NUM374", 3, 4), new MaxSpec("examples.tptp.SET943", 5, Integer.MAX_VALUE), new MaxSpec("examples.tptp.LAT258", 7, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO092", 8, 3), new MaxSpec("examples.tptp.GEO158", 8, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO159", 8, Integer.MAX_VALUE), - - /** SCE, RCE */ - new MaxSpec("examples.tptp.SET948", 14, 6), new MaxSpec("examples.tptp.SET967", 4, 5), new MaxSpec("examples.tptp.TOP020", 10, Integer.MAX_VALUE), new MaxSpec("examples.alloy.Lists", "checkEmpties", 60, Integer.MAX_VALUE), new MaxSpec("examples.alloy.Lists", "checkReflexive", 14, 5), new MaxSpec("examples.alloy.Lists", "checkSymmetric", 8, 6), new MaxSpec("examples.alloy.AbstractWorldDefinitions", "checkA241", 10, Integer.MAX_VALUE), new MaxSpec("examples.alloy.AbstractWorldDefinitions", "checkAbIgnore_inv", 10, Integer.MAX_VALUE), new MaxSpec("examples.alloy.AbstractWorldDefinitions", "checkAbTransfer_inv", 7, Integer.MAX_VALUE), new MaxSpec("examples.alloy.Dijkstra", 25, Integer.MAX_VALUE), - - /** RCE */ - new MaxSpec("examples.tptp.GEO091", 10, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO115", 9, 5), new MaxSpec("examples.tptp.MED007", 35, 6), new MaxSpec("examples.tptp.MED009", 35, 6), - }; - - private static final MaxSpec[] MAX_SPECS = { - /** NCE, SCE, RCE */ - new MaxSpec("examples.alloy.Trees", 7, 2), new MaxSpec("examples.alloy.Hotel", 5, Integer.MAX_VALUE), new MaxSpec("examples.alloy.RingElection", 8, 1), new MaxSpec("examples.tptp.ALG212", 7, 2), new MaxSpec("examples.tptp.COM008", 9, 4), new MaxSpec("examples.tptp.NUM374", 3, Integer.MAX_VALUE), new MaxSpec("examples.tptp.SET943", 5, 3), new MaxSpec("examples.tptp.LAT258", 7, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO092", 8, 4), new MaxSpec("examples.tptp.GEO158", 8, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO159", 8, Integer.MAX_VALUE), - - /** SCE, RCE */ - new MaxSpec("examples.tptp.SET948", 14, 2), new MaxSpec("examples.tptp.SET967", 4, Integer.MAX_VALUE), new MaxSpec("examples.tptp.TOP020", 10, 2), new MaxSpec("examples.alloy.Lists", "checkEmpties", 60, 4), new MaxSpec("examples.alloy.Lists", "checkReflexive", 14, 4), new MaxSpec("examples.alloy.Lists", "checkSymmetric", 8, 4), - - /** RCE */ - new MaxSpec("examples.alloy.AbstractWorldDefinitions", "checkA241", 10, Integer.MAX_VALUE), new MaxSpec("examples.alloy.AbstractWorldDefinitions", "checkAbIgnore_inv", 10, Integer.MAX_VALUE), new MaxSpec("examples.alloy.AbstractWorldDefinitions", "checkAbTransfer_inv", 7, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO091", 10, Integer.MAX_VALUE), new MaxSpec("examples.tptp.GEO115", 9, Integer.MAX_VALUE), new MaxSpec("examples.tptp.MED007", 17, 6), new MaxSpec("examples.tptp.MED009", 17, 6), - }; - - private static long FIVE_MIN = 300000, ONE_HOUR = 3600000; - - private static void usage() { - System.out.println("Usage: java tests.UCoreTestDriver strategy [-train | -test] [ ]"); - System.exit(1); - } - - private static void commonHeaders(String strategy) { - System.out.print("problem\t"); - System.out.print("cmd\t"); - System.out.print("scope\t"); - System.out.print("status\t"); - System.out.print("vars\t"); - System.out.print("clauses\t"); - System.out.print("transl(ms)\t"); - System.out.print("solve(ms)\t"); - System.out.print("all core\t"); - System.out.print("init core\t"); - System.out.print("min core\t"); - System.out.print(strategy.substring(strategy.lastIndexOf(".") + 1) + "(ms)\t"); - } - - private static void trainHeaders(String strategy) { - commonHeaders(strategy); - System.out.println("depth"); - } - - private static void testHeaders(String strategy) { - commonHeaders(strategy); - System.out.println(); - } - - private static void skip(String problem, String check, int scope, String status) { - System.out.print(problem.substring(problem.lastIndexOf(".") + 1) + "\t"); - System.out.print(check + "\t"); - System.out.println(scope + "\t" + status); - } - - /** - * Trains the given strategy at 75% of the test scope. - */ - private static void trainMax(String strategy) { - if (strategy.toLowerCase().indexOf("rce") < 0) - return; - trainHeaders(strategy); - - final long timeout = FIVE_MIN; - final int[] depths = { - Integer.MAX_VALUE, 6, 5, 4, 3, 2, 1 - }; - for (MaxSpec spec : MAX_SPECS) { - final int scope = (int) Math.round(0.75 * spec.scope); - - for (int depth : depths) { - - final String opt = " -m " + spec.check + " -s " + strategy + " -d " + depth + " -o stats"; - final String cmd = "java -cp bin -Xmx2G tests.benchmarks.UCoreStats " + spec.problem + " " + scope + " " + opt; - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - - try { - runner.join(timeout); - if (runner.getState() != Thread.State.TERMINATED) { - runner.interrupt(); - runner.destroyProcess(); - skip(spec.problem, spec.check, spec.scope, "G"); - continue; - } - - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - String line = null; - - while ((line = out.readLine()) != null) { - - final String[] parsed = line.split("\\s"); - - System.out.print(spec.problem.substring(spec.problem.lastIndexOf(".") + 1) + "\t"); - System.out.print(parsed[0] + "\t"); - System.out.print(scope); - - for (int i = 1; i < parsed.length; i++) { - System.out.print("\t" + parsed[i]); - } - - System.out.println("\t" + depth); - } - - } catch (InterruptedException e) { - System.out.println("INTERRUPTED"); - runner.destroyProcess(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } - } - } - - } - - /** - * Runs all problems with the given strategy for the predetermined maximum - * scopes. - * - * @requires strategy is the name of a reduction strategy supported by - * {@linkplain UCoreStats#main(String[])} - */ - private static void testMax(String strategy) { - testHeaders(strategy); - - final long timeout = ONE_HOUR; - for (MaxSpec spec : TRAIN_SPECS) { - final String opt = " -m " + spec.check + " -s " + strategy + " -d " + Integer.MAX_VALUE + " -o stats"; - // final String opt = " -m " + spec.check + " -s " +strategy + " -d - // " + spec.depth + " -o stats"; - final String cmd = "java -cp bin -Xmx2G tests.benchmarks.UCoreStats " + spec.problem + " " + spec.scope + " " + opt; - - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - - try { - runner.join(timeout); - if (runner.getState() != Thread.State.TERMINATED) { - runner.interrupt(); - runner.destroyProcess(); - skip(spec.problem, spec.check, spec.scope, "G"); - continue; - } - - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - String line = null; - - while ((line = out.readLine()) != null) { - - final String[] parsed = line.split("\\s"); - - System.out.print(spec.problem.substring(spec.problem.lastIndexOf(".") + 1) + "\t"); - System.out.print(parsed[0] + "\t"); - System.out.print(spec.scope); - - for (int i = 1; i < parsed.length; i++) { - System.out.print("\t" + parsed[i]); - } - System.out.println(); - } - } catch (InterruptedException e) { - System.out.println("INTERRUPTED"); - runner.destroyProcess(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } - - } - - } - - /** - * Runs all problems with the given strategy for the given scope range. - * - * @requires 1 < min <= max - * @requires strategy is the name of a reduction strategy supported by - * {@linkplain UCoreStats#main(String[])} - */ - private static void runAllInScopes(String strategy, int min, int max) { - testHeaders(strategy); - - final Set timedOut = new LinkedHashSet(); - final Set sat = new LinkedHashSet(); - - for (int scope = min; scope <= max; scope++) { - for (String problem : RANGE_PROBLEMS) { - for (Method m : checks(findClass(problem))) { - if (timedOut.contains(m)) { - skip(problem, m.getName(), scope, "G"); - continue; - } - if (sat.contains(m)) { - skip(problem, m.getName(), scope, "S"); - continue; - } - - final String cmd = "java -cp bin -Xmx2G tests.UCoreStats " + problem + " " + String.valueOf(scope) + " -o stats -m " + m.getName() + " -s " + strategy; - final ProcessRunner runner = new ProcessRunner(cmd.split("\\s")); - runner.start(); - - try { - runner.join(FIVE_MIN); - if (runner.getState() != Thread.State.TERMINATED) { - runner.interrupt(); - runner.destroyProcess(); - skip(problem, m.getName(), scope, "G"); - timedOut.add(m); - continue; - } - - final BufferedReader out = new BufferedReader(new InputStreamReader(runner.processOutput(), "ISO-8859-1")); - String line = null; - - while ((line = out.readLine()) != null) { - - final String[] parsed = line.split("\\s"); - - System.out.print(problem.substring(problem.lastIndexOf(".") + 1) + "\t"); - System.out.print(parsed[0] + "\t"); - System.out.print(scope); - - for (int i = 1; i < parsed.length; i++) { - System.out.print("\t" + parsed[i]); - } - System.out.println(); - - if ("S".equals(parsed[1]) || "T".equals(parsed[1])) { - sat.add(m); - } - } - } catch (InterruptedException e) { - System.out.println("INTERRUPTED"); - runner.destroyProcess(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } - } - } - } - } - - /** - * Usage: java tests.benchmarks.UCoreStatsDriver strategy [-train | -test] - * [ ] - */ - public static void main(String[] args) { - if (args.length < 1) - usage(); - - switch (args.length) { - - case 2 : - if (args[1].equals("-test")) { - testMax(args[0]); - } else if (args[1].equals("-train")) { - trainMax(args[0]); - } else - usage(); - break; - - case 3 : - try { - int min = Integer.parseInt(args[1]); - int max = Integer.parseInt(args[2]); - if (min < 1 || min > max) - usage(); - runAllInScopes(args[0], min, max); - } catch (NumberFormatException e) { - usage(); - } - break; - - default : - usage(); - } - } - -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/cores b/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/cores deleted file mode 100644 index 6dd96b523..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/benchmarks/cores +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -java -cp bin tests.benchmarks.UCoreStatsDriver oce -test > oce.txt -java -cp bin tests.benchmarks.UCoreStatsDriver kodkod.engine.ucore.AdaptiveRCEStrategy -test > rce.txt -java -cp bin tests.benchmarks.UCoreStatsDriver kodkod.engine.ucore.SCEStrategy -test > sce.txt -java -cp bin tests.benchmarks.UCoreStatsDriver kodkod.engine.ucore.NCEStrategy -test > nce.txt - - diff --git a/org.alloytools.kodkod.core/src/test/java/tests/util/ProcessRunner.java b/org.alloytools.kodkod.core/src/test/java/tests/util/ProcessRunner.java deleted file mode 100644 index cc6ae7249..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/util/ProcessRunner.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * A simple thread that runs a given command in a fresh process. - * - * @specfield cmd: String[] - * @author Emina Torlak - */ -public final class ProcessRunner extends Thread { - - private final String[] cmd; - private Process process; - - /** - * Constructs a process runner for the given command. - * - * @effects this.cmd' = cmd - */ - public ProcessRunner(String... cmd) { - this.cmd = cmd; - process = null; - } - - /** - * Destroys the process wrapped by this thread, if any. - * - * @effects destroys the process wrapped by this thread, if any. - */ - public void destroyProcess() { - if (process != null) { - process.destroy(); - process = null; - } - } - - /** - * Gets the input stream of the subprocess running this.com. The stream obtains - * data piped from the standard output stream of the process run by this thread. - * - * @return input stream of the subprocess running this.com - */ - public InputStream processOutput() { - if (process == null) { - System.out.println("process not started."); - throw new IllegalStateException(); - } else { - return process.getInputStream(); - } - } - - /** - * Gets the output stream of the subprocess running this.com. The stream pipes - * data to the standard input stream of the process run by this thread. - * - * @return output stream of the subprocess running this.com. - */ - public OutputStream processInput() { - if (process == null) { - System.out.println("process not started."); - throw new IllegalStateException(); - } else { - return process.getOutputStream(); - } - } - - /** - * Gets the error stream of the subprocess running this.com. The stream obtains - * data piped from the standard error stream of the process run by this thread. - * - * @return error stream of the subprocess running this.com - */ - public InputStream processError() { - if (process == null) { - System.out.println("process not started."); - throw new IllegalStateException(); - } else { - return process.getErrorStream(); - } - } - - /** - * Starts and waits for a process that runs this.cmd - * - * @see java.lang.Thread#run() - */ - @Override - public void run() { - try { - process = Runtime.getRuntime().exec(cmd); - process.waitFor(); - } catch (IOException e) { - System.out.print("Could not run: "); - for (String c : cmd) { - System.out.print(c + " "); - } - System.out.println(); - System.exit(1); - } catch (InterruptedException e) { - // ignore - } - } -} diff --git a/org.alloytools.kodkod.core/src/test/java/tests/util/Reflection.java b/org.alloytools.kodkod.core/src/test/java/tests/util/Reflection.java deleted file mode 100644 index 448c1444f..000000000 --- a/org.alloytools.kodkod.core/src/test/java/tests/util/Reflection.java +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-2008, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package tests.util; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import kodkod.ast.Formula; -import kodkod.engine.fol2sat.TranslationLog; -import kodkod.engine.satlab.ReductionStrategy; -import kodkod.instance.Bounds; - -/** - * Provides a collection of utility methods for finding and executing benchmark - * methods and constructors reflectively. - * - * @author Emina Torlak - */ -public final class Reflection { - - private Reflection() {} - - /** - * This method invokes each method in the given set on the given instance, and - * returns a map from the invoked methods to the resulting objects. - * - * @return a map from the given methods to the objects they produced when - * invoked on the given instance. - */ - @SuppressWarnings("unchecked" ) - public static Map invokeAll(Object instance, Set methods) { - final Map ret = new LinkedHashMap(); - for (Method m : methods) { - try { - ret.put(m, (T) m.invoke(instance)); - } catch (IllegalArgumentException e) {} catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} - } - return ret; - } - - /** - * Returns all public member methods declared by the given class that take no - * arguments, return a Formula, and whose name starts with the word "check". - * - * @return all public member methods declared by the given class that take no - * arguments, return a Formula, and whose name starts with the word - * "check". - */ - public static Set checks(Class< ? > c) { - final Set methods = new LinkedHashSet(); - for (Method m : c.getMethods()) { - if (m.getDeclaringClass().equals(c) && m.getName().startsWith("check") && noArgs(m) && returnsFormula(m)) { - methods.add(m); - } - } - return methods; - } - - /** - * Returns the public member method with the given name and no arguments that - * returns a formula. - * - * @return public member method with the given name and no arguments that - * returns a formula. - **/ - public static Method formulaCreator(Class< ? > c, String name) { - try { - Method m = c.getMethod(name, new Class[0]); - if (returnsFormula(m)) - return m; - else { - throw new IllegalArgumentException("Wrong signature for method " + name + "."); - } - } catch (SecurityException e) { - throw new IllegalArgumentException("Cannot access method " + name + "."); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException("Method " + name + " does not exist."); - } - - } - - /** - * Returns the bounds for the given instance. This method assumes that the - * instance has a no-argument method called "bounds" that returns a Bounds - * object. - * - * @requires instance must have a method called bounds that takes no arguments - * and returns a Bounds object - * @return instance.bounds() - */ - public static Bounds bounds(Object instance) { - try { - final Method bounder = instance.getClass().getMethod("bounds", new Class[] {}); - return (Bounds) bounder.invoke(instance); - } catch (SecurityException e) { - throw new IllegalArgumentException(instance.getClass().getName() + " has no accessible Bounds bounds(int) method."); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(instance.getClass().getName() + " has no Bounds bounds(int) method."); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException("Could not invoke Bounds bounds(int) method of " + instance.getClass().getName() + "."); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException("Could not invoke Bounds bounds(int) method of " + instance.getClass().getName() + "."); - } - } - - /** - * Returns the bounds for the given instance. This method assumes that the - * instance has a method called "bounds" that takes a single integer argument - * and returns a Bounds object. - * - * @requires instance must have a method called bounds that takes an integer - * argument and returns a Bounds object - * @return instance.bounds(scope) - */ - public static Bounds bounds(Object instance, int scope) { - try { - final Method bounder = instance.getClass().getMethod("bounds", new Class[] { - int.class - }); - return (Bounds) bounder.invoke(instance, scope); - } catch (SecurityException e) { - throw new IllegalArgumentException(instance.getClass().getName() + " has no accessible Bounds bounds(int) method."); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(instance.getClass().getName() + " has no Bounds bounds(int) method."); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException("Could not invoke Bounds bounds(int) method of " + instance.getClass().getName() + "."); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException("Could not invoke Bounds bounds(int) method of " + instance.getClass().getName() + "."); - } - } - - /** - * Returns an instance of the given reduction strategy. - * - * @requires strategy has a constructor that takes a translation log - * @return an instance of the given reduction strategy. - */ - public static ReductionStrategy strategy(Class< ? extends ReductionStrategy> strategy, TranslationLog log) { - try { - return strategy.getConstructor(TranslationLog.class).newInstance(log); - } catch (IllegalArgumentException e) { - throw e; - } catch (SecurityException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible one-argument constructor."); - } catch (InstantiationException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible one-argument constructor."); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible one-argument constructor."); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible one-argument constructor."); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible one-argument constructor."); - } - } - - /** - * Returns an instance of the given reduction strategy. - * - * @requires strategy has a constructor that takes a translation log and an - * integer - * @return an instance of the given reduction strategy. - */ - public static ReductionStrategy strategy(Class< ? extends ReductionStrategy> strategy, TranslationLog log, int depth) { - try { - return strategy.getConstructor(TranslationLog.class, int.class).newInstance(log, depth); - } catch (IllegalArgumentException e) { - throw e; - } catch (SecurityException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible two-argument constructor."); - } catch (InstantiationException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible two-argument constructor."); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible two-argument constructor."); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible two-argument constructor."); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(strategy.getName() + " has no accessible two-argument constructor."); - } - } - - /** - * Returns true if m takes no arguments. - * - * @return true if m takes no arguments - **/ - public static boolean noArgs(Method m) { - return m.getParameterTypes().length == 0; - } - - /** - * Returns true if m returns a formula. - * - * @return true if m returns a formula - **/ - public static boolean returnsFormula(Method m) { - return Formula.class.isAssignableFrom(m.getReturnType()); - } - - // -----CREATION FROM STRINGS-----// - - private static Matcher name = Pattern.compile("(.+?)\\(").matcher(""); - private static Matcher arg = Pattern.compile("[\\(,]\\s*(.+?)\\s*[\\),]").matcher(""); - - /** - * Returns the class with the given name - * - * @throws IllegalArgumentException - no such class exists - * @return class with the given name - */ - public static Class< ? > findClass(String className) { - try { - return Class.forName(className); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException(e); - } - } - - /** - * Returns all arguments in the given call, in the order in which they appear. - * - * @return all arguments in the given call, in the order in which they appear. - */ - private static String[] args(String call) { - final List args = new ArrayList(); - arg.reset(call); - if (arg.find()) { - args.add(arg.group(1)); - while (arg.find(arg.end() - 1)) { - args.add(arg.group(1)); - } - } - return args.toArray(new String[args.size()]); - } - - /** - * Converts the given argument, represented as a string, to the given type. - * - * @throws RuntimeException - the conversion is not possible. - * @return the given argument converted to the given type - */ - @SuppressWarnings({ - "unchecked", "rawtypes" - } ) - private static Object convert(String arg, Class< ? > type) { - try { - if (type.isPrimitive()) { - if (type == int.class) { - return new Integer(arg); - } else if (type == long.class) { - return new Long(arg); - } else if (type == boolean.class) { - return new Boolean(arg); - } else if (type == double.class) { - return new Double(arg); - } else if (type == float.class) { - return new Float(arg); - } else if (type == byte.class) { - return new Byte(arg); - } else if (type == short.class) { - return new Short(arg); - } else if (type == char.class && arg.length() == 1) { - return new Character(arg.charAt(0)); - } else { - throw new IllegalArgumentException("Unknown primitive type: " + type); - } - } else if (type == String.class) { - return arg; - } else if (type.isEnum()) { - return Enum.valueOf((Class) type, arg); - } else if (Number.class.isAssignableFrom(type) || type == Boolean.class) { - final Constructor< ? > c = type.getConstructor(String.class); - return c.newInstance(arg); - } else if (type == Character.class && arg.length() == 1) { - return new Character(arg.charAt(0)); - } - } catch (NoSuchMethodException e) {} catch (IllegalAccessException e) {} catch (InstantiationException e) {} catch (InvocationTargetException e) {} - - throw new IllegalArgumentException(); - } - - /** - * Converts the given arguments, represented as strings, to appropriate types, - * if possible. If not returns null. - * - * @requires args.length = argTypes.length - * @return an array containing the given arguments, converted to appropriate - * types, if possible; null if not. - */ - private static Object[] convert(String[] args, Class< ? >[] argTypes) { - assert args.length == argTypes.length; - final Object[] out = new Object[args.length]; - for (int i = 0; i < args.length; i++) { - try { - out[i] = convert(args[i], argTypes[i]); - } catch (RuntimeException e) { - return null; - } - } - return out; - } - - /** - * Reflectively performs the given invocation and returns the result. - * - * @requires call is of the form "name(arg1, arg2, ..., argn)" where name is the - * full class name of the class whose constructor is to be invoked - * (e.g. java.lang.Integer) and the arguments are either strings, - * primitives, objects corresponding to primitives (Integer, Long, - * etc), or publicly accessible Enums. - * @throws IllegalArgumentException - call is not formatted as specified above, - * or it could not be made for some reason. - * @return an object of type T, created reflectively from the given call String - */ - @SuppressWarnings("unchecked" ) - public static T construct(String call) { - try { - name.reset(call); - if (!name.find()) - throw new IllegalArgumentException("Badly formatted call: " + call); - final Class< ? > callClass = findClass(name.group(1)); - - final String[] args = args(call); - - for (Constructor< ? > c : callClass.getConstructors()) { - final Class< ? >[] argTypes = c.getParameterTypes(); - if (argTypes.length == args.length) { - final Object[] convertedArgs = convert(args, argTypes); - if (convertedArgs != null) { - return (T) c.newInstance(convertedArgs); - } - } - } - - throw new IllegalAccessException("Could not call " + call); - } catch (InstantiationException e) { - throw new IllegalArgumentException(e); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(e); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(e); - } - } - - /** - * Reflectively performs the specified invocation and returns the result. - * - * @requires call is of the form "name(arg1, arg2, ..., argn)" where name is the - * full name of the static method to be invoked (e.g. - * java.lang.Integer#parseInt) and the arguments are either strings, - * primitives, objects corresponding to primitives (Integer, Long, - * etc), or publicly accessible Enums. - * @throws IllegalArgumentException - call is not formatted as specified above, - * or it could not be made for some reason. - * @return an object of type T, created reflectively from executing the given - * call String - */ - @SuppressWarnings("unchecked" ) - public static T create(String call) { - try { - name.reset(call); - if (!name.find()) - throw new IllegalArgumentException("Badly formatted call: " + call); - final String[] parts = name.group(1).split("#"); - if (parts.length != 2) - throw new IllegalArgumentException("Badly formatted call: " + call); - final Class< ? > callClass = findClass(parts[0]); - - final String[] args = args(call); - - for (Method m : callClass.getDeclaredMethods()) { - final int mod = m.getModifiers(); - if (!(parts[1].equals(m.getName()) && Modifier.isPublic(mod) && Modifier.isStatic(mod))) - continue; - final Class< ? >[] argTypes = m.getParameterTypes(); - if (argTypes.length == args.length) { - final Object[] convertedArgs = convert(args, argTypes); - if (convertedArgs != null) { - return (T) m.invoke(null, convertedArgs); - } - } - } - - throw new IllegalAccessException("Could not call " + call); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(e); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(e); - } - } - - /** - * Reflectively performs the specified invocation on the specified instance and - * returns the result. - * - * @requires call is of the form "name(arg1, arg2, ..., argn)" where name is the - * name of the method to be invoked on the specified object and the - * arguments are either strings, primitives, objects corresponding to - * primitives (Integer, Long, etc), or publicly accessible Enums. - * @throws IllegalArgumentException - call is not formatted as specified above, - * or it could not be made for some reason. - * @return an object of type T, created reflectively from executing the given - * call String on the given instance - */ - @SuppressWarnings("unchecked" ) - public static T create(Object instance, String call) { - try { - name.reset(call); - if (!name.find()) - throw new IllegalArgumentException("Badly formatted call: " + call); - final String method = name.group(1); - final Class< ? > callClass = instance.getClass(); - - final String[] args = args(call); - - for (Method m : callClass.getMethods()) { - - if (!method.equals(m.getName())) - continue; - final Class< ? >[] argTypes = m.getParameterTypes(); - if (argTypes.length == args.length) { - final Object[] convertedArgs = convert(args, argTypes); - if (convertedArgs != null) { - return (T) m.invoke(instance, convertedArgs); - } - } - } - - throw new IllegalAccessException("Could not call " + call); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException(e); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException(e); - } - } - -} diff --git a/org.alloytools.kodkod.core/uncompile/taglet/SpecificationTaglet.java b/org.alloytools.kodkod.core/uncompile/taglet/SpecificationTaglet.java deleted file mode 100644 index cbd967d5b..000000000 --- a/org.alloytools.kodkod.core/uncompile/taglet/SpecificationTaglet.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Kodkod -- Copyright (c) 2005-present, Emina Torlak - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package kodkod.util.taglet; - -import java.util.Map; - -import com.sun.javadoc.Doc; -import com.sun.javadoc.MethodDoc; -import com.sun.javadoc.Tag; -import com.sun.tools.doclets.formats.html.TagletOutputImpl; -import com.sun.tools.doclets.internal.toolkit.taglets.InheritableTaglet; -import com.sun.tools.doclets.internal.toolkit.taglets.Taglet; -import com.sun.tools.doclets.internal.toolkit.taglets.TagletOutput; -import com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter; -import com.sun.tools.doclets.internal.toolkit.util.DocFinder; -import com.sun.tools.doclets.internal.toolkit.util.DocFinder.Input; -import com.sun.tools.doclets.internal.toolkit.util.DocFinder.Output; -import com.sun.tools.doclets.internal.toolkit.util.DocletConstants; - - -/** - * Represents a taglet for specification tags: @specfield, @invariant, - * @ensures, and @requires. - * - * @specfield name: String - * - * @author Emina Torlak - */ -public final class SpecificationTaglet implements InheritableTaglet { - private static final int TYPE = 1, FIELD = 2, METHOD = 4, CONSTRUCTOR = 8, PACKAGE = 16, OVERVIEW = 32; - private final String tagName, tagHeader; - private int tagLocations; - - /** - * Constructs a specification taglet for the given tag name, using the - * given header and location specifier. - */ - private SpecificationTaglet(String tagName, String tagHeader, int tagLocations) { - this.tagName = tagName; - this.tagHeader = tagHeader; - this.tagLocations = tagLocations; -// super(tagName, tagHeader, tagLocations); - } - - /** - * Register this Taglet. - * @param tagletMap the map to register this tag to. - */ - public static void register(Map tagletMap) { - register(tagletMap, new SpecificationTaglet("specfield", "Specfields:", TYPE)); - register(tagletMap, new SpecificationTaglet("requires", "Requires:", METHOD+CONSTRUCTOR)); - register(tagletMap, new SpecificationTaglet("ensures", "Ensures:", METHOD+CONSTRUCTOR)); - register(tagletMap, new SpecificationTaglet("invariant", "Invariants:", TYPE+METHOD+CONSTRUCTOR+FIELD)); - } - - /** - * Adds the given taglet to the map. - */ - private static void register(Map tagletMap, Taglet taglet) { - final Taglet current = tagletMap.get(taglet.getName()); - if (current != null) - tagletMap.remove(taglet.getName()); - tagletMap.put(taglet.getName(), taglet); - - } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#getName() - */ - @Override - public String getName() { return tagName; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.InheritableTaglet#inherit(com.sun.tools.doclets.internal.toolkit.util.DocFinder.Input, com.sun.tools.doclets.internal.toolkit.util.DocFinder.Output) - */ - @Override - public void inherit(Input input, Output output) { - if (input.method != null) { - final Tag[] tags = input.method.tags(tagName); - if (tags.length > 0) { - output.holder = input.method; - output.holderTag = tags[0]; - output.inlineTags = input.isFirstSentence ? - tags[0].firstSentenceTags() : tags[0].inlineTags(); - } - } - } - - /** - * Appends the formatted definition header to the given buffer. - * @return out - */ - private StringBuilder writeHeader(StringBuilder out) { - return out.append(DocletConstants.NL) - .append("
").append(tagHeader).append("
"); - } - - /** - * Appends the formatted definition tag to the given buffer. - * @return out - */ - private StringBuilder writeTag(StringBuilder out, Tag tag, TagletWriter writer) { - return out.append(DocletConstants.NL) - .append("
") - .append(writer.commentTagsToOutput(tag, null, tag.inlineTags(), false)) - .append("
"); - } - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#getTagletOutput(com.sun.javadoc.Tag, com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter) - */ - @Override - public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException { - final StringBuilder out = writeTag(writeHeader(new StringBuilder()), tag, writer); - return new TagletOutputImpl(out.toString()); - } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#getTagletOutput(com.sun.javadoc.Doc, com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter) - */ - @Override - public TagletOutput getTagletOutput(Doc doc, TagletWriter writer) throws IllegalArgumentException { - Tag[] tags = doc.tags(getName()); - if (tags.length==0 && doc instanceof MethodDoc) { // inherit if necessary and possible - final DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) doc, this)); - tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag}; - } - if (tags.length==0) - return null; - final StringBuilder out = writeHeader(new StringBuilder()); - for(Tag tag : tags) { - writeTag(out, tag, writer); - } - return new TagletOutputImpl(out.toString()); - } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#inConstructor() - */ - @Override - public boolean inConstructor() { return (tagLocations & CONSTRUCTOR) != 0; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#inField() - */ - @Override - public boolean inField() { return (tagLocations & FIELD) != 0; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#inMethod() - */ - @Override - public boolean inMethod() { return (tagLocations & METHOD) != 0; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#inOverview() - */ - @Override - public boolean inOverview() { return (tagLocations & OVERVIEW) != 0; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#inPackage() - */ - @Override - public boolean inPackage() { return (tagLocations & PACKAGE) != 0; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#inType() - */ - @Override - public boolean inType() { return (tagLocations & TYPE) != 0; } - - /** - * {@inheritDoc} - * @see com.sun.tools.doclets.internal.toolkit.taglets.Taglet#isInlineTag() - */ - @Override - public boolean isInlineTag() { return false; } - - -} diff --git a/org.alloytools.kodkod.core/uncompile/taglet/kodkod.css b/org.alloytools.kodkod.core/uncompile/taglet/kodkod.css deleted file mode 100644 index 4c21d13f3..000000000 --- a/org.alloytools.kodkod.core/uncompile/taglet/kodkod.css +++ /dev/null @@ -1,467 +0,0 @@ -/* Javadoc style sheet */ -/* -Overall document style -*/ -body { - font-size:76%; - margin:0; - background-color: #FFFFFF; color: #323232; - font-family: Verdana, Arial, Helvetica, "Times New Roman", Times, serif; -} -a:link, a:visited { - text-decoration:none; - color: #007800; -} -a:hover, a:focus { - text-decoration:underline; - color: #007800; -} -a:active { - text-decoration:none; - color: #007800; -} -a[name] { - color: #007800; -} -a[name]:hover { - text-decoration:none; - color: #007800; -} -pre { - font-size:1.3em; -} -h1 { - font-size:1.8em; -} -h2 { - font-size:1.5em; -} -h3 { - font-size:1.4em; -} -h4 { - font-size:1.3em; -} -h5 { - font-size:1.2em; -} -h6 { - font-size:1.1em; -} -ul { - list-style-type:disc; -} -code, tt { - font-size:1.2em; -} -dt code { - font-size:1.2em; -} -table tr td dt code { - font-size:1.2em; - vertical-align:top; -} -sup { - font-size:.6em; -} -/* -Document title and Copyright styles -*/ -.clear { - clear:both; - height:0px; - overflow:hidden; -} -.aboutLanguage { - float:right; - padding:0px 21px; - font-size:.8em; - z-index:200; - margin-top:-7px; -} -.legalCopy { - margin-left:.5em; - padding-top: 40px; - margin-top: 40px; -} -.bar a, .bar a:link, .bar a:visited, .bar a:active { - - text-decoration:none; -} -.bar a:hover, .bar a:focus { - text-decoration:none; - color: #007800; -} -.tab { - - padding:8px; - width:5em; - font-weight:bold; -} -/* -Navigation bar styles -*/ -.bar { - padding:.8em .5em .4em .8em; - height:auto;/*height:1.8em;*/ - font-size:1em; - margin:0; -} -.topNav { - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; -} -.bottomNav { - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - margin-top: 20px; -} -.subNav { - font-variant: small-caps; - border-bottom:1px solid #dddddd; - border-top:1px solid #dddddd; - float:left; - width:100%; - overflow:hidden; - box-shadow: 5px 3px 5px #888888; - margin-bottom: 10px; -} -.subNav div { - clear:left; - float:left; - padding:0 0 5px 6px; -} -ul.navList, ul.subNavList { - float:left; - margin:0 25px 0 0; - padding:0; -} -ul.navList li{ - list-style:none; - float:left; - padding:3px 6px; -} -ul.subNavList li{ - list-style:none; - float:left; - font-size:90%; -} -.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { - color:#232323; - font-weight: bold; - text-decoration:none; -} - -.topNav a:hover, .bottomNav a:hover { - text-decoration:none; - color:#007800; -} -.navBarCell1Rev { - background-color:#fff; - margin: auto 5px; - border:1px solid #dddddd; -} -/* -Page header and footer styles -*/ -.header, .footer { - clear:both; - margin:0 20px; - padding:5px 0 10px 0; -} -.indexHeader { - margin:10px; - position:relative; -} -.indexHeader h1 { - font-size:1.3em; -} -h1.title { - background-image: url(kodkod.png); - background-repeat: no-repeat; - text-align: left; - padding-left: 90px; - padding-top: 40px; - padding-bottom: 30px; - margin:10px 0; -} - -.subTitle { - margin:5px 0 0 0; -} -.header ul { - margin:0 0 25px 0; - padding:0; -} -.footer ul { - margin:20px 0 15px 0; -} -.header ul li, .footer ul li { - list-style:none; - font-size:1.2em; -} -/* -Heading styles -*/ -div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { - background-color:#dddddd; - border-top:1px solid #dddddd; - border-bottom:1px solid #dddddd; - margin:0 0 6px -8px; - padding:2px 5px; -} -ul.blockList ul.blockList ul.blockList li.blockList h3 { - background-color:#dddddd; - border-top:1px solid #dddddd; - border-bottom:1px solid #dddddd; - margin:0 0 6px -8px; - padding:2px 5px; -} -ul.blockList ul.blockList li.blockList h3 { - padding:0; - margin:15px 0; -} -ul.blockList li.blockList h2 { - padding:0px 0 20px 0; -} -/* -Page layout container styles -*/ -.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { - clear:both; - padding:10px 20px; - position:relative; -} -.indexContainer { - margin:10px; - position:relative; - font-size:1.0em; -} -.indexContainer h2 { - font-size:1.1em; - padding:0 0 3px 0; -} -.indexContainer ul { - margin:0; - padding:0; -} -.indexContainer ul li { - list-style:none; -} -.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { - font-size:1.1em; - font-weight:bold; - margin:10px 0 0 0; - color:#4E4E4E; -} -.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { - margin:10px 0 10px 20px; -} -.serializedFormContainer dl.nameValue dt { - margin-left:1px; - font-size:1.1em; - display:inline; - font-weight:bold; -} -.serializedFormContainer dl.nameValue dd { - margin:0 0 0 1px; - font-size:1.1em; - display:inline; -} -/* -List styles -*/ -ul.horizontal li { - display:inline; - font-size:0.9em; -} -ul.inheritance { - margin:0; - padding:0; -} -ul.inheritance li { - display:inline; - list-style:none; -} -ul.inheritance li ul.inheritance { - margin-left:15px; - padding-left:15px; - padding-top:1px; -} -ul.blockList, ul.blockListLast { - margin:10px 0 10px 0; - padding:0; -} -ul.blockList li.blockList, ul.blockListLast li.blockList { - list-style:none; - margin-bottom:25px; -} -ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { - padding:0px 20px 5px 10px; - border:1px solid #dddddd; - background-color:#f9f9f9; -} -ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { - padding:0 0 5px 8px; - background-color:#ffffff; - border:1px solid #dddddd; - border-top:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { - margin-left:0; - padding-left:0; - padding-bottom:15px; - border:none; - border-bottom:1px solid #dddddd; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { - list-style:none; - border-bottom:none; - padding-bottom:0; -} -table tr td dl, table tr td dl dt, table tr td dl dd { - margin-top:0; - margin-bottom:1px; -} -/* -Table styles -*/ -.contentContainer table, .classUseContainer table, .constantValuesContainer table { - border-bottom:1px solid #dddddd; - width:100%; -} -.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { - width:100%; -} -.contentContainer .description table, .contentContainer .details table { - border-bottom:none; -} -.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ - vertical-align:top; - padding-right:20px; -} -.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, -.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, -.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, -.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { - padding-right:3px; -} -.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { - position:relative; - text-align:left; - color:#555555; - font-weight:bold; - clear:none; - overflow:hidden; - padding:0px; - margin:0px; -} -caption a:link, caption a:hover, caption a:active, caption a:visited { - color:#FFFFFF; -} -.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { - white-space:nowrap; - padding-top:8px; - padding-left:8px; - display:block; - float:left; - height:18px; -} -.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { - width:10px; - position:relative; - float:left; -} -ul.blockList ul.blockList li.blockList table { - margin:0 0 12px 0px; - width:100%; -} -.tableSubHeadingColor { - background-color: #EEEEFF; -} -.altColor { - background-color:#eeeeef; -} -.rowColor { - background-color:#ffffff; -} -.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { - text-align:left; - padding:3px 3px 3px 7px; -} -th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { - background:#dddddd; - border-top:1px solid #dddddd; - border-bottom:1px solid #dddddd; - text-align:left; - padding:3px 3px 3px 7px; -} -td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { - font-weight:bold; -} -td.colFirst, th.colFirst { - border-left:1px solid #bbbbbb; - white-space:nowrap; -} -td.colLast, th.colLast { - border-right:1px solid #bbbbbb; -} -td.colOne, th.colOne { - border-right:1px solid #bbbbbb; - border-left:1px solid #bbbbbb; -} -table.overviewSummary { - padding:0px; - margin-left:0px; -} -table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, -table.overviewSummary td.colOne, table.overviewSummary th.colOne { - width:25%; - vertical-align:middle; -} -table.packageSummary td.colFirst, table.overviewSummary th.colFirst { - width:25%; - vertical-align:middle; -} -/* -Content styles -*/ -.description pre { - margin-top:0; -} -.deprecatedContent { - margin:0; - padding:10px 0; -} -.docSummary { - padding:0; -} -/* -Formatting effect styles -*/ -.sourceLineNo { - color:green; - padding:0 30px 0 0; -} -h1.hidden { - visibility:hidden; - overflow:hidden; - font-size:.9em; -} -.block { - display:block; - margin:3px 0 0 0; -} -.strong { - font-weight:bold; -} diff --git a/org.alloytools.kodkod.core/uncompile/taglet/kodkod.png b/org.alloytools.kodkod.core/uncompile/taglet/kodkod.png deleted file mode 100644 index 391036525..000000000 Binary files a/org.alloytools.kodkod.core/uncompile/taglet/kodkod.png and /dev/null differ diff --git a/org.alloytools.kodkod.core/uncompile/taglet/kodkod1.5.css b/org.alloytools.kodkod.core/uncompile/taglet/kodkod1.5.css deleted file mode 100644 index a2dc3cd62..000000000 --- a/org.alloytools.kodkod.core/uncompile/taglet/kodkod1.5.css +++ /dev/null @@ -1,61 +0,0 @@ -/** default stylesheet **/ - - -/** basic body attributes **/ -body { - background-color: #FFFFFF; color: #323232; - font-family: Trebuchet, "Times New Roman", Times, serif; -} - - - -/** link attributes **/ -a {text-decoration: none;} -a:link, a:visited { color: #007800; } -a:hover { text-decoration: underline; } - - -/* header */ - -h1 { - font-family: Verdana, Arial, Helvetica, sans-serif; - background-image: url(kodkod.png); - background-repeat: no-repeat; - text-align: left; - padding-left: 90px; - padding-top: 40px; - padding-bottom: 30px; -} - -hr { border: 1px dotted #DDDDDD; } - - -/* Table colors */ -.TableHeadingColor { background: #DDDDDD } /* Dark gray */ -.TableSubHeadingColor { background: #DDDDDD } /* Light gray */ -.TableRowColor { background: #FFFFFF } /* White */ - -/* Font used in left-hand frame lists */ -.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } -.FrameHeadingFont { font-weight: bold; font-size: 90%; font-family: Helvetica, Arial, sans-serif } -.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } - -/* Navigation bar fonts and colors */ -td.NavBarCell1 { background-color:#fff; padding:0;border:0; width: 100em;} -td table td.NavBarCell1 { - background-color:#fffff; - padding:4px 6px 4px 6px; - border:1px solid #bbb; - width: 5em; -} - -.NavBarCell1Rev { background-color:#DDDDDD; margin: 0; padding:4px 6px 4px 6px;border:1px solid #bbb;width: 5em;} /* Dark gray */ -.NavBarFont1 { color:#000000;} -.NavBarFont1Rev { color:#000000;} - -.NavBarCell2 { background-color:#FFFFFF; padding:8px 8px 4px 4px;border:0; text-align: left;} -.NavBarCell3 { background-color:#FFFFFF; padding:4px 8px 4px 4px;border:0; text-align: left;} - -td.NavBarCell3:first-child { - padding-left: .45em; -} diff --git a/org.alloytools.kodkod.nativesat/.classpath b/org.alloytools.kodkod.nativesat/.classpath index 08abc6d26..46d4d1a9a 100644 --- a/org.alloytools.kodkod.nativesat/.classpath +++ b/org.alloytools.kodkod.nativesat/.classpath @@ -1,8 +1,11 @@ - - - + + + + + + diff --git a/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.core.prefs b/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.core.prefs index 581b9f158..6f9e91618 100644 --- a/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.core.prefs +++ b/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.core.prefs @@ -137,8 +137,11 @@ org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=4 org.eclipse.jdt.core.formatter.align_type_members_on_columns=true +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=2 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=51 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=50 @@ -148,6 +151,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_e org.eclipse.jdt.core.formatter.alignment_for_assignment=2 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=2 org.eclipse.jdt.core.formatter.alignment_for_compact_if=2 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=2 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=2 @@ -191,6 +195,8 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true @@ -242,13 +248,13 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert @@ -415,6 +421,9 @@ org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false diff --git a/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.ui.prefs b/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.ui.prefs index dcee2a4d2..4282c280f 100644 --- a/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.ui.prefs +++ b/org.alloytools.kodkod.nativesat/.settings/org.eclipse.jdt.ui.prefs @@ -60,7 +60,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Alloy -formatter_settings_version=13 +formatter_settings_version=14 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true org.eclipse.jdt.ui.ignorelowercasenames=true diff --git a/org.alloytools.kodkod.nativesat/jni/amd64-linux/electrod b/org.alloytools.kodkod.nativesat/jni/amd64-linux/electrod new file mode 100644 index 000000000..6d2868298 Binary files /dev/null and b/org.alloytools.kodkod.nativesat/jni/amd64-linux/electrod differ diff --git a/org.alloytools.kodkod.nativesat/jni/x86-mac/electrod b/org.alloytools.kodkod.nativesat/jni/x86-mac/electrod new file mode 100755 index 000000000..9eb3f2398 Binary files /dev/null and b/org.alloytools.kodkod.nativesat/jni/x86-mac/electrod differ diff --git a/org.alloytools.kodkod.nativesat/jni/x86-windows/electrod.exe b/org.alloytools.kodkod.nativesat/jni/x86-windows/electrod.exe new file mode 100644 index 000000000..26809bbae Binary files /dev/null and b/org.alloytools.kodkod.nativesat/jni/x86-windows/electrod.exe differ diff --git a/org.alloytools.kodkod.nativesat/src/main/java/org/alloytools/nativecode/util/NativeCode.java b/org.alloytools.kodkod.nativesat/src/main/java/org/alloytools/nativecode/util/NativeCode.java index 0d2482b86..d34564b83 100644 --- a/org.alloytools.kodkod.nativesat/src/main/java/org/alloytools/nativecode/util/NativeCode.java +++ b/org.alloytools.kodkod.nativesat/src/main/java/org/alloytools/nativecode/util/NativeCode.java @@ -10,6 +10,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; +/** + * @modified [electrum] find executable binaries + */ public class NativeCode { static class Platform { @@ -48,6 +51,47 @@ public Platform(String osnames, String osarch, String dir) { public static Platform platform = findPlatform(); + public static String findexecutable(Path cache, String name) throws RuntimeException { + try { + if (platform.dir == null) + return null; + + Platform p = platform; + String libraryName = name; + + String file = platform.dir + "/" + libraryName; + Enumeration enumeration = NativeCode.class.getClassLoader().getResources(file); + if (!enumeration.hasMoreElements()) { + System.out.println("Could not find native lib " + file); + return null; + } + URL resource = enumeration.nextElement(); + System.out.println("Found native lib '" + resource + "'"); + + Path to = cached.computeIfAbsent(name, (k) -> { + try { + if (cache == null) { + Path tox = Files.createTempFile(name, libraryName); + tox.toFile().deleteOnExit(); + Files.copy(resource.openStream(), tox, StandardCopyOption.REPLACE_EXISTING); + return tox; + } else { + cache.toFile().mkdirs(); + return cache.resolve(libraryName); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + + to.toFile().setExecutable(true); + return to.toFile().getAbsolutePath(); + + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @SuppressWarnings("unused" ) public static boolean loadlibrary(Path cache, String name) throws RuntimeException { try { diff --git a/org.alloytools.kodkod.nativesat/x86-mac.bnd b/org.alloytools.kodkod.nativesat/x86-mac.bnd index 57e0046ad..68b744594 100644 --- a/org.alloytools.kodkod.nativesat/x86-mac.bnd +++ b/org.alloytools.kodkod.nativesat/x86-mac.bnd @@ -10,6 +10,9 @@ Bundle-NativeCode: \ osname=MacOSX; \ processor=x86, \ x86-mac/libminisatprover.dylib; \ + osname=MacOSX; \ + processor=x86, \ + x86-mac/electrod; \ osname=MacOSX; \ processor=x86 diff --git a/org.alloytools.pardinus b/org.alloytools.pardinus new file mode 160000 index 000000000..feafcf7a8 --- /dev/null +++ b/org.alloytools.pardinus @@ -0,0 +1 @@ +Subproject commit feafcf7a83ada1ad750f27aaf0fd6a0db941c8e2 diff --git a/org.alloytools.satsolver.provider/extern/minisat/minisat b/org.alloytools.satsolver.provider/extern/minisat/minisat deleted file mode 160000 index 3db58943b..000000000 --- a/org.alloytools.satsolver.provider/extern/minisat/minisat +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3db58943b6ffe855d3b8c9a959300d9a148ab554