tla-ts 0.0.4-dev.a0009b7 → 0.0.4-dev.a11a30a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -143
- package/dist/deciders.cjs +366 -0
- package/dist/deciders.js +366 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -4
- package/dist/parallel-worker.js +1 -4
- package/dist/prove-worker.cjs +9 -0
- package/dist/prove-worker.d.cts +9 -0
- package/dist/prove-worker.d.ts +9 -0
- package/dist/prove-worker.js +9 -0
- package/dist/prove.cjs +996 -0
- package/dist/prove.js +996 -0
- package/dist/run-cli.cjs +37 -47
- package/dist/run-cli.js +37 -47
- package/dist/tlapm.cjs +10 -0
- package/dist/tlapm.js +10 -0
- package/dist/transfer.cjs +38 -44
- package/dist/transfer.js +38 -44
- package/dist/worker.cjs +21 -0
- package/dist/worker.js +21 -0
- package/package.json +21 -12
- package/src/check.ts +1 -0
- package/src/codegen.ts +26 -7
- package/src/errors.ts +86 -0
- package/src/evaluate.ts +63 -20
- package/src/index.ts +10 -0
- package/src/{obligation-action.ts → obligations/action.ts} +247 -69
- package/src/{obligation-anon.ts → obligations/anon.ts} +49 -47
- package/src/obligations/ctx.ts +64 -0
- package/src/{obligation-deref.ts → obligations/deref.ts} +51 -92
- package/src/{obligation-expression.ts → obligations/expression.ts} +117 -57
- package/src/{obligation-format.ts → obligations/format.ts} +7 -8
- package/src/{obligation-generate.ts → obligations/generate.ts} +170 -192
- package/src/{obligations.ts → obligations/index.ts} +32 -16
- package/src/{obligation-levels.ts → obligations/levels.ts} +26 -28
- package/src/{obligation-module.ts → obligations/module.ts} +113 -121
- package/src/obligations/pickle.ts +98 -0
- package/src/obligations/pragma.ts +189 -0
- package/src/{obligation-printer.ts → obligations/printer.ts} +22 -80
- package/src/{obligation-proof.ts → obligations/proof.ts} +7 -2
- package/src/{obligation-source.ts → obligations/source.ts} +154 -99
- package/src/obligations/temporal.ts +321 -0
- package/src/{obligation-tuples.ts → obligations/tuples.ts} +38 -54
- package/src/ocaml-marshal.ts +166 -0
- package/src/parallel-worker.ts +2 -18
- package/src/parallel.ts +10 -43
- package/src/prove/decide-pool.ts +95 -0
- package/src/prove/deciders.ts +33 -0
- package/src/prove/first-order.ts +78 -0
- package/src/prove/isabelle/LICENSE +36 -0
- package/src/prove/isabelle/LICENSE-tlapm +26 -0
- package/src/prove/isabelle/decide.ts +47 -0
- package/src/prove/isabelle/encode.ts +446 -0
- package/src/prove/isabelle/isar/inner-syntax.ts +579 -0
- package/src/prove/isabelle/isar/method.ts +367 -0
- package/src/prove/isabelle/isar/proof.ts +28 -0
- package/src/prove/isabelle/isar/statement.ts +57 -0
- package/src/prove/isabelle/isar/theory.ts +192 -0
- package/src/prove/isabelle/isar/type-check.ts +278 -0
- package/src/prove/isabelle/provers/blast/blast.ts +258 -0
- package/src/prove/isabelle/provers/blast/branch.ts +322 -0
- package/src/prove/isabelle/provers/blast/prove.ts +347 -0
- package/src/prove/isabelle/provers/blast/rules.ts +330 -0
- package/src/prove/isabelle/provers/blast/state.ts +180 -0
- package/src/prove/isabelle/provers/blast/term.ts +547 -0
- package/src/prove/isabelle/provers/clasimp.ts +150 -0
- package/src/prove/isabelle/provers/classical.ts +389 -0
- package/src/prove/isabelle/provers/hypsubst.ts +441 -0
- package/src/prove/isabelle/pure/bicompose.ts +174 -0
- package/src/prove/isabelle/pure/consts.ts +32 -0
- package/src/prove/isabelle/pure/conv.ts +79 -0
- package/src/prove/isabelle/pure/drule.ts +264 -0
- package/src/prove/isabelle/pure/envir.ts +363 -0
- package/src/prove/isabelle/pure/goal.ts +53 -0
- package/src/prove/isabelle/pure/interrupt.ts +16 -0
- package/src/prove/isabelle/pure/list.ts +12 -0
- package/src/prove/isabelle/pure/logic.ts +402 -0
- package/src/prove/isabelle/pure/name.ts +110 -0
- package/src/prove/isabelle/pure/net.ts +262 -0
- package/src/prove/isabelle/pure/object-logic.ts +41 -0
- package/src/prove/isabelle/pure/pattern.ts +650 -0
- package/src/prove/isabelle/pure/raw-simplifier.ts +353 -0
- package/src/prove/isabelle/pure/rewriter.ts +602 -0
- package/src/prove/isabelle/pure/search.ts +68 -0
- package/src/prove/isabelle/pure/seq.ts +156 -0
- package/src/prove/isabelle/pure/simplifier.ts +112 -0
- package/src/prove/isabelle/pure/table.ts +208 -0
- package/src/prove/isabelle/pure/tactic.ts +276 -0
- package/src/prove/isabelle/pure/tactical.ts +347 -0
- package/src/prove/isabelle/pure/term-ord.ts +159 -0
- package/src/prove/isabelle/pure/term.ts +808 -0
- package/src/prove/isabelle/pure/thm.ts +806 -0
- package/src/prove/isabelle/pure/type.ts +133 -0
- package/src/prove/isabelle/pure/unify.ts +753 -0
- package/src/prove/isabelle/pure/variable.ts +25 -0
- package/src/prove/isabelle/tla/classical-setup.ts +101 -0
- package/src/prove/isabelle/tla/context.ts +74 -0
- package/src/prove/isabelle/tla/logic-data.ts +5 -0
- package/src/prove/isabelle/tla/logic.ts +215 -0
- package/src/prove/isabelle/tla/simpdata.ts +241 -0
- package/src/prove/isabelle/tools/intuitionistic.ts +132 -0
- package/src/prove/ocaml.ts +22 -0
- package/src/prove/prep/action.ts +508 -0
- package/src/prove/prep/defs.ts +33 -0
- package/src/prove/prep/elab.ts +156 -0
- package/src/prove/prep/enabled-axioms.ts +189 -0
- package/src/prove/prep/enabled.ts +43 -0
- package/src/prove/prep/fingerprint.ts +388 -0
- package/src/prove/prep/flatten.ts +70 -0
- package/src/prove/prep/level-comparison.ts +529 -0
- package/src/prove/prep/md5.ts +67 -0
- package/src/prove/prep/pragma.ts +221 -0
- package/src/prove/prep/trivial.ts +22 -0
- package/src/prove/prove-worker.ts +22 -0
- package/src/prove/prove.ts +498 -0
- package/src/prove/ptl/decide.ts +68 -0
- package/src/prove/ptl/encode.ts +255 -0
- package/src/prove/ptl/sat.ts +151 -0
- package/src/prove/ptl/tableau.ts +276 -0
- package/src/prove/smt/axiomatize.ts +69 -0
- package/src/prove/smt/axioms.ts +209 -0
- package/src/prove/smt/context.ts +108 -0
- package/src/prove/smt/data.ts +636 -0
- package/src/prove/smt/encode.ts +164 -0
- package/src/prove/smt/extensionality.ts +65 -0
- package/src/prove/smt/flatten.ts +112 -0
- package/src/prove/smt/format.ts +154 -0
- package/src/prove/smt/instances.ts +181 -0
- package/src/prove/smt/rewrite.ts +772 -0
- package/src/prove/smt/simplify.ts +57 -0
- package/src/prove/smt/solver/act-cache.ts +265 -0
- package/src/prove/smt/solver/arith-rewriter.ts +962 -0
- package/src/prove/smt/solver/array.ts +22 -0
- package/src/prove/smt/solver/asserted-formulas.ts +469 -0
- package/src/prove/smt/solver/ast-lt.ts +157 -0
- package/src/prove/smt/solver/ast-util.ts +147 -0
- package/src/prove/smt/solver/ast.ts +1315 -0
- package/src/prove/smt/solver/auf-solver.ts +572 -0
- package/src/prove/smt/solver/case-split-queue.ts +178 -0
- package/src/prove/smt/solver/cg-table.ts +175 -0
- package/src/prove/smt/solver/clause.ts +276 -0
- package/src/prove/smt/solver/conflict-resolution.ts +343 -0
- package/src/prove/smt/solver/context.ts +1292 -0
- package/src/prove/smt/solver/ctx-simplify.ts +334 -0
- package/src/prove/smt/solver/der.ts +224 -0
- package/src/prove/smt/solver/dyn-ack.ts +141 -0
- package/src/prove/smt/solver/e-matching.ts +659 -0
- package/src/prove/smt/solver/enode.ts +259 -0
- package/src/prove/smt/solver/expr-ref.ts +21 -0
- package/src/prove/smt/solver/expr-safe-replace.ts +172 -0
- package/src/prove/smt/solver/fingerprints.ts +92 -0
- package/src/prove/smt/solver/flat-literals.ts +51 -0
- package/src/prove/smt/solver/goal.ts +138 -0
- package/src/prove/smt/solver/hash.ts +173 -0
- package/src/prove/smt/solver/hashtable.ts +166 -0
- package/src/prove/smt/solver/internalizer.ts +1381 -0
- package/src/prove/smt/solver/lbool.ts +5 -0
- package/src/prove/smt/solver/literal.ts +24 -0
- package/src/prove/smt/solver/lp/bound-propagator.ts +391 -0
- package/src/prove/smt/solver/lp/constraints.ts +78 -0
- package/src/prove/smt/solver/lp/containers.ts +296 -0
- package/src/prove/smt/solver/lp/core-solver.ts +504 -0
- package/src/prove/smt/solver/lp/cross-nested.ts +224 -0
- package/src/prove/smt/solver/lp/dep-intervals.ts +656 -0
- package/src/prove/smt/solver/lp/dependency.ts +51 -0
- package/src/prove/smt/solver/lp/dioph-eq.ts +1181 -0
- package/src/prove/smt/solver/lp/explanation.ts +46 -0
- package/src/prove/smt/solver/lp/gomory.ts +255 -0
- package/src/prove/smt/solver/lp/hnf-cutter.ts +125 -0
- package/src/prove/smt/solver/lp/hnf.ts +281 -0
- package/src/prove/smt/solver/lp/int-cube.ts +295 -0
- package/src/prove/smt/solver/lp/int-solver.ts +514 -0
- package/src/prove/smt/solver/lp/lar-solver.ts +816 -0
- package/src/prove/smt/solver/lp/lar-term.ts +62 -0
- package/src/prove/smt/solver/lp/lp-settings.ts +91 -0
- package/src/prove/smt/solver/lp/maximize-term.ts +347 -0
- package/src/prove/smt/solver/lp/nex-creator.ts +381 -0
- package/src/prove/smt/solver/lp/nex.ts +120 -0
- package/src/prove/smt/solver/lp/nla-backoff.ts +43 -0
- package/src/prove/smt/solver/lp/nla-basics.ts +398 -0
- package/src/prove/smt/solver/lp/nla-core.ts +968 -0
- package/src/prove/smt/solver/lp/nla-divisions.ts +332 -0
- package/src/prove/smt/solver/lp/nla-emonics.ts +373 -0
- package/src/prove/smt/solver/lp/nla-factorization.ts +30 -0
- package/src/prove/smt/solver/lp/nla-grobner.ts +904 -0
- package/src/prove/smt/solver/lp/nla-horner.ts +126 -0
- package/src/prove/smt/solver/lp/nla-intervals.ts +265 -0
- package/src/prove/smt/solver/lp/nla-monomial-bounds.ts +715 -0
- package/src/prove/smt/solver/lp/nla-monotone.ts +59 -0
- package/src/prove/smt/solver/lp/nla-order.ts +307 -0
- package/src/prove/smt/solver/lp/nla-patcher.ts +112 -0
- package/src/prove/smt/solver/lp/nla-tangents.ts +251 -0
- package/src/prove/smt/solver/lp/nla-throttle.ts +85 -0
- package/src/prove/smt/solver/lp/nla-types.ts +124 -0
- package/src/prove/smt/solver/lp/nla-var-eqs.ts +141 -0
- package/src/prove/smt/solver/lp/nra-solver.ts +440 -0
- package/src/prove/smt/solver/lp/numeric-pair.ts +65 -0
- package/src/prove/smt/solver/lp/pdd-interval.ts +31 -0
- package/src/prove/smt/solver/lp/pdd-simplifier.ts +184 -0
- package/src/prove/smt/solver/lp/pdd-solver.ts +408 -0
- package/src/prove/smt/solver/lp/pdd.ts +971 -0
- package/src/prove/smt/solver/lp/random-updater.ts +138 -0
- package/src/prove/smt/solver/lp/static-matrix.ts +246 -0
- package/src/prove/smt/solver/lp/union-find.ts +96 -0
- package/src/prove/smt/solver/mam-compiler.ts +847 -0
- package/src/prove/smt/solver/mam-interpreter.ts +400 -0
- package/src/prove/smt/solver/maximize-ac-sharing.ts +118 -0
- package/src/prove/smt/solver/model-checker.ts +347 -0
- package/src/prove/smt/solver/model-evaluator.ts +262 -0
- package/src/prove/smt/solver/model-finder.ts +155 -0
- package/src/prove/smt/solver/model-generator.ts +97 -0
- package/src/prove/smt/solver/model-macro-solver.ts +728 -0
- package/src/prove/smt/solver/nlsat/algebraic.ts +1161 -0
- package/src/prove/smt/solver/nlsat/atoms.ts +238 -0
- package/src/prove/smt/solver/nlsat/evaluator.ts +303 -0
- package/src/prove/smt/solver/nlsat/explain.ts +607 -0
- package/src/prove/smt/solver/nlsat/interval-set.ts +351 -0
- package/src/prove/smt/solver/nlsat/levelwise.ts +740 -0
- package/src/prove/smt/solver/nlsat/mpbq.ts +161 -0
- package/src/prove/smt/solver/nlsat/polynomial.ts +1722 -0
- package/src/prove/smt/solver/nlsat/solver.ts +911 -0
- package/src/prove/smt/solver/nlsat/types.ts +43 -0
- package/src/prove/smt/solver/nlsat/upolynomial-factorization.ts +648 -0
- package/src/prove/smt/solver/nlsat/upolynomial.ts +996 -0
- package/src/prove/smt/solver/nnf.ts +469 -0
- package/src/prove/smt/solver/pattern-inference.ts +351 -0
- package/src/prove/smt/solver/poly-rewriter.ts +477 -0
- package/src/prove/smt/solver/propagate-values.ts +83 -0
- package/src/prove/smt/solver/proto-model.ts +551 -0
- package/src/prove/smt/solver/pull-quant.ts +139 -0
- package/src/prove/smt/solver/qe-lite-der.ts +526 -0
- package/src/prove/smt/solver/qe-lite-fm.ts +576 -0
- package/src/prove/smt/solver/qe-lite.ts +381 -0
- package/src/prove/smt/solver/qi-queue.ts +362 -0
- package/src/prove/smt/solver/quant-tactics.ts +117 -0
- package/src/prove/smt/solver/quantifier-analyzer.ts +562 -0
- package/src/prove/smt/solver/quantifier-manager.ts +186 -0
- package/src/prove/smt/solver/random-gen.ts +10 -0
- package/src/prove/smt/solver/rational.ts +165 -0
- package/src/prove/smt/solver/ref-vector.ts +62 -0
- package/src/prove/smt/solver/relevancy.ts +247 -0
- package/src/prove/smt/solver/rewriter-tpl.ts +1159 -0
- package/src/prove/smt/solver/rewriter.ts +843 -0
- package/src/prove/smt/solver/rlimit.ts +79 -0
- package/src/prove/smt/solver/smtlib-parser.ts +526 -0
- package/src/prove/smt/solver/solver.ts +71 -0
- package/src/prove/smt/solver/sort.ts +35 -0
- package/src/prove/smt/solver/sticky-generations.ts +69 -0
- package/src/prove/smt/solver/theory-lra-axioms.ts +340 -0
- package/src/prove/smt/solver/theory-lra-bounds.ts +226 -0
- package/src/prove/smt/solver/theory-lra-final-check.ts +252 -0
- package/src/prove/smt/solver/theory-lra-internalize.ts +476 -0
- package/src/prove/smt/solver/theory-lra-model.ts +243 -0
- package/src/prove/smt/solver/theory-lra-propagate.ts +405 -0
- package/src/prove/smt/solver/theory-lra-state.ts +43 -0
- package/src/prove/smt/solver/theory-lra.ts +56 -0
- package/src/prove/smt/solver/var-subst.ts +258 -0
- package/src/prove/smt/solver/z3-license.txt +10 -0
- package/src/prove/smt/table.ts +170 -0
- package/src/prove/tlapm/tlapm.ts +96 -0
- package/src/prove/tlaps-module.ts +510 -0
- package/src/prove/verdict.ts +18 -0
- package/src/prove/zenon/LICENSE +32 -0
- package/src/prove/zenon/check/check.ts +105 -0
- package/src/prove/zenon/check/definitions.ts +144 -0
- package/src/prove/zenon/check/equality.ts +182 -0
- package/src/prove/zenon/check/functions.ts +62 -0
- package/src/prove/zenon/check/keys.ts +125 -0
- package/src/prove/zenon/check/propositional.ts +104 -0
- package/src/prove/zenon/check/records.ts +188 -0
- package/src/prove/zenon/check/relations.ts +121 -0
- package/src/prove/zenon/check/rewrites.ts +224 -0
- package/src/prove/zenon/check/sets.ts +302 -0
- package/src/prove/zenon/check/terms.ts +127 -0
- package/src/prove/zenon/check/tla.ts +126 -0
- package/src/prove/zenon/decide.ts +113 -0
- package/src/prove/zenon/encode.ts +379 -0
- package/src/prove/zenon/eqrel.ts +300 -0
- package/src/prove/zenon/equality-rules.ts +435 -0
- package/src/prove/zenon/expr.ts +551 -0
- package/src/prove/zenon/index-table.ts +350 -0
- package/src/prove/zenon/isar-case.ts +513 -0
- package/src/prove/zenon/isar.ts +1249 -0
- package/src/prove/zenon/limits.ts +15 -0
- package/src/prove/zenon/llproof.ts +173 -0
- package/src/prove/zenon/mltoll.ts +1566 -0
- package/src/prove/zenon/node.ts +297 -0
- package/src/prove/zenon/ocaml.ts +169 -0
- package/src/prove/zenon/parse.ts +247 -0
- package/src/prove/zenon/phrase.ts +191 -0
- package/src/prove/zenon/proof.ts +198 -0
- package/src/prove/zenon/propositional-rules.ts +387 -0
- package/src/prove/zenon/rules.ts +94 -0
- package/src/prove/zenon/search.ts +288 -0
- package/src/prove/zenon/tla/functions.ts +151 -0
- package/src/prove/zenon/tla/llproof.ts +480 -0
- package/src/prove/zenon/tla/records.ts +225 -0
- package/src/prove/zenon/tla/rewrites.ts +447 -0
- package/src/prove/zenon/tla/sets.ts +304 -0
- package/src/prove/zenon/tla/terms.ts +181 -0
- package/src/prove/zenon/tla/tla.ts +506 -0
- package/src/run-cli.ts +283 -81
- package/src/standard-modules.ts +5 -2
- package/src/successors.ts +24 -5
- package/src/tlapm-cache.ts +236 -0
- package/src/tlc-random.ts +55 -32
- package/src/tlc-version.ts +8 -7
- package/src/values.ts +97 -47
- package/src/worker.ts +65 -0
- package/dist/parallel.cjs +0 -12
- package/dist/parallel.js +0 -12
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Ported from Z3 (src/math/lp/nla_monotone_lemmas.h, src/math/lp/nla_monotone_lemmas.cpp), MIT
|
|
2
|
+
// license, see z3-license.txt. The monotonicity lemmas of nla: the absolute value of a monomial is
|
|
3
|
+
// at most, or at least, the product of its factors' absolute values when they are.
|
|
4
|
+
import { Rational } from "../rational";
|
|
5
|
+
import { KIND_GE, KIND_GT, KIND_LE, KIND_LT } from "./constraints";
|
|
6
|
+
import { type NlaCore } from "./nla-core";
|
|
7
|
+
import { LemmaBuilder, mkIneq } from "./nla-types";
|
|
8
|
+
import type { Monic } from "./nla-emonics";
|
|
9
|
+
import { THROTTLE_MONOTONE_LEMMA } from "./nla-throttle";
|
|
10
|
+
|
|
11
|
+
export class Monotone {
|
|
12
|
+
constructor(private core: NlaCore) {}
|
|
13
|
+
|
|
14
|
+
monotonicityLemma() {
|
|
15
|
+
const core = this.core;
|
|
16
|
+
const shift = core.random();
|
|
17
|
+
const size = core.toRefine.size;
|
|
18
|
+
for (let index = 0; index < size && !core.done(); index++)
|
|
19
|
+
this.monotonicityLemmaOnMonic(core.emons.get(core.toRefine.elems[(index + shift) % size]));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private monotonicityLemmaOnMonic(monic: Monic) {
|
|
23
|
+
const core = this.core;
|
|
24
|
+
if (core.monHasZero(monic.vars) || core.hasBigNum(monic)) return;
|
|
25
|
+
const productValue = core.productValue(monic).abs();
|
|
26
|
+
const monicValue = core.varVal(monic).abs();
|
|
27
|
+
const isLt = monicValue.compare(productValue) < 0;
|
|
28
|
+
if (core.throttle.insertMonotone(THROTTLE_MONOTONE_LEMMA, monic.variable, isLt)) return;
|
|
29
|
+
if (isLt) this.monotonicityLemmaLt(monic);
|
|
30
|
+
else if (monicValue.compare(productValue) > 0) this.monotonicityLemmaGt(monic);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// /\_i |m[i]| <= |val(m[i])| => |m| <= |product_i val(m[i])|
|
|
34
|
+
private monotonicityLemmaGt(monic: Monic) {
|
|
35
|
+
const core = this.core;
|
|
36
|
+
const lemma = new LemmaBuilder(core);
|
|
37
|
+
let product = Rational.one;
|
|
38
|
+
for (const lpVar of monic.vars) {
|
|
39
|
+
const value = core.val(lpVar);
|
|
40
|
+
lemma.addIneq(mkIneq(lpVar, value.isNegative() ? KIND_LT : KIND_GT, value));
|
|
41
|
+
lemma.addIneq(mkIneq(lpVar, value.isNegative() ? KIND_GT : KIND_LT, 0));
|
|
42
|
+
product = product.mul(value);
|
|
43
|
+
}
|
|
44
|
+
lemma.addIneq(mkIneq(monic.variable, product.isNegative() ? KIND_GE : KIND_LE, product));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// /\_i |m[i]| >= |val(m[i])| => |m| >= |product_i val(m[i])|
|
|
48
|
+
private monotonicityLemmaLt(monic: Monic) {
|
|
49
|
+
const core = this.core;
|
|
50
|
+
const lemma = new LemmaBuilder(core);
|
|
51
|
+
let product = Rational.one;
|
|
52
|
+
for (const lpVar of monic.vars) {
|
|
53
|
+
const value = core.val(lpVar);
|
|
54
|
+
lemma.addIneq(mkIneq(lpVar, value.isNegative() ? KIND_GT : KIND_LT, value));
|
|
55
|
+
product = product.mul(value);
|
|
56
|
+
}
|
|
57
|
+
lemma.addIneq(mkIneq(monic.variable, product.isNegative() ? KIND_LE : KIND_GE, product));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// Ported from Z3 (src/math/lp/nla_order_lemmas.h, src/math/lp/nla_order_lemmas.cpp), MIT
|
|
2
|
+
// license, see z3-license.txt. The order lemmas of nla: a > b and c > 0 imply ac > bc, over the
|
|
3
|
+
// binary factorizations of the monomials to refine, and the sign lemmas of binomials.
|
|
4
|
+
import { Rational } from "../rational";
|
|
5
|
+
import { KIND_EQ, KIND_GE, KIND_GT, KIND_LE, KIND_LT, KIND_NE } from "./constraints";
|
|
6
|
+
import { LarTerm } from "./lar-term";
|
|
7
|
+
import { NLA_PARAMS, type NlaCore } from "./nla-core";
|
|
8
|
+
import { type Factor, type Factorization, getFactorSign, mkFactor } from "./nla-factorization";
|
|
9
|
+
import { getRatSign, LemmaBuilder, mkIneq, negateKind, signToRat } from "./nla-types";
|
|
10
|
+
import type { Monic } from "./nla-emonics";
|
|
11
|
+
import { getSignedVarVar } from "./nla-var-eqs";
|
|
12
|
+
import { THROTTLE_BINOMIAL_SIGN_LEMMA, THROTTLE_ORDER_LEMMA } from "./nla-throttle";
|
|
13
|
+
|
|
14
|
+
export class Order {
|
|
15
|
+
constructor(private core: NlaCore) {}
|
|
16
|
+
|
|
17
|
+
orderLemma() {
|
|
18
|
+
if (!NLA_PARAMS.order) return;
|
|
19
|
+
const core = this.core;
|
|
20
|
+
const toRefine = core.toRefine;
|
|
21
|
+
const offset = core.random();
|
|
22
|
+
const size = toRefine.size;
|
|
23
|
+
for (let index = 0; index < size && !core.done(); index++)
|
|
24
|
+
this.orderLemmaOnMonic(core.emons.get(toRefine.elems[(index + offset) % size]));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private orderLemmaOnMonic(monic: Monic) {
|
|
28
|
+
const core = this.core;
|
|
29
|
+
for (const factorization of core.getFactorizations(monic)) {
|
|
30
|
+
if (factorization.factors.length !== 2) continue;
|
|
31
|
+
if (factorization.mon !== null) this.orderLemmaOnBinomial(factorization.mon);
|
|
32
|
+
else this.orderLemmaOnFactorization(monic, factorization);
|
|
33
|
+
if (core.done()) break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Either variable of the binomial plays the role of c.
|
|
38
|
+
private orderLemmaOnBinomial(ac: Monic) {
|
|
39
|
+
const core = this.core;
|
|
40
|
+
const isGt = core.varVal(ac).compare(core.mulVal(ac)) > 0;
|
|
41
|
+
for (const k of [0, 1]) {
|
|
42
|
+
this.orderLemmaOnBinomialSign(ac, ac.vars[k], ac.vars[1 - k], isGt ? 1 : -1);
|
|
43
|
+
this.orderLemmaOnFactorBinomialExplore(ac, k);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// y <= 0 or x < a or xy >= ay, and the like for the sign of val(xy) - val(x) * val(y).
|
|
48
|
+
private orderLemmaOnBinomialSign(xy: Monic, x: number, y: number, sign: number) {
|
|
49
|
+
if (!NLA_PARAMS.orderBinomialSign) return;
|
|
50
|
+
const core = this.core;
|
|
51
|
+
if (!core.varIsInt(x) && core.val(x).isBig()) return;
|
|
52
|
+
const ySign = getRatSign(core.val(y));
|
|
53
|
+
if (
|
|
54
|
+
core.throttle.insertBinomialSign(THROTTLE_BINOMIAL_SIGN_LEMMA, xy.variable, x, y, sign, ySign)
|
|
55
|
+
)
|
|
56
|
+
return;
|
|
57
|
+
const lemma = new LemmaBuilder(core);
|
|
58
|
+
lemma.addIneq(mkIneq(y, ySign === 1 ? KIND_LE : KIND_GE, 0));
|
|
59
|
+
lemma.addIneq(mkIneq(x, ySign * sign === 1 ? KIND_GT : KIND_LT, core.val(x)));
|
|
60
|
+
lemma.addIneq(
|
|
61
|
+
mkIneq(
|
|
62
|
+
new LarTerm([
|
|
63
|
+
[xy.variable, Rational.one],
|
|
64
|
+
[y, core.val(x).neg()],
|
|
65
|
+
]),
|
|
66
|
+
sign === 1 ? KIND_LE : KIND_GE,
|
|
67
|
+
0,
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The monics bd with d equivalent to ac[k].
|
|
73
|
+
private orderLemmaOnFactorBinomialExplore(ac: Monic, k: number) {
|
|
74
|
+
const core = this.core;
|
|
75
|
+
for (const bd of core.emons.getProductsOf(ac.vars[k])) {
|
|
76
|
+
if (bd.variable === ac.variable) continue;
|
|
77
|
+
this.orderLemmaOnFactorBinomialRm(ac, k, bd);
|
|
78
|
+
if (core.done()) break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private orderLemmaOnFactorBinomialRm(ac: Monic, k: number, bd: Monic) {
|
|
83
|
+
const d = mkFactor(getSignedVarVar(this.core.varEqs.findVar(ac.vars[k])), false);
|
|
84
|
+
const b = this.core.divide(bd, d);
|
|
85
|
+
if (b !== undefined) this.orderLemmaOnBinomialAcBd(ac, k, bd, b, d.variable);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ac >= bd && |c| = |d| => ac/|c| >= bd/|d|
|
|
89
|
+
private orderLemmaOnBinomialAcBd(ac: Monic, k: number, bd: Monic, b: Factor, d: number) {
|
|
90
|
+
const core = this.core;
|
|
91
|
+
const a = ac.vars[1 - k];
|
|
92
|
+
const c = ac.vars[k];
|
|
93
|
+
const acValue = core.varVal(ac);
|
|
94
|
+
const cSign = Rational.fromNumber(getRatSign(core.val(c)));
|
|
95
|
+
const dSign = Rational.fromNumber(getRatSign(core.val(d)));
|
|
96
|
+
const bdValue = core.varVal(bd);
|
|
97
|
+
const aTimesCSign = core.val(a).mul(cSign);
|
|
98
|
+
const bTimesDSign = core.valFactor(b).mul(dSign);
|
|
99
|
+
if (acValue.compare(bdValue) >= 0 && aTimesCSign.compare(bTimesDSign) < 0)
|
|
100
|
+
this.generateMonOl(ac, a, cSign, c, bd, b, dSign, d, KIND_LT);
|
|
101
|
+
else if (acValue.compare(bdValue) <= 0 && aTimesCSign.compare(bTimesDSign) > 0)
|
|
102
|
+
this.generateMonOl(ac, a, cSign, c, bd, b, dSign, d, KIND_GT);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ac > bd => ac/|c| > bd/|d| => a*c_sign > b*d_sign, whose last inequality does not hold.
|
|
106
|
+
private generateMonOl(
|
|
107
|
+
ac: Monic,
|
|
108
|
+
a: number,
|
|
109
|
+
cSign: Rational,
|
|
110
|
+
c: number,
|
|
111
|
+
bd: Monic,
|
|
112
|
+
b: Factor,
|
|
113
|
+
dSign: Rational,
|
|
114
|
+
d: number,
|
|
115
|
+
abCmp: number,
|
|
116
|
+
) {
|
|
117
|
+
const core = this.core;
|
|
118
|
+
if (
|
|
119
|
+
core.throttle.insertOrder(
|
|
120
|
+
THROTTLE_ORDER_LEMMA,
|
|
121
|
+
ac.variable,
|
|
122
|
+
a,
|
|
123
|
+
cSign,
|
|
124
|
+
c,
|
|
125
|
+
bd.variable,
|
|
126
|
+
b.variable,
|
|
127
|
+
dSign,
|
|
128
|
+
d,
|
|
129
|
+
abCmp,
|
|
130
|
+
)
|
|
131
|
+
)
|
|
132
|
+
return;
|
|
133
|
+
const lemma = new LemmaBuilder(core);
|
|
134
|
+
lemma.addIneq(mkIneq(new LarTerm([[c, cSign]]), KIND_LE, 0));
|
|
135
|
+
lemma.explainVar(c);
|
|
136
|
+
lemma.addIneq(
|
|
137
|
+
mkIneq(
|
|
138
|
+
new LarTerm([
|
|
139
|
+
[a, cSign],
|
|
140
|
+
[b.variable, dSign.mul(getFactorSign(b)).neg()],
|
|
141
|
+
]),
|
|
142
|
+
negateKind(abCmp),
|
|
143
|
+
0,
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
lemma.addIneq(
|
|
147
|
+
mkIneq(
|
|
148
|
+
new LarTerm([
|
|
149
|
+
[ac.variable, Rational.one],
|
|
150
|
+
[bd.variable, Rational.minusOne],
|
|
151
|
+
]),
|
|
152
|
+
abCmp,
|
|
153
|
+
0,
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
lemma.explainMonic(bd);
|
|
157
|
+
lemma.explainFactor(b);
|
|
158
|
+
lemma.explainVar(d);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ac_f[k] plays the role of c.
|
|
162
|
+
private orderLemmaOnAcAndBc(ac: Monic, acFactorization: Factorization, k: number, bd: Monic) {
|
|
163
|
+
const factors = acFactorization.factors;
|
|
164
|
+
const b = this.core.divide(bd, factors[k]);
|
|
165
|
+
return (
|
|
166
|
+
b !== undefined && this.orderLemmaOnAcAndBcAndFactors(ac, factors[1 - k], factors[k], bd, b)
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// m = ab: a monic n = cd with |b| = |d| gives m R n & |b| = |d| => ab/|b| R cd/|d|.
|
|
171
|
+
private orderLemmaOnFactorization(monic: Monic, ab: Factorization) {
|
|
172
|
+
const core = this.core;
|
|
173
|
+
let isNegated = false;
|
|
174
|
+
for (const factor of ab.factors) isNegated = isNegated !== factor.isNegated;
|
|
175
|
+
const sign = signToRat(isNegated);
|
|
176
|
+
const factorsValue = core.val(ab.factors[0].variable).mul(core.val(ab.factors[1].variable));
|
|
177
|
+
const monicValue = sign.mul(core.varVal(monic));
|
|
178
|
+
if (!monicValue.equals(factorsValue) && !core.hasReal(monic)) {
|
|
179
|
+
const isGt = monicValue.compare(factorsValue) > 0;
|
|
180
|
+
for (let j = 0, k = 1; j < 2; j++, k--) {
|
|
181
|
+
const lemma = new LemmaBuilder(core);
|
|
182
|
+
this.orderLemmaOnAb(
|
|
183
|
+
lemma,
|
|
184
|
+
monic,
|
|
185
|
+
sign,
|
|
186
|
+
ab.factors[k].variable,
|
|
187
|
+
ab.factors[j].variable,
|
|
188
|
+
isGt,
|
|
189
|
+
);
|
|
190
|
+
lemma.explainFactorization(ab);
|
|
191
|
+
lemma.explainMonic(monic);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
for (const k of [0, 1]) this.orderLemmaOnAcExplore(monic, ab, k);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private orderLemmaOnAcExplore(rooted: Monic, ac: Factorization, k: number) {
|
|
198
|
+
const c = ac.factors[k];
|
|
199
|
+
const emons = this.core.emons;
|
|
200
|
+
const candidates = c.isMon ? emons.getProductsOf(c.variable) : emons.getUseList(c.variable);
|
|
201
|
+
for (const bc of candidates) if (this.orderLemmaOnAcAndBc(rooted, ac, k, bc)) return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private generateOlEq(ac: Monic, a: Factor, c: Factor, bc: Monic, b: Factor) {
|
|
205
|
+
const lemma = new LemmaBuilder(this.core);
|
|
206
|
+
lemma.addIneq(mkIneq(c.variable, KIND_EQ, 0));
|
|
207
|
+
lemma.addIneq(
|
|
208
|
+
mkIneq(
|
|
209
|
+
new LarTerm([
|
|
210
|
+
[ac.variable, Rational.one],
|
|
211
|
+
[bc.variable, Rational.minusOne],
|
|
212
|
+
]),
|
|
213
|
+
KIND_NE,
|
|
214
|
+
0,
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
lemma.addIneq(
|
|
218
|
+
mkIneq(
|
|
219
|
+
new LarTerm([
|
|
220
|
+
[a.variable, getFactorSign(a)],
|
|
221
|
+
[b.variable, getFactorSign(b).neg()],
|
|
222
|
+
]),
|
|
223
|
+
KIND_EQ,
|
|
224
|
+
0,
|
|
225
|
+
),
|
|
226
|
+
);
|
|
227
|
+
this.explainOl(lemma, ac, a, bc, b, c);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// c > 0 and ac >= bc => a >= b, and the like for the other signs and relations.
|
|
231
|
+
private generateOl(ac: Monic, a: Factor, c: Factor, bc: Monic, b: Factor) {
|
|
232
|
+
const core = this.core;
|
|
233
|
+
const lemma = new LemmaBuilder(core);
|
|
234
|
+
lemma.addIneq(mkIneq(c.variable, core.val(c.variable).isNegative() ? KIND_GE : KIND_LE, 0));
|
|
235
|
+
lemma.addIneq(
|
|
236
|
+
mkIneq(
|
|
237
|
+
new LarTerm([
|
|
238
|
+
[ac.variable, Rational.one],
|
|
239
|
+
[bc.variable, Rational.minusOne],
|
|
240
|
+
]),
|
|
241
|
+
core.varVal(ac).compare(core.varVal(bc)) < 0 ? KIND_GT : KIND_LT,
|
|
242
|
+
0,
|
|
243
|
+
),
|
|
244
|
+
);
|
|
245
|
+
lemma.addIneq(
|
|
246
|
+
mkIneq(
|
|
247
|
+
new LarTerm([
|
|
248
|
+
[a.variable, getFactorSign(a)],
|
|
249
|
+
[b.variable, getFactorSign(b).neg()],
|
|
250
|
+
]),
|
|
251
|
+
core.valFactor(a).compare(core.valFactor(b)) < 0 ? KIND_GE : KIND_LE,
|
|
252
|
+
0,
|
|
253
|
+
),
|
|
254
|
+
);
|
|
255
|
+
this.explainOl(lemma, ac, a, bc, b, c);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private explainOl(lemma: LemmaBuilder, ac: Monic, a: Factor, bc: Monic, b: Factor, c: Factor) {
|
|
259
|
+
lemma.explainMonic(ac);
|
|
260
|
+
lemma.explainFactor(a);
|
|
261
|
+
lemma.explainMonic(bc);
|
|
262
|
+
lemma.explainFactor(b);
|
|
263
|
+
lemma.explainFactor(c);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ac = a*c and bc = b*c: ac >= bc implies ac/|c| >= bc/|c|.
|
|
267
|
+
private orderLemmaOnAcAndBcAndFactors(ac: Monic, a: Factor, c: Factor, bc: Monic, b: Factor) {
|
|
268
|
+
const core = this.core;
|
|
269
|
+
const cSign = Rational.fromNumber(getRatSign(core.valFactor(c)));
|
|
270
|
+
const aTimesCSign = core.valFactor(a).mul(cSign);
|
|
271
|
+
const bTimesCSign = core.valFactor(b).mul(cSign);
|
|
272
|
+
const comparison = core.varVal(ac).compare(core.varVal(bc));
|
|
273
|
+
const factorComparison = aTimesCSign.compare(bTimesCSign);
|
|
274
|
+
if ((comparison > 0 && factorComparison < 0) || (comparison < 0 && factorComparison > 0)) {
|
|
275
|
+
this.generateOl(ac, a, c, bc, b);
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
if (comparison === 0 && factorComparison !== 0) {
|
|
279
|
+
this.generateOlEq(ac, a, c, bc, b);
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// sign * m = ab: b != val(b) or sign*m <= a*val(b), or >= when not gt.
|
|
286
|
+
private orderLemmaOnAb(
|
|
287
|
+
lemma: LemmaBuilder,
|
|
288
|
+
monic: Monic,
|
|
289
|
+
sign: Rational,
|
|
290
|
+
a: number,
|
|
291
|
+
b: number,
|
|
292
|
+
isGt: boolean,
|
|
293
|
+
) {
|
|
294
|
+
const core = this.core;
|
|
295
|
+
lemma.addIneq(mkIneq(b, KIND_NE, core.val(b)));
|
|
296
|
+
lemma.addIneq(
|
|
297
|
+
mkIneq(
|
|
298
|
+
new LarTerm([
|
|
299
|
+
[monic.variable, sign],
|
|
300
|
+
[a, core.val(b).neg()],
|
|
301
|
+
]),
|
|
302
|
+
isGt ? KIND_LE : KIND_GE,
|
|
303
|
+
0,
|
|
304
|
+
),
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Ported from Z3 (src/math/lp/nla_patcher.{h,cpp}, src/util/mpz.cpp is_perfect_square), MIT
|
|
2
|
+
// license, see z3-license.txt. Moves the values of monic variables, or of one of their factors, to
|
|
3
|
+
// agree with the products, without breaking monics that are already correct.
|
|
4
|
+
import { Rational } from "../rational";
|
|
5
|
+
import type { Impq } from "./numeric-pair";
|
|
6
|
+
import type { NlaCore } from "./nla-core";
|
|
7
|
+
import type { Monic } from "./nla-emonics";
|
|
8
|
+
|
|
9
|
+
// in_power: whether the variable at an index occurs next to an equal one.
|
|
10
|
+
const isInPower = (vars: number[], index: number) => {
|
|
11
|
+
const lpVar = vars[index];
|
|
12
|
+
return (
|
|
13
|
+
(index !== 0 && vars[index - 1] === lpVar) ||
|
|
14
|
+
(index + 1 < vars.length && lpVar === vars[index + 1])
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class Patcher {
|
|
19
|
+
private patchedVar = 0;
|
|
20
|
+
private patchedMonic: Monic | undefined;
|
|
21
|
+
|
|
22
|
+
constructor(private core: NlaCore) {}
|
|
23
|
+
|
|
24
|
+
private varBreaksCorrectMonicAsFactor(lpVar: number, monic: Monic) {
|
|
25
|
+
const core = this.core;
|
|
26
|
+
if (!core.varVal(monic).isZero()) return true;
|
|
27
|
+
if (!core.val(lpVar).isZero()) return false;
|
|
28
|
+
return !monic.vars.some((other) => other !== lpVar && core.val(other).isZero());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private varBreaksCorrectMonic(lpVar: number) {
|
|
32
|
+
const core = this.core;
|
|
33
|
+
if (core.isMonicVar(lpVar) && !core.toRefine.has(lpVar)) return true;
|
|
34
|
+
for (const monic of core.emons.getUseList(lpVar)) {
|
|
35
|
+
if (core.toRefine.has(monic.variable)) continue;
|
|
36
|
+
if (this.varBreaksCorrectMonicAsFactor(lpVar, monic)) return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private updateToRefineOfVar(lpVar: number) {
|
|
42
|
+
const core = this.core;
|
|
43
|
+
const update = (monic: Monic) => {
|
|
44
|
+
if (core.varVal(monic).equals(core.mulVal(monic))) core.eraseFromToRefine(monic.variable);
|
|
45
|
+
else core.insertToRefine(monic.variable);
|
|
46
|
+
};
|
|
47
|
+
for (const monic of core.emons.getUseList(lpVar)) update(monic);
|
|
48
|
+
if (core.isMonicVar(lpVar)) update(core.emon(lpVar));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private isPatchBlocked(lpVar: number, value: Impq) {
|
|
52
|
+
const core = this.core;
|
|
53
|
+
if (!core.lra.insideBounds(lpVar, value) || (core.varIsInt(lpVar) && !value.isInt()))
|
|
54
|
+
return true;
|
|
55
|
+
if (lpVar === this.patchedVar) return false;
|
|
56
|
+
const monic = this.patchedMonic;
|
|
57
|
+
if (monic !== undefined && (monic.containsVar(lpVar) || lpVar === monic.variable)) return true;
|
|
58
|
+
return this.varBreaksCorrectMonic(lpVar);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private tryToPatch(value: Rational) {
|
|
62
|
+
return this.core.lra.tryToPatch(
|
|
63
|
+
this.patchedVar,
|
|
64
|
+
value,
|
|
65
|
+
(lpVar, target) => this.isPatchBlocked(lpVar, target),
|
|
66
|
+
(lpVar) => this.updateToRefineOfVar(lpVar),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private patchMonomial(lpVar: number) {
|
|
71
|
+
const core = this.core;
|
|
72
|
+
const monic = core.emon(lpVar);
|
|
73
|
+
this.patchedMonic = monic;
|
|
74
|
+
this.patchedVar = lpVar;
|
|
75
|
+
const product = core.mulVal(monic);
|
|
76
|
+
if (core.val(lpVar).equals(product)) {
|
|
77
|
+
core.eraseFromToRefine(lpVar);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!this.varBreaksCorrectMonic(lpVar) && this.tryToPatch(product)) return;
|
|
81
|
+
if (monic.vars.length === 2 && monic.vars[0] === monic.vars[1]) {
|
|
82
|
+
const root = product.root(2);
|
|
83
|
+
if (root === undefined) return;
|
|
84
|
+
this.patchedVar = monic.vars[0];
|
|
85
|
+
if (!this.varBreaksCorrectMonic(this.patchedVar))
|
|
86
|
+
if (this.tryToPatch(root) || this.tryToPatch(root.neg())) return;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (product.isZero()) return;
|
|
90
|
+
const ratio = core.val(lpVar).div(product);
|
|
91
|
+
for (let index = 0; index < monic.size; index++) {
|
|
92
|
+
this.patchedVar = monic.vars[index];
|
|
93
|
+
if (
|
|
94
|
+
!isInPower(monic.vars, index) &&
|
|
95
|
+
!this.varBreaksCorrectMonic(this.patchedVar) &&
|
|
96
|
+
this.tryToPatch(ratio.mul(core.val(this.patchedVar)))
|
|
97
|
+
) {
|
|
98
|
+
core.eraseFromToRefine(lpVar);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
patchMonomials() {
|
|
105
|
+
const core = this.core;
|
|
106
|
+
const toRefine = [...core.toRefine.elems];
|
|
107
|
+
const size = toRefine.length;
|
|
108
|
+
const start = core.random();
|
|
109
|
+
for (let index = 0; index < size && core.toRefine.size > 0; index++)
|
|
110
|
+
this.patchMonomial(toRefine[(start + index) % size]);
|
|
111
|
+
}
|
|
112
|
+
}
|